#include "becopyopt_t.h"
#include "becopystat.h"
#include "beirg_t.h"
+#include "bemodule.h"
#define DEBUG_LVL SET_LEVEL_1
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
static pset *all_copy_nodes;
static ir_graph *last_irg;
-void copystat_init(void) {
+void be_init_copystat(void) {
FIRM_DBG_REGISTER(dbg, "firm.be.copystat");
all_phi_nodes = pset_new_ptr_default();
all_phi_classes = pset_new_ptr_default();
all_copy_nodes = pset_new_ptr_default();
+ memset(curr_vals, 0, sizeof(curr_vals));
}
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_copystat);
-void copystat_reset(void) {
- int i;
- for (i = 0; i < ASIZE; ++i)
- curr_vals[i] = 0;
+void be_quit_copystat(void) {
del_pset(all_phi_nodes);
del_pset(all_phi_classes);
del_pset(all_copy_nodes);
- all_phi_nodes = pset_new_ptr_default();
- all_phi_classes = pset_new_ptr_default();
- all_copy_nodes = pset_new_ptr_default();
+}
+BE_REGISTER_MODULE_DESTRUCTOR(be_quit_copystat);
+
+void copystat_reset(void) {
+ be_quit_copystat();
+ be_init_copystat();
}
/**
* Collect register-constrained node data
*/
static void stat_copy_node(be_chordal_env_t *chordal_env, ir_node *root) {
+ be_lv_t *lv = be_get_birg_liveness(chordal_env->birg);
curr_vals[I_CPY_CNT]++;
curr_vals[I_COPIES_MAX]++;
- if (nodes_interfere(chordal_env, root, get_Perm_src(root))) {
+ if (values_interfere(lv, root, get_Perm_src(root))) {
curr_vals[I_COPIES_IF]++;
assert(0 && "A Perm pair (in/out) should never interfere!");
}
static void stat_phi_class(be_chordal_env_t *chordal_env, pset *pc) {
int i, o, size, if_free, phis;
ir_node **members, *p;
+ be_lv_t *lv = be_get_birg_liveness(chordal_env->birg);
/* phi class count */
curr_vals[I_CLS_CNT]++;
if_free = 1;
for (i = 0; i < size-1; ++i)
for (o = i+1; o < size; ++o)
- if (nodes_interfere(chordal_env, members[i], members[o])) {
+ if (values_interfere(lv, members[i], members[o])) {
if_free = 0;
curr_vals[I_CLS_IF_CNT]++;
}
irg_walk_graph(color_saver->chordal_env->irg, save_load, NULL, color_saver);
}
+#ifdef WITH_ILP
static void load_colors(color_save_t *color_saver) {
color_saver->flag = 1;
irg_walk_graph(color_saver->chordal_env->irg, save_load, NULL, color_saver);
}
+#endif
/**
* Main compare routine
saver.chordal_env = chordal_env;
saver.saved_colors = pmap_create();
save_colors(&saver);
- be_ra_chordal_check(co->cenv);
/* initial values */
costs_inevit = co_get_inevit_copy_costs(co);
lc_timer_stop(timer);
- be_ra_chordal_check(co->cenv);
costs_solved = co_get_copy_costs(co);
DBG((dbg, LEVEL_1, "HEUR1 costs: %3d\n", costs_solved));
copystat_add_heur_time(lc_timer_elapsed_msec(timer));
lc_timer_stop(timer);
- be_ra_chordal_check(co->cenv);
costs_solved = co_get_copy_costs(co);
DBG((dbg, LEVEL_1, "HEUR2 costs: %3d\n", costs_solved));
copystat_add_heur_time(lc_timer_elapsed_msec(timer));
lc_timer_stop(timer);
- be_ra_chordal_check(co->cenv);
costs_solved = co_get_copy_costs(co);
DBG((dbg, LEVEL_1, "Park/Moon costs: %3d\n", costs_solved));
copystat_add_heur_time(lc_timer_elapsed_msec(timer));
co_solve_ilp2(co);
- be_ra_chordal_check(co->cenv);
costs_solved = co_get_copy_costs(co);
DBG((dbg, LEVEL_1, "ILP2 costs: %3d\n", costs_solved));
copystat_add_opt_costs(costs_solved); /* TODO: ADAPT */