some preliminary long double support, more panic's
[libfirm] / ir / ir / iredges.c
index 84a442e..9f6cccc 100644 (file)
@@ -238,10 +238,33 @@ const ir_edge_t *get_irn_edge(ir_graph *irg, const ir_node *src, int pos)
 
 /**
  * Change the out count
+ *
+ * @param tgt  the edge target
+ * @param kind the kind of the edge
  */
 static INLINE void edge_change_cnt(ir_node *tgt, ir_edge_kind_t kind, int ofs) {
        irn_edge_info_t *info = _get_irn_edge_info(tgt, kind);
        info->out_count += ofs;
+
+#if 0
+       assert(info->out_count >= 0);
+       if (info->out_count == 0 && kind == EDGE_KIND_NORMAL) {
+               /* tgt lost it's last user */
+               int i;
+
+               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);
+               }
+               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);
+
+               }
+       }
+#endif
 }
 
 /**
@@ -408,8 +431,14 @@ void edges_notify_edge(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir
        }
 }
 
-
-void edges_node_deleted_kind(ir_node *old, ir_edge_kind_t kind, ir_graph *irg)
+/**
+ * Delete all in edges of a given kind from the node old.
+ *
+ * @param old   the node
+ * @param kind  the kind of edges to remove
+ * @param irg   the irg of the old node
+ */
+static void edges_node_deleted_kind(ir_node *old, ir_edge_kind_t kind, ir_graph *irg)
 {
        int i, n;
 
@@ -560,8 +589,10 @@ static void verify_set_presence(ir_node *irn, void *data)
                        e->present = 1;
                } else {
                        w->problem_found = 1;
+#if 0
                        ir_fprintf(stderr, "Edge Verifier: edge %+F,%d -> %+F (kind: \"%s\") is missing\n",
                                irn, i, get_n(irn, i, w->kind), get_kind_str(w->kind));
+#endif
                }
        }
 }
@@ -581,8 +612,10 @@ static void verify_list_presence(ir_node *irn, void *data)
 
                if (w->kind == EDGE_KIND_NORMAL && get_irn_arity(e->src) <= e->pos) {
                        w->problem_found = 1;
+#if 0
                        ir_fprintf(stderr, "Edge Verifier: edge(%ld) %+F -> %+F recorded at src position %d, but src has arity %d\n",
                                edge_get_id(e), e->src, irn, e->pos, get_irn_arity(e->src));
+#endif
                        continue;
                }
 
@@ -590,8 +623,10 @@ static void verify_list_presence(ir_node *irn, void *data)
 
                if (irn != tgt) {
                        w->problem_found = 1;
+#if 0
                        ir_fprintf(stderr, "Edge Verifier: edge(%ld) %+F,%d (kind \"%s\") is no out edge of %+F but of %+F\n",
                                edge_get_id(e), e->src, e->pos, get_kind_str(w->kind), irn, tgt);
+#endif
                }
        }
 }
@@ -838,3 +873,38 @@ void dump_all_out_edges(ir_node *irn)
                }
        }
 }
+
+static void irg_block_edges_walk2(ir_node *bl,
+                                irg_walk_func *pre, irg_walk_func *post,
+                                void *env) {
+       const ir_edge_t *edge, *next;
+
+       if (Block_not_block_visited(bl)) {
+               mark_Block_block_visited(bl);
+
+               if (pre)
+                       pre(bl, env);
+
+               foreach_out_edge_kind_safe(bl, edge, next, EDGE_KIND_BLOCK) {
+                       /* find the corresponding successor block. */
+                       ir_node *pred = get_edge_src_irn(edge);
+                       irg_block_edges_walk2(pred, pre, post, env);
+               }
+
+               if (post)
+                       post(bl, env);
+       }
+}
+
+/* Walks only over Block nodes in the graph.  Has it's own visited
+   flag, so that it can be interleaved with the other walker.         */
+void irg_block_edges_walk(ir_node *node,
+                          irg_walk_func *pre, irg_walk_func *post,
+                          void *env) {
+
+       assert(edges_activated(current_ir_graph));
+       assert(is_Block(node));
+
+       inc_irg_block_visited(current_ir_graph);
+       irg_block_edges_walk2(node, pre, post, env);
+}