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"
26 #define DEBUG_LVL SET_LEVEL_1
27 static firm_dbg_module_t *dbg = NULL;
29 void be_copy_opt_init(void) {
30 dbg = firm_dbg_register("ir.be.copyoptmain");
31 firm_dbg_set_mask(dbg, DEBUG_LVL);
34 void be_copy_opt(be_chordal_env_t *chordal_env) {
36 int costs, costs_init=-1, costs_heur=-1, costs_ilp=-1;
39 /* BETTER: You can remove this if you replace all
40 * `grep get_irn_out *.c` by the irouts.h module.*/
41 compute_outs(chordal_env->session_env->irg);
43 co = new_copy_opt(chordal_env, get_costs_all_one);
44 DBG((dbg, LEVEL_1, "----> CO: %s\n", co->name));
48 lower_bound = co_get_lower_bound(co);
49 DBG((dbg, LEVEL_1, "Lower Bound: %3d\n", lower_bound));
50 costs = co_get_copy_costs(co);
52 copystat_add_max_costs(co_get_max_copy_costs(co));
53 copystat_add_inevit_costs(co_get_inevit_copy_costs(co));
54 copystat_add_init_costs(costs_init);
55 DBG((dbg, LEVEL_1, "Init costs: %3d\n", costs_init));
59 lc_timer_t *timer = lc_timer_register("heur", NULL);
60 lc_timer_start(timer);
63 copystat_add_heur_time(lc_timer_elapsed_msec(timer));
65 costs = co_get_copy_costs(co);
67 copystat_add_heur_costs(costs_heur);
68 DBG((dbg, LEVEL_1, "Heur costs: %3d\n", costs_heur));
75 costs = co_get_copy_costs(co);
77 copystat_add_opt_costs(costs_ilp);
78 DBG((dbg, LEVEL_1, "Opt costs: %3d\n", costs_ilp));
81 assert(lower_bound <= costs_ilp);
82 assert(costs_ilp <= costs_heur);