X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbecopypbqp.c;h=16a50e61063a9bca5554552a71cfa802b29c0ec8;hb=51d5090095b2f4f2285ff1b7ccd13c72a7b5d9d3;hp=bbca5301b4699abd15918e85906a6368ac00f8d5;hpb=53ed570350c930aa9046f684a9404f3a9c076305;p=libfirm diff --git a/ir/be/becopypbqp.c b/ir/be/becopypbqp.c index bbca5301b..16a50e610 100644 --- a/ir/be/becopypbqp.c +++ b/ir/be/becopypbqp.c @@ -15,7 +15,7 @@ #include "vector.h" #include "matrix.h" #include "html_dumper.h" -#include "heuristical.h" +#include "heuristical_co.h" #include "pbqp_node_t.h" #include "becopyopt_t.h" @@ -62,7 +62,8 @@ static FILE *my_open(const be_chordal_env_t *env, const char *prefix, const char } #endif -static void insert_into_reverse_peo(ir_node *block, void *data) { +static void insert_into_reverse_peo(ir_node *block, void *data) +{ pqueue_t *queue = new_pqueue(); pqueue_t *restrictedNodesQueue = new_pqueue(); pbqp_co_t *pbqp_co = data; @@ -110,13 +111,14 @@ static void insert_into_reverse_peo(ir_node *block, void *data) { del_pqueue(restrictedNodesQueue); } -static int co_solve_heuristic_pbqp(copy_opt_t *co) { +static int co_solve_heuristic_pbqp(copy_opt_t *co) +{ void *nodes_it = be_ifg_nodes_iter_alloca(co->cenv->ifg); void *neigh_it = be_ifg_neighbours_iter_alloca(co->cenv->ifg); unsigned number_registers = co->cls->n_regs; unsigned number_nodes = get_irg_last_idx(co->irg); - ir_timer_t *t_ra_copymin_pbqp_create = ir_timer_register("be_co_pbqp_create", "copy minimization pbqp create"); - ir_timer_t *t_ra_copymin_pbqp_solve = ir_timer_register("be_co_pbqp_solve", "copy minimization pbqp solve"); + ir_timer_t *t_ra_copymin_pbqp_create = ir_timer_new(); + ir_timer_t *t_ra_copymin_pbqp_solve = ir_timer_new(); ir_node *ifg_node; ir_node *if_neighb_node; pbqp_co_t pbqp_co; @@ -186,14 +188,7 @@ static int co_solve_heuristic_pbqp(copy_opt_t *co) { struct pbqp_matrix *ife_matrix = pbqp_matrix_alloc(pbqp_co.pbqp, number_registers, number_registers); /* set costs */ for(row = 0; row < number_registers; row++) { - for(col = 0; col < number_registers; col++) { - if(row == col) { - pbqp_matrix_set(ife_matrix, row, col, INF_COSTS); - } - else { - pbqp_matrix_set(ife_matrix, row, col, 0); - } - } + pbqp_matrix_set(ife_matrix, row, row, INF_COSTS); } /* create costs matrix for affinity edges */ @@ -230,7 +225,7 @@ static int co_solve_heuristic_pbqp(copy_opt_t *co) { if(aff_node != NULL) { co_gs_foreach_neighb(aff_node, aff_neighb_node) { /* ignore Unknowns */ - if(get_node(pbqp_co.pbqp, get_irn_idx(aff_node->irn))->costs != NULL) + if(get_node(pbqp_co.pbqp, get_irn_idx(aff_neighb_node->irn)) == NULL) continue; if(get_edge(pbqp_co.pbqp, get_irn_idx(aff_node->irn), get_irn_idx(aff_neighb_node->irn)) == NULL) { @@ -253,9 +248,8 @@ static int co_solve_heuristic_pbqp(copy_opt_t *co) { #if KAPS_DUMP // dump graph before solving pbqp - FILE *file_before = my_open(co->cenv, "", "-before.html"); - set_dumpfile(pbqp_co.pbqp, file_before); - pbqp_dump_input(pbqp_co.pbqp); + FILE *file = my_open(co->cenv, "", "-pbqp_copymin.html"); + set_dumpfile(pbqp_co.pbqp, file); #endif /* start timer */ @@ -279,20 +273,15 @@ static int co_solve_heuristic_pbqp(copy_opt_t *co) { #endif #if KAPS_TIMING - printf("%-20s: %8.3lf msec\n" , ir_timer_get_description(t_ra_copymin_pbqp_create), (double)ir_timer_elapsed_usec(t_ra_copymin_pbqp_create) / 1000.0); - printf("%-20s: %8.3lf msec\n" , ir_timer_get_description(t_ra_copymin_pbqp_solve), (double)ir_timer_elapsed_usec(t_ra_copymin_pbqp_solve) / 1000.0); + printf("%-20s: %8.3lf msec\n", "copy minimization pbqp create", + (double)ir_timer_elapsed_usec(t_ra_copymin_pbqp_create) / 1000.0); + printf("%-20s: %8.3lf msec\n" , "copy minimization pbqp solve", + (double)ir_timer_elapsed_usec(t_ra_copymin_pbqp_solve) / 1000.0); printf("==>> END PBQP TIMING on IRG %s (%s) <<==\n", get_entity_name(get_irg_entity(co->irg)), arch_register_class_name(co->cls)); #endif assert(solution != INF_COSTS && "No PBQP solution found"); - #if KAPS_DUMP - /* dump graph after solving pbqp */ - FILE *file_after = my_open(co->cenv, "", "-after.html"); - set_dumpfile(pbqp_co.pbqp, file_after); - pbqp_dump_input(pbqp_co.pbqp); - #endif - /* coloring ifg */ be_ifg_foreach_node(co->cenv->ifg, nodes_it, ifg_node) { num index = get_node_solution(pbqp_co.pbqp, get_irn_idx(ifg_node)); @@ -302,8 +291,7 @@ static int co_solve_heuristic_pbqp(copy_opt_t *co) { /* free allocated memory */ #if KAPS_DUMP - fclose(file_before); - fclose(file_after); + fclose(file); #endif bitset_free(pbqp_co.ignore_reg); bitset_free(pbqp_co.restricted_nodes);