4 * Copyright: (c) Universitaet Karlsruhe
5 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
7 * Main file for the optimization reducing the copies needed for:
9 * - register-constrained nodes
15 #include "becopyopt.h"
16 #include "becopystat.h"
17 #include "becopyoptmain.h"
22 #define DEBUG_LVL SET_LEVEL_1
23 static firm_dbg_module_t *dbg = NULL;
25 void be_copy_opt_init(void) {
26 dbg = firm_dbg_register("ir.be.copyopt");
27 firm_dbg_set_mask(dbg, DEBUG_LVL);
30 void be_copy_opt(ir_graph* irg, const arch_env_t *env, const arch_register_class_t *cls) {
33 co = new_copy_opt(irg, env, cls);
34 DBG((dbg, LEVEL_1, "\n\n ===> %s <===\n\n", co->name));
35 co_check_allocation(co);
38 copies = co_get_copy_count(co);
39 curr_vals[I_COPIES_INIT] += copies;
40 DBG((dbg, 1, "Init copies: %3d\n", copies));
45 co_check_allocation(co);
47 copies = co_get_copy_count(co);
48 curr_vals[I_COPIES_HEUR] += copies;
49 DBG((dbg, 1, "Heur copies: %3d\n", copies));
51 DBG((dbg, 1, "Heur copies: %3d\n", co_get_copy_count(co)));
55 lb = co_get_lower_bound(co);
56 copies = co_get_copy_count(co);
57 //TODO remove checks and enable lb
59 DBG((dbg, 0, "\n\nAt least one computation of these two is boooogy %d < %d\n\n", lb, copies));
63 co_check_allocation(co);
65 copies = co_get_copy_count(co);
66 assert(copies>=lb && "At least one computation of these two is boooogy");
69 copies = co_get_copy_count(co);
70 curr_vals[I_COPIES_HEUR] += copies;
71 DBG((dbg, 1, "Opt copies: %3d\n", copies));
73 DBG((dbg, 1, "Opt copies: %3d\n", co_get_copy_count(co)));