X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbecopyilp.c;h=d7cf202c4fece77b0a39462f79dd3e18c81e3002;hb=31a94f37b692bfab97bebf48ba6d667c16956835;hp=646b6c98d1576952acc419c1237a078f56a3a58a;hpb=b6de8e65b56fb153061505d65d10548f40daf8f5;p=libfirm diff --git a/ir/be/becopyilp.c b/ir/be/becopyilp.c index 646b6c98d..d7cf202c4 100644 --- a/ir/be/becopyilp.c +++ b/ir/be/becopyilp.c @@ -165,28 +165,57 @@ void sr_remove(size_red_t *sr) void sr_reinsert(size_red_t *sr) { coloring_suffix_t *cs; + ir_graph *irg = sr->co->irg; be_ifg_t *ifg = sr->co->cenv->ifg; - bitset_t *used_cols = bitset_alloca(arch_register_class_n_regs(sr->co->cls)); + unsigned n_regs = arch_register_class_n_regs(sr->co->cls); + unsigned *possible_cols; + unsigned *allocatable_cols; + + rbitset_alloca(allocatable_cols, n_regs); + be_set_allocatable_regs(irg, sr->co->cls, allocatable_cols); + + rbitset_alloca(possible_cols, n_regs); neighbours_iter_t iter; /* color the removed nodes in right order */ for (cs = sr->col_suff; cs; cs = cs->next) { - int free_col; - ir_node *other, *irn; + unsigned free_col; + ir_node *other; + ir_node *irn = cs->irn; - /* get free color by inspecting all neighbors */ - irn = cs->irn; - bitset_clear_all(used_cols); + rbitset_copy(possible_cols, allocatable_cols, n_regs); + /* get free color by inspecting all neighbors */ be_ifg_foreach_neighbour(ifg, &iter, irn, other) { - if (!sr_is_removed(sr, other)) /* only inspect nodes which are in graph right now */ - bitset_set(used_cols, get_irn_col(other)); + const arch_register_req_t *cur_req; + unsigned cur_col; + + /* only inspect nodes which are in graph right now */ + if (sr_is_removed(sr, other)) + continue; + + cur_req = arch_get_irn_register_req(other); + cur_col = get_irn_col(other); + + /* Invalidate all single size register when it is a large one */ + do { + rbitset_clear(possible_cols, cur_col); + ++cur_col; + } while ((cur_col % cur_req->width) != 0); } /* now all bits not set are possible colors */ - free_col = bitset_next_clear(used_cols, 0); - assert(free_col != -1 && "No free color found. This can not be."); - set_irn_col(sr->co, irn, free_col); + /* take one that matches the alignment constraint */ + free_col = 0; + assert(!rbitset_is_empty(possible_cols, n_regs) && "No free color found. This can not be."); + while (true) { + free_col = (unsigned)rbitset_next(possible_cols, free_col, true); + if (free_col % arch_get_irn_register_req(irn)->width == 0) + break; + ++free_col; + assert(free_col < n_regs); + } + set_irn_col(sr->co->cls, irn, free_col); pset_remove_ptr(sr->all_removed, irn); /* irn is back in graph again */ } } @@ -225,8 +254,7 @@ ilp_env_t *new_ilp_env(copy_opt_t *co, ilp_callback build, ilp_callback apply, v lpp_sol_state_t ilp_go(ilp_env_t *ienv) { - ir_graph *irg = ienv->co->irg; - be_options_t *options = be_get_irg_options(irg); + ir_graph *irg = ienv->co->irg; sr_remove(ienv->sr); @@ -250,7 +278,7 @@ lpp_sol_state_t ilp_go(ilp_env_t *ienv) if (solve_log) lpp_set_log(ienv->lp, stdout); - lpp_solve(ienv->lp, options->ilp_server, options->ilp_solver); + lpp_solve(ienv->lp, be_options.ilp_server, be_options.ilp_solver); //be_stat_ev_dbl("co_ilp_objval", ienv->lp->objval); //be_stat_ev_dbl("co_ilp_best_bound", ienv->lp->best_bound);