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
17 #include "becopyopt.h"
18 #include "becopystat.h"
19 #include "becopyoptmain.h"
24 #define DEBUG_LVL SET_LEVEL_1
25 static firm_dbg_module_t *dbg = NULL;
27 void be_copy_opt_init(void) {
28 dbg = firm_dbg_register("ir.be.copyoptmain");
29 firm_dbg_set_mask(dbg, LEVEL_1);
32 void be_copy_opt(be_chordal_env_t *chordal_env) {
36 /* BETTER: You can remove this if you replace all
37 * `grep get_irn_out *.c` by the irouts.h module.*/
38 compute_outs(chordal_env->session_env->irg);
40 co = new_copy_opt(chordal_env, get_costs_loop_depth);
41 DBG((dbg, LEVEL_1, "----> CO: %s\n", co->name));
44 lb = co_get_lower_bound(co);
45 copy_costs = co_get_copy_costs(co);
46 copystat_add_max_costs(co_get_max_copy_costs(co));
47 copystat_add_inevit_costs(co_get_inevit_copy_costs(co));
48 copystat_add_init_costs(copy_costs);
49 DBG((dbg, LEVEL_1, "Init costs: %3d <= %3d\n", lb, copy_costs));
55 copy_costs = co_get_copy_costs(co);
56 copystat_add_heur_costs(copy_costs);
57 DBG((dbg, LEVEL_1, "Heur costs: %3d <= %3d\n", lb, copy_costs));
62 copy_costs = co_get_copy_costs(co);
63 assert(copy_costs>=lb && "At least one computation of these two is boooogy");
64 if (copy_costs > lb) {
69 copy_costs = co_get_copy_costs(co);
70 assert(copy_costs>=lb && "At least one computation of these two is boooogy");
71 copystat_add_opt_costs(copy_costs);
72 DBG((dbg, LEVEL_1, "Opt costs: %3d <= %3d\n", lb, copy_costs));