X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbecopyheur.c;h=5e8805ff78d2a20e8f087b24a3b8f7038cce40ba;hb=2814a774ee584b3c19ff3c87b3775ff46859b21e;hp=58158c17a1099a7cb4a37c9f619b5200f20f74f0;hpb=429d687f06baeeb63d04750f846d39e55fb62343;p=libfirm diff --git a/ir/be/becopyheur.c b/ir/be/becopyheur.c index 58158c17a..5e8805ff7 100644 --- a/ir/be/becopyheur.c +++ b/ir/be/becopyheur.c @@ -42,7 +42,8 @@ #include "becopyopt_t.h" #include "becopystat.h" #include "beintlive_t.h" -#include "beirg_t.h" +#include "beirg.h" +#include "bemodule.h" DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;) @@ -93,7 +94,7 @@ static inline int nodes_interfere(const be_chordal_env_t *env, const ir_node *a, if (env->ifg) return be_ifg_connected(env->ifg, a, b); else - return values_interfere(env->birg, a, b); + return be_values_interfere(env->birg->lv, a, b); } static int set_cmp_conflict_t(const void *x, const void *y, size_t size) { @@ -384,7 +385,7 @@ static inline void qnode_max_ind_set(qnode_t *qn, const unit_t *ou) { int i, o, safe_count, safe_costs, unsafe_count, *unsafe_costs; bitset_t *curr, *best; bitset_pos_t pos; - int max, next, curr_weight, best_weight = 0; + int next, curr_weight, best_weight = 0; /* assign the nodes into two groups. * safe: node has no interference, hence it is in every max stable set. @@ -438,7 +439,7 @@ static inline void qnode_max_ind_set(qnode_t *qn, const unit_t *ou) { /* Exact Algorithm: Brute force */ curr = bitset_alloca(unsafe_count); bitset_set_all(curr); - while ((max = bitset_popcnt(curr)) != 0) { + while (!bitset_is_empty(curr)) { /* check if curr is a stable set */ for (i=bitset_next_set(curr, 0); i!=-1; i=bitset_next_set(curr, i+1)) for (o=bitset_next_set(curr, i); o!=-1; o=bitset_next_set(curr, o+1)) /* !!!!! difference to ou_max_ind_set_costs(): NOT (curr, i+1) */ @@ -616,9 +617,12 @@ static void ou_optimize(unit_t *ou) { free_qnode(curr); } +/** + * Solves the problem using a heuristic approach + * Uses the OU data structure + */ int co_solve_heuristic(copy_opt_t *co) { unit_t *curr; - FIRM_DBG_REGISTER(dbg, "ir.be.copyoptheur"); ASSERT_OU_AVAIL(co); @@ -630,3 +634,15 @@ int co_solve_heuristic(copy_opt_t *co) { del_pset(pinned_global); return 0; } + +void be_init_copyheur(void) +{ + static co_algo_info copyheur = { + co_solve_heuristic, 0 + }; + + be_register_copyopt("heur1", ©heur); + FIRM_DBG_REGISTER(dbg, "ir.be.copyoptheur"); +} + +BE_REGISTER_MODULE_CONSTRUCTOR(be_init_copyheur);