X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbecopyheur4.c;h=ad5ca80d0c43f429cfb6c041ab2f3cc0a055aca1;hb=5474a1c188c9d59eea2c915515980cd9cbab58d8;hp=3dbb8a48ad15a8eaff1c16c66ba5ed818c214f5f;hpb=f8dfdaaff8e4f364da8494fd35a9bb2f8c267e7f;p=libfirm diff --git a/ir/be/becopyheur4.c b/ir/be/becopyheur4.c index 3dbb8a48a..ad5ca80d0 100644 --- a/ir/be/becopyheur4.c +++ b/ir/be/becopyheur4.c @@ -22,7 +22,6 @@ * @brief Simple copy minimization heuristics. * @author Christian Wuerdig * @date 27.04.2007 - * @version $Id$ * * This is the C implementation of the mst algorithm * originally written in Java by Sebastian Hack. @@ -44,15 +43,12 @@ #include "xmalloc.h" #include "pdeq.h" #include "irprintf.h" -#include "irbitset.h" #include "util.h" #include "irtools.h" #include "error.h" #include "list.h" #include "statev.h" -#include "irbitset.h" - #include "bearch.h" #include "beifg.h" #include "be_t.h" @@ -773,13 +769,13 @@ static __attribute__((unused)) void chunk_order_nodes(co_mst_env_t *env, aff_chu } if (max_node) { - bitset_t *visited = bitset_irg_malloc(env->co->irg); + bitset_t *visited = bitset_malloc(get_irg_last_idx(env->co->irg)); for (i = ARR_LEN(chunk->n); i != 0;) - bitset_add_irn(visited, chunk->n[--i]); + bitset_set(visited, get_irn_idx(chunk->n[--i])); pqueue_put(grow, (void *) max_node, max_weight); - bitset_remv_irn(visited, max_node); + bitset_clear(visited, get_irn_idx(max_node)); i = 0; while (!pqueue_empty(grow)) { ir_node *irn = (ir_node*)pqueue_pop_front(grow); @@ -798,9 +794,9 @@ static __attribute__((unused)) void chunk_order_nodes(co_mst_env_t *env, aff_chu co_gs_foreach_neighb(an, neigh) { co_mst_irn_t *node = get_co_mst_irn(env, neigh->irn); - if (bitset_contains_irn(visited, node->irn)) { + if (bitset_is_set(visited, get_irn_idx(node->irn))) { pqueue_put(grow, (void *) neigh->irn, neigh->costs); - bitset_remv_irn(visited, node->irn); + bitset_clear(visited, get_irn_idx(node->irn)); } } } @@ -878,7 +874,7 @@ static void expand_chunk_from(co_mst_env_t *env, co_mst_irn_t *node, bitset_t *v */ static aff_chunk_t *fragment_chunk(co_mst_env_t *env, int col, aff_chunk_t *c, waitq *tmp) { - bitset_t *visited = bitset_irg_malloc(env->co->irg); + bitset_t *visited = bitset_malloc(get_irg_last_idx(env->co->irg)); int idx, len; aff_chunk_t *best = NULL; @@ -1247,7 +1243,7 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) */ for (i = 0; i < env->k; ++i) { int col = order[i].col; - waitq *good_starts = new_waitq(); + waitq *good_starts; aff_chunk_t *local_best; int n_succeeded; @@ -1258,6 +1254,7 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) DB((dbg, LEVEL_2, "\ttrying color %d\n", col)); n_succeeded = 0; + good_starts = new_waitq(); /* try to bring all nodes of given chunk to the current color. */ for (idx = 0, len = ARR_LEN(c->n); idx < len; ++idx) { @@ -1296,8 +1293,10 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) } /* try next color when failed */ - if (n_succeeded == 0) + if (n_succeeded == 0) { + del_waitq(good_starts); continue; + } /* fragment the chunk according to the coloring */ local_best = fragment_chunk(env, col, c, tmp_chunks); @@ -1398,7 +1397,7 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) } /* fragment the remaining chunk */ - visited = bitset_irg_malloc(env->co->irg); + visited = bitset_malloc(get_irg_last_idx(env->co->irg)); for (idx = 0, len = ARR_LEN(best_chunk->n); idx < len; ++idx) bitset_set(visited, get_irn_idx(best_chunk->n[idx]));