backend: put ignore regs into beirg
[libfirm] / ir / ir / iredges.c
index 9a345e7..583169b 100644 (file)
@@ -273,6 +273,7 @@ static inline void edge_change_cnt(ir_node *tgt, ir_edge_kind_t kind, int ofs)
        info->out_count += ofs;
 
 #if 0
+       ir_graph *irg = get_irn_irg(tgt);
        assert(info->out_count >= 0);
        if (info->out_count == 0 && kind == EDGE_KIND_NORMAL) {
                /* tgt lost it's last user */
@@ -281,12 +282,12 @@ static inline void edge_change_cnt(ir_node *tgt, ir_edge_kind_t kind, int ofs)
                for (i = get_irn_arity(tgt) - 1; i >= -1; --i) {
                        ir_node *prev = get_irn_n(tgt, i);
 
-                       edges_notify_edge(tgt, i, NULL, prev, current_ir_graph);
+                       edges_notify_edge(tgt, i, NULL, prev, irg);
                }
                for (i = get_irn_deps(tgt) - 1; i >= 0; --i) {
                        ir_node *prev = get_irn_dep(tgt, i);
 
-                       edges_notify_edge_kind(tgt, i, NULL, prev, EDGE_KIND_DEP, current_ir_graph);
+                       edges_notify_edge_kind(tgt, i, NULL, prev, EDGE_KIND_DEP, irg);
 
                }
        }
@@ -297,7 +298,7 @@ static inline void edge_change_cnt(ir_node *tgt, ir_edge_kind_t kind, int ofs)
  * Verify the edge list of a node, ie. ensure it's a loop:
  * head -> e_1 -> ... -> e_n -> head
  */
-static inline void vrfy_list_head(ir_node *irn, ir_edge_kind_t kind)
+static inline void verify_list_head(ir_node *irn, ir_edge_kind_t kind)
 {
        int                    err       = 0;
        int                    num       = 0;
@@ -455,9 +456,9 @@ void edges_notify_edge_kind(ir_node *src, int pos, ir_node *tgt,
        /* verify list heads */
        if (edges_dbg) {
                if (tgt)
-                       vrfy_list_head(tgt, kind);
+                       verify_list_head(tgt, kind);
                if (old_tgt)
-                       vrfy_list_head(old_tgt, kind);
+                       verify_list_head(old_tgt, kind);
        }
 #endif
 
@@ -471,17 +472,13 @@ void edges_notify_edge(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir
        }
 
        if (edges_activated_kind(irg, EDGE_KIND_BLOCK) && is_Block(src)) {
-               if (pos == -1) {
-                       /* a MacroBlock edge: ignore it here */
-               } else {
-                       ir_node *bl_old = old_tgt ? get_nodes_block(skip_Proj(old_tgt)) : NULL;
-                       ir_node *bl_tgt = NULL;
+               ir_node *bl_old = old_tgt ? get_nodes_block(skip_Proj(old_tgt)) : NULL;
+               ir_node *bl_tgt = NULL;
 
-                       if (tgt)
-                               bl_tgt = is_Bad(tgt) ? tgt : get_nodes_block(skip_Proj(tgt));
+               if (tgt)
+                       bl_tgt = is_Bad(tgt) ? tgt : get_nodes_block(skip_Proj(tgt));
 
-                       edges_notify_edge_kind(src, pos, bl_tgt, bl_old, EDGE_KIND_BLOCK, irg);
-               }
+               edges_notify_edge_kind(src, pos, bl_tgt, bl_old, EDGE_KIND_BLOCK, irg);
        }
 }
 
@@ -621,6 +618,9 @@ static void visitor(ir_node *irn, void *data)
 {
        visitor_info_t *info = data;
 
+       if (is_Deleted(irn))
+               return;
+
        if (!irn_visited_else_mark(irn)) {
                info->visit(irn, info->data);
        }
@@ -751,7 +751,7 @@ static void verify_list_presence(ir_node *irn, void *data)
        bitset_set(w->reachable, get_irn_idx(irn));
 
        /* check list heads */
-       vrfy_list_head(irn, w->kind);
+       verify_list_head(irn, w->kind);
 
        foreach_out_edge_kind(irn, e, w->kind) {
                ir_node *tgt;
@@ -1074,6 +1074,44 @@ int (get_irn_n_edges_kind)(const ir_node *irn, ir_edge_kind_t kind)
        return _get_irn_n_edges_kind(irn, kind);
 }
 
+static void irg_walk_edges2(ir_node *node, irg_walk_func *pre,
+                            irg_walk_func *post, void *env)
+{
+       const ir_edge_t *edge, *next;
+
+       if (irn_visited(node))
+               return;
+       mark_irn_visited(node);
+
+       if (pre != NULL)
+               pre(node, env);
+
+       foreach_out_edge_kind_safe(node, edge, next, EDGE_KIND_NORMAL) {
+               /* find the corresponding successor block. */
+               ir_node *pred = get_edge_src_irn(edge);
+               irg_walk_edges2(pred, pre, post, env);
+       }
+
+       if (post != NULL)
+               post(node, env);
+}
+
+void irg_walk_edges(ir_node *node, irg_walk_func *pre, irg_walk_func *post,
+                    void *env)
+{
+       ir_graph *irg = get_irn_irg(node);
+
+       assert(edges_activated(irg));
+       assert(is_Block(node));
+
+       ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED);
+
+       inc_irg_visited(irg);
+       irg_walk_edges2(node, pre, post, env);
+
+       ir_free_resources(irg, IR_RESOURCE_IRN_VISITED);
+}
+
 static void irg_block_edges_walk2(ir_node *bl, irg_walk_func *pre,
                                   irg_walk_func *post, void *env)
 {
@@ -1099,13 +1137,15 @@ static void irg_block_edges_walk2(ir_node *bl, irg_walk_func *pre,
 void irg_block_edges_walk(ir_node *node, irg_walk_func *pre,
                           irg_walk_func *post, void *env)
 {
-       assert(edges_activated(current_ir_graph));
+       ir_graph *irg = get_irn_irg(node);
+
+       assert(edges_activated(irg));
        assert(is_Block(node));
 
-       ir_reserve_resources(current_ir_graph, IR_RESOURCE_BLOCK_VISITED);
+       ir_reserve_resources(irg, IR_RESOURCE_BLOCK_VISITED);
 
-       inc_irg_block_visited(current_ir_graph);
+       inc_irg_block_visited(irg);
        irg_block_edges_walk2(node, pre, post, env);
 
-       ir_free_resources(current_ir_graph, IR_RESOURCE_BLOCK_VISITED);
+       ir_free_resources(irg, IR_RESOURCE_BLOCK_VISITED);
 }