X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbecopystat.c;h=6a9c602d0e31413452d0c516ad8dd85315092f9e;hb=d14c6378674f36728eacaf5dc7e4bb045ff9fbab;hp=425714bb1e3bca55a8474f355ae5917cd52d8277;hpb=5776909de54f878d723524d03d072ca8a1e50ab6;p=libfirm diff --git a/ir/be/becopystat.c b/ir/be/becopystat.c index 425714bb1..6a9c602d0 100644 --- a/ir/be/becopystat.c +++ b/ir/be/becopystat.c @@ -21,6 +21,8 @@ #include "beutil.h" #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;) @@ -93,24 +95,26 @@ static pset *all_phi_classes; 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(); } /** @@ -216,9 +220,10 @@ static void stat_phi_node(be_chordal_env_t *chordal_env, ir_node *phi) { * 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!"); } @@ -230,6 +235,7 @@ static void stat_copy_node(be_chordal_env_t *chordal_env, ir_node *root) { 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]++; @@ -265,7 +271,7 @@ static void stat_phi_class(be_chordal_env_t *chordal_env, pset *pc) { 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]++; } @@ -444,10 +450,12 @@ static void save_colors(color_save_t *color_saver) { 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 @@ -471,7 +479,6 @@ void co_compare_solvers(be_chordal_env_t *chordal_env) { 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); @@ -486,16 +493,14 @@ void co_compare_solvers(be_chordal_env_t *chordal_env) { copystat_add_init_costs(costs_init); copystat_add_max_costs(co_get_max_copy_costs(co)); - /* heuristic 1 (Daniel Grund) */ timer = lc_timer_register("heur1", NULL); lc_timer_reset_and_start(timer); - co_solve_heuristic_new(co); + co_solve_heuristic(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)); @@ -510,13 +515,26 @@ void co_compare_solvers(be_chordal_env_t *chordal_env) { 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)); copystat_add_heur_costs(costs_solved); assert(lower_bound <= costs_solved); + /* Park & Moon register coalescing (Kimon Hoffmann) */ + timer = lc_timer_register("park", NULL); + lc_timer_reset_and_start(timer); + + co_solve_park_moon(co); + + lc_timer_stop(timer); + + 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)); + copystat_add_heur_costs(costs_solved); + assert(lower_bound <= costs_solved); + #ifdef WITH_ILP @@ -535,9 +553,8 @@ void co_compare_solvers(be_chordal_env_t *chordal_env) { /* ILP 2 */ load_colors(&saver); - co_solve_ilp2(co, 60.0); + 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 */