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
16 #include <libcore/lc_timing.h>
19 #include "becopyopt.h"
20 #include "becopystat.h"
21 #include "becopyoptmain.h"
27 #define DEBUG_LVL SET_LEVEL_1
28 static firm_dbg_module_t *dbg = NULL;
30 void be_copy_opt_init(void) {
31 dbg = firm_dbg_register("ir.be.copyoptmain");
32 firm_dbg_set_mask(dbg, DEBUG_LVL);
35 void be_copy_opt(be_chordal_env_t *chordal_env) {
37 int costs, costs_init=-1, costs_heur=-1, costs_ilp=-1;
40 /* BETTER: You can remove this if you replace all
41 * `grep get_irn_out *.c` by the irouts.h module.*/
42 compute_outs(chordal_env->session_env->irg);
44 co = new_copy_opt(chordal_env, get_costs_loop_depth);
45 DBG((dbg, LEVEL_1, "----> CO: %s\n", co->name));
46 phi_class_compute(chordal_env->session_env->irg);
49 lower_bound = co_get_lower_bound(co);
50 DBG((dbg, LEVEL_1, "Lower Bound: %3d\n", lower_bound));
51 DBG((dbg, LEVEL_1, "Inevit Costs: %3d\n", co_get_inevit_copy_costs(co)));
53 costs = co_get_copy_costs(co);
55 copystat_add_max_costs(co_get_max_copy_costs(co));
56 copystat_add_inevit_costs(co_get_inevit_copy_costs(co));
57 copystat_add_init_costs(costs_init);
58 DBG((dbg, LEVEL_1, "Init costs: %3d\n", costs_init));
62 lc_timer_t *timer = lc_timer_register("heur", NULL);
63 lc_timer_reset_and_start(timer);
66 copystat_add_heur_time(lc_timer_elapsed_msec(timer));
68 costs = co_get_copy_costs(co);
70 copystat_add_heur_costs(costs_heur);
71 DBG((dbg, LEVEL_1, "Heur costs: %3d\n", costs_heur));
75 assert(lower_bound <= costs_heur);
80 costs = co_get_copy_costs(co);
82 copystat_add_opt_costs(costs_ilp);
83 DBG((dbg, LEVEL_1, "Opt costs: %3d\n", costs_ilp));
86 assert(lower_bound <= costs_ilp);
87 assert(costs_ilp <= costs_heur);