X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbelive.c;h=3129520630fcc8719015320490d2b36ffd8b0ea2;hb=485c69395f430b4ccc7118d69f52d914ad2124d8;hp=e2719c0a683105e5f1e347c8aeceb8a46d4ac9fb;hpb=b482d88d58ce6517bbb6597aa04ffa86ade5f2c9;p=libfirm diff --git a/ir/be/belive.c b/ir/be/belive.c index e2719c0a6..312952063 100644 --- a/ir/be/belive.c +++ b/ir/be/belive.c @@ -122,7 +122,7 @@ be_lv_info_node_t *be_lv_get(const be_lv_t *li, const ir_node *bl, be_lv_info_node_t *res = NULL; stat_ev_tim_push(); - irn_live = (be_lv_info_t*)ir_nodehashmap_get(&li->map, bl); + irn_live = ir_nodehashmap_get(be_lv_info_t, &li->map, bl); if (irn_live != NULL) { unsigned idx = get_irn_idx(irn); @@ -144,7 +144,7 @@ be_lv_info_node_t *be_lv_get(const be_lv_t *li, const ir_node *bl, static be_lv_info_node_t *be_lv_get_or_set(be_lv_t *li, ir_node *bl, ir_node *irn) { - be_lv_info_t *irn_live = (be_lv_info_t*)ir_nodehashmap_get(&li->map, bl); + be_lv_info_t *irn_live = ir_nodehashmap_get(be_lv_info_t, &li->map, bl); if (irn_live == NULL) { irn_live = OALLOCNZ(&li->obst, be_lv_info_t, LV_STD_SIZE); irn_live[0].head.n_size = LV_STD_SIZE-1; @@ -203,7 +203,7 @@ static be_lv_info_node_t *be_lv_get_or_set(be_lv_t *li, ir_node *bl, static int be_lv_remove(be_lv_t *li, const ir_node *bl, const ir_node *irn) { - be_lv_info_t *irn_live = (be_lv_info_t*)ir_nodehashmap_get(&li->map, bl); + be_lv_info_t *irn_live = ir_nodehashmap_get(be_lv_info_t, &li->map, bl); if (irn_live != NULL) { unsigned n = irn_live[0].head.n_members; @@ -231,19 +231,6 @@ static int be_lv_remove(be_lv_t *li, const ir_node *bl, return 0; } -static void register_node(be_lv_t *lv, const ir_node *irn) -{ - unsigned idx = get_irn_idx(irn); - if (idx >= bitset_size(lv->nodes)) { - bitset_t *nw = bitset_malloc(2 * idx); - bitset_copy_into(nw, lv->nodes); - bitset_free(lv->nodes); - lv->nodes = nw; - } - - bitset_set(lv->nodes, idx); -} - /** * Mark a node as live-in in a block. */ @@ -252,7 +239,6 @@ static inline void mark_live_in(be_lv_t *lv, ir_node *block, ir_node *irn) be_lv_info_node_t *n = be_lv_get_or_set(lv, block, irn); DBG((dbg, LEVEL_2, "marking %+F live in at %+F\n", irn, block)); n->flags |= be_lv_state_in; - register_node(lv, irn); } /** @@ -263,7 +249,6 @@ static inline void mark_live_out(be_lv_t *lv, ir_node *block, ir_node *irn) be_lv_info_node_t *n = be_lv_get_or_set(lv, block, irn); DBG((dbg, LEVEL_2, "marking %+F live out at %+F\n", irn, block)); n->flags |= be_lv_state_out | be_lv_state_end; - register_node(lv, irn); } /** @@ -274,7 +259,6 @@ static inline void mark_live_end(be_lv_t *lv, ir_node *block, ir_node *irn) be_lv_info_node_t *n = be_lv_get_or_set(lv, block, irn); DBG((dbg, LEVEL_2, "marking %+F live end at %+F\n", irn, block)); n->flags |= be_lv_state_end; - register_node(lv, irn); } static struct { @@ -334,7 +318,6 @@ typedef struct lv_remove_walker_t { */ static void liveness_for_node(ir_node *irn) { - const ir_edge_t *edge; ir_node *def_block; bitset_clear_all(re.visited); @@ -410,19 +393,11 @@ void be_liveness_compute_sets(be_lv_t *lv) ir_node **nodes; int i; int n; - unsigned last_idx; if (lv->sets_valid) return; be_timer_push(T_LIVE); - last_idx = get_irg_last_idx(lv->irg); - if (last_idx >= bitset_size(lv->nodes)) { - bitset_free(lv->nodes); - lv->nodes = bitset_malloc(last_idx * 2); - } else { - bitset_clear_all(lv->nodes); - } ir_nodehashmap_init(&lv->map); obstack_init(&lv->obst); @@ -486,7 +461,6 @@ be_lv_t *be_liveness_new(ir_graph *irg) lv->irg = irg; lv->hook_info.context = lv; lv->hook_info.hook._hook_node_info = be_dump_liveness_block; - lv->nodes = bitset_malloc(2 * get_irg_last_idx(lv->irg)); return lv; } @@ -496,14 +470,12 @@ void be_liveness_free(be_lv_t *lv) be_liveness_invalidate_sets(lv); be_liveness_invalidate_chk(lv); - bitset_free(lv->nodes); xfree(lv); } void be_liveness_remove(be_lv_t *lv, const ir_node *irn) { if (lv->sets_valid) { - unsigned idx = get_irn_idx(irn); lv_remove_walker_t w; /* @@ -514,8 +486,6 @@ void be_liveness_remove(be_lv_t *lv, const ir_node *irn) w.lv = lv; w.irn = irn; dom_tree_walk(get_nodes_block(irn), lv_remove_irn_walker, NULL, &w); - if (idx < bitset_size(lv->nodes)) - bitset_clear(lv->nodes, idx); } } @@ -546,8 +516,6 @@ void be_liveness_transfer(const arch_register_class_t *cls, assert(!is_Phi(node) && "liveness_transfer produces invalid results for phi nodes"); if (get_irn_mode(node) == mode_T) { - const ir_edge_t *edge; - foreach_out_edge(node, edge) { ir_node *proj = get_edge_src_irn(edge); @@ -574,11 +542,8 @@ void be_liveness_end_of_block(const be_lv_t *lv, const arch_register_class_t *cls, const ir_node *block, ir_nodeset_t *live) { - int i; - - assert(lv->nodes && "live sets must be computed"); - be_lv_foreach(lv, block, be_lv_state_end, i) { - ir_node *node = be_lv_get_irn(lv, block, i); + assert(lv->sets_valid && "live sets must be computed"); + be_lv_foreach(lv, block, be_lv_state_end, node) { if (!arch_irn_consider_in_reg_alloc(cls, node)) continue; @@ -593,7 +558,6 @@ void be_liveness_nodes_live_at(const be_lv_t *lv, const ir_node *pos, ir_nodeset_t *live) { const ir_node *bl = is_Block(pos) ? pos : get_nodes_block(pos); - ir_node *irn; be_liveness_end_of_block(lv, cls, bl, live); sched_foreach_reverse(bl, irn) {