X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbecopyheur2.c;h=489a915101129701f502591be2db3268f90efe2f;hb=4ed245f5007168dab7850942a7ee6b6b29a19817;hp=e7fbd6327816fade23ee505add7966a1b712fc32;hpb=d1761f5ecefabce588a7db95e8e8f8ce76498480;p=libfirm diff --git a/ir/be/becopyheur2.c b/ir/be/becopyheur2.c index e7fbd6327..489a91510 100644 --- a/ir/be/becopyheur2.c +++ b/ir/be/becopyheur2.c @@ -43,15 +43,16 @@ static int dump_flags = 0; static int subtree_iter = 4; -static double constr_factor = 0.5; +static int max_depth = 20; +static double constr_factor = 0.9; /* Options using libcore */ #ifdef WITH_LIBCORE static const lc_opt_enum_mask_items_t dump_items[] = { { "before", DUMP_BEFORE }, - { "after", DUMP_AFTER }, - { "cloud", DUMP_CLOUD }, + { "after", DUMP_AFTER }, + { "cloud", DUMP_CLOUD }, { "all", DUMP_ALL }, { NULL, 0 } }; @@ -64,6 +65,7 @@ static const lc_opt_table_entry_t options[] = { LC_OPT_ENT_ENUM_MASK("dump", "dump ifg before, after or after each cloud", &dump_var), LC_OPT_ENT_INT ("iter", "iterations for subtree nodes (standard: 3)", &subtree_iter), LC_OPT_ENT_DBL ("cf", "factor of constraint importance (between 0.0 and 1.0)", &constr_factor), + LC_OPT_ENT_INT ("max", "maximum recursion depth (default 20)", &max_depth), { NULL } }; @@ -198,8 +200,8 @@ static void *co2_irn_init(phase_t *ph, ir_node *irn, void *data) static int cmp_clouds_gt(const void *a, const void *b) { - const co2_cloud_t **p = a; - const co2_cloud_t **q = b; + const co2_cloud_t * const *p = a; + const co2_cloud_t * const *q = b; double c = CLOUD_WEIGHT(*p); double d = CLOUD_WEIGHT(*q); return QSORT_CMP(d, c); @@ -401,10 +403,12 @@ static int recolor(co2_t *env, ir_node *irn, col_cost_pair_t *col_list, struct l be_ifg_t *ifg = env->co->cenv->ifg; co2_irn_t *ci = get_co2_irn(env, irn); int res = 0; - int n_aff = 0; int i; + if(depth >= max_depth) + return 0; + for(i = 0; i < n_regs; ++i) { col_t tgt_col = col_list[i].col; unsigned costs = col_list[i].costs; @@ -698,7 +702,6 @@ static int coalesce_top_down(co2_cloud_irn_t *ci, int child_nr, int depth) INIT_LIST_HEAD(&changed); for(i = 0; i < (best_col < 0 ? n_regs : n_iter); ++i) { col_t col = seq[i].col; - int costs = seq[i].costs; int add_cost = !is_root && col != parent_col ? ci->mst_costs : 0; int subtree_costs, sum_costs; @@ -838,7 +841,7 @@ static void apply_coloring(co2_cloud_irn_t *ci, col_t col, int depth) DBG((ci->cloud->env->dbg, LEVEL_2, "%2{firm:indent}setting %+F to %d\n", depth, irn, col)); ok = change_color_single(ci->cloud->env, irn, col, &changed, depth); - assert(ok && "Color changing may not fail while committing the coloring"); + // assert(ok && "Color changing may not fail while committing the coloring"); materialize_coloring(&changed); for(i = 0; i < ci->mst_n_childs; ++i) { @@ -862,7 +865,6 @@ static void process_cloud(co2_cloud_t *cloud) int *mst_edges = xmalloc(cloud->n_memb * cloud->n_memb * sizeof(mst_edges[0])); pdeq *q; - struct list_head changed; edge_t *edges; int i; int best_col; @@ -1051,7 +1053,8 @@ static void process(co2_t *env) FILE *f; ir_snprintf(buf, sizeof(buf), "ifg_%F_%s_cloud_%d.dot", env->co->irg, env->co->cls->name, i); - if(f = fopen(buf, "wt")) { + f = fopen(buf, "wt"); + if(f != NULL) { be_ifg_dump_dot(env->co->cenv->ifg, env->co->irg, f, &ifg_dot_cb, env); fclose(f); } @@ -1165,7 +1168,7 @@ static void ifg_dump_node_attr(FILE *f, void *self, ir_node *irn) peri = 2; if(cci->cloud && cci->cloud->mst_root) - snprintf(buf, sizeof(buf), "%+F", cci->cloud->mst_root->inh.irn); + ir_snprintf(buf, sizeof(buf), "%+F", cci->cloud->mst_root->inh.irn); } ir_fprintf(f, "label=\"%+F%s\" style=filled peripheries=%d color=%s shape=%s", irn, buf, peri, @@ -1215,7 +1218,7 @@ static be_ifg_dump_dot_cb_t ifg_dot_cb = { }; -void co_solve_heuristic_new(copy_opt_t *co) +int co_solve_heuristic_new(copy_opt_t *co) { char buf[256]; co2_t env; @@ -1235,7 +1238,8 @@ void co_solve_heuristic_new(copy_opt_t *co) if(dump_flags & DUMP_BEFORE) { ir_snprintf(buf, sizeof(buf), "ifg_%F_%s_before.dot", co->irg, co->cls->name); - if(f = fopen(buf, "wt")) { + f = fopen(buf, "wt"); + if (f != NULL) { be_ifg_dump_dot(co->cenv->ifg, co->irg, f, &ifg_dot_cb, &env); fclose(f); } @@ -1245,7 +1249,8 @@ void co_solve_heuristic_new(copy_opt_t *co) if(dump_flags & DUMP_AFTER) { ir_snprintf(buf, sizeof(buf), "ifg_%F_%s_after.dot", co->irg, co->cls->name); - if(f = fopen(buf, "wt")) { + f = fopen(buf, "wt"); + if (f != NULL) { be_ifg_dump_dot(co->cenv->ifg, co->irg, f, &ifg_dot_cb, &env); fclose(f); } @@ -1253,4 +1258,5 @@ void co_solve_heuristic_new(copy_opt_t *co) writeback_colors(&env); phase_free(&env.ph); + return 0; }