X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbecopyilp.c;h=48077b412afa92c0446f90793094e580767d39f3;hb=b0b017615d99df915f731aa23842e26a10691f05;hp=646b6c98d1576952acc419c1237a078f56a3a58a;hpb=b6de8e65b56fb153061505d65d10548f40daf8f5;p=libfirm diff --git a/ir/be/becopyilp.c b/ir/be/becopyilp.c index 646b6c98d..48077b412 100644 --- a/ir/be/becopyilp.c +++ b/ir/be/becopyilp.c @@ -1,20 +1,6 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. - * * This file is part of libFirm. - * - * This file may be distributed and/or modified under the terms of the - * GNU General Public License version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * Licensees holding valid libFirm Professional Edition licenses may use - * this file in accordance with the libFirm Commercial License. - * Agreement provided with the Software. - * - * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. + * Copyright (C) 2012 University of Karlsruhe. */ /** @@ -27,11 +13,11 @@ #include +#include "be_t.h" #include "irtools.h" #include "irprintf.h" -#include "bestatevent.h" -#include "beirg.h" +#include "statev_t.h" #include "bemodule.h" #include "error.h" @@ -110,7 +96,6 @@ static inline bool sr_is_simplicial(size_red_t *sr, const ir_node *ifn) be_ifg_t *ifg = sr->co->cenv->ifg; neighbours_iter_t iter; ir_node **all = ALLOCAN(ir_node*, be_ifg_degree(ifg, ifn)); - ir_node *curr; int size = 0; int i; int o; @@ -132,7 +117,6 @@ static inline bool sr_is_simplicial(size_red_t *sr, const ir_node *ifn) void sr_remove(size_red_t *sr) { - ir_node *irn; bool redo = true; const be_ifg_t *ifg = sr->co->cenv->ifg; nodes_iter_t iter; @@ -165,28 +149,54 @@ 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 *const allocatable_cols = rbitset_alloca(n_regs); + be_set_allocatable_regs(irg, sr->co->cls, allocatable_cols); + + unsigned *const possible_cols = rbitset_alloca(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 *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 +235,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,12 +259,12 @@ 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); - be_stat_ev ("co_ilp_iter", lpp_get_iter_cnt(ienv->lp)); - be_stat_ev_dbl("co_ilp_sol_time", lpp_get_sol_time(ienv->lp)); + //stat_ev_dbl("co_ilp_objval", ienv->lp->objval); + //stat_ev_dbl("co_ilp_best_bound", ienv->lp->best_bound); + stat_ev_int("co_ilp_iter", lpp_get_iter_cnt(ienv->lp)); + stat_ev_dbl("co_ilp_sol_time", lpp_get_sol_time(ienv->lp)); ienv->apply(ienv);