From dc2df8d109c0d6f2d9b0810aba2327497f543973 Mon Sep 17 00:00:00 2001 From: Johannes Spallek Date: Mon, 26 Jun 2006 13:43:29 +0000 Subject: [PATCH] Moved the bitsets to the iterator-structs to allow nested iterations about all neighbours. --- ir/be/beifg_pointer.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ir/be/beifg_pointer.c b/ir/be/beifg_pointer.c index cc709a13f..c1b06e376 100644 --- a/ir/be/beifg_pointer.c +++ b/ir/be/beifg_pointer.c @@ -54,7 +54,6 @@ typedef struct _ifg_pointer_t { ptr_head_t *curr_ptr_head; ptr_element_t *curr_element; pmap *node_map; - bitset_t *visited_neighbours; } ifg_pointer_t; typedef struct _ptr_iter_t { @@ -66,6 +65,7 @@ typedef struct _ptr_iter_t { ir_node *curr_irn; int get_first; int sub_call; + bitset_t *visited_neighbours; } ptr_iter_t; /* PRIVATE FUNCTIONS */ @@ -474,13 +474,13 @@ static ir_node *get_next_neighbour(ptr_iter_t *it) if (res && !it->sub_call) { - if (bitset_contains_irn(it->ifg->visited_neighbours, res) || res == it->irn) + if (bitset_contains_irn(it->visited_neighbours, res) || res == it->irn) { res = get_next_neighbour(it); } else { - bitset_set(it->ifg->visited_neighbours, get_irn_idx(res)); + bitset_set(it->visited_neighbours, get_irn_idx(res)); } } @@ -492,12 +492,14 @@ static ir_node *get_first_neighbour(const ifg_pointer_t *ifg, ptr_iter_t *it, co ir_node *res; ptr_head_t *head; ptr_element_t *element; + bitset_t *bitsetvisited_neighbours = bitset_malloc(get_irg_last_idx(ifg->env->irg)); it->ifg = ifg; it->irn = irn; it->get_first = 0; it->sub_call = 0; - bitset_clear_all(it->ifg->visited_neighbours); + + it->visited_neighbours = bitsetvisited_neighbours; head = phase_get_irn_data(&ifg->ph, irn); if (!head) @@ -569,13 +571,13 @@ static ir_node *get_first_neighbour(const ifg_pointer_t *ifg, ptr_iter_t *it, co if (res && !it->sub_call) { - if (bitset_contains_irn(it->ifg->visited_neighbours, res) || res == it->irn) + if (bitset_contains_irn(it->visited_neighbours, res) || res == it->irn) { res = get_next_neighbour(it); } else { - bitset_set(it->ifg->visited_neighbours, get_irn_idx(res)); + bitset_set(it->visited_neighbours, get_irn_idx(res)); } } @@ -592,8 +594,6 @@ static void ifg_pointer_free(void *self) obstack_free(&ifg->obst, NULL); phase_free(&ifg->ph); - bitset_free(ifg->visited_neighbours); - free(self); } @@ -630,6 +630,10 @@ static ir_node *ifg_pointer_neighbours_next(const void *self, void *iter) static void ifg_pointer_neighbours_break(const void *self, void *iter) { + ptr_iter_t *it = iter; + + bitset_free(it->visited_neighbours); + return; } @@ -685,10 +689,8 @@ static const be_ifg_impl_t ifg_pointer_impl = { be_ifg_t *be_ifg_pointer_new(const be_chordal_env_t *env) { ifg_pointer_t *ifg = xmalloc(sizeof(*ifg)); - bitset_t *bitsetvisited_neighbours = bitset_malloc(get_irg_last_idx(env->irg)); ifg->impl = &ifg_pointer_impl; ifg->env = env; - ifg->visited_neighbours = bitsetvisited_neighbours; ifg->node_map = pmap_create(); /* to find all nodes, should be replaced by a "keywalker" of irphase */ -- 2.20.1