Added node info dump callbacks
[libfirm] / ir / ana / irouts.c
index cff4ae3..3e6fa3d 100644 (file)
@@ -98,7 +98,7 @@ int get_Block_n_cfg_outs(ir_node *bl) {
 
 ir_node *get_Block_cfg_out(ir_node *bl, int pos) {
   int i, out_pos = 0;
-  assert(bl && (get_irn_op(bl) == op_Block));
+  assert(bl && is_Block(bl));
 #ifdef DEBUG_libfirm
   assert (bl->out_valid);
 #endif /* defined DEBUG_libfirm */
@@ -178,7 +178,7 @@ void irg_out_block_walk(ir_node *node,
             irg_walk_func *pre, irg_walk_func *post,
             void *env) {
 
-  assert((get_irn_op(node) == op_Block) || (get_irn_mode(node) == mode_X));
+  assert(is_Block(node) || (get_irn_mode(node) == mode_X));
 
   inc_irg_block_visited(current_ir_graph);
 
@@ -238,7 +238,7 @@ static int _count_outs(ir_node *n) {
 
 
 /** Returns the amount of out edges for not yet visited successors.
- *  This version handles some special nodes like irg_frame etc.
+ *  This version handles some special nodes like irg_frame, irg_args etc.
  */
 static int count_outs(ir_graph *irg) {
   ir_node *n;
@@ -254,6 +254,12 @@ static int count_outs(ir_graph *irg) {
     ++res;
   }
 
+  n = get_irg_args(irg);
+  if (irn_not_visited(n)) {
+    n->out = (ir_node **)1;
+    ++res;
+  }
+
   return res;
 }
 
@@ -307,20 +313,27 @@ static ir_node **_set_out_edges(ir_node *n, ir_node **free) {
  * @return The next free address
  */
 static ir_node **set_out_edges(ir_graph *irg, ir_node **free) {
-  ir_node *n;
-  int n_outs;
+  ir_node *n, *special[2];
+  int i, n_outs;
 
   inc_irg_visited(irg);
   free = _set_out_edges(get_irg_end(irg), free);
 
-  n = get_irg_frame(irg);
-  if (get_irn_visited(n) < get_irg_visited(current_ir_graph)) {
-    n_outs = PTR_TO_INT(n->out);
-    n->out = free;
+  /* handle special nodes */
+  special[0] = get_irg_frame(irg);
+  special[1] = get_irg_args(irg);
+
+  for (i = 1; i >= 0; --i) {
+    n = special[i];
+
+    if (get_irn_visited(n) < get_irg_visited(current_ir_graph)) {
+      n_outs = PTR_TO_INT(n->out);
+      n->out = free;
 #ifdef DEBUG_libfirm
-    n->out_valid = 1;
+      n->out_valid = 1;
 #endif /* defined DEBUG_libfirm */
-    free += n_outs;
+      free += n_outs;
+    }
   }
 
   return free;
@@ -336,7 +349,7 @@ static INLINE void fix_start_proj(ir_graph *irg) {
   int i;
 
   if (get_Block_n_cfg_outs(startbl)) {
-    for (i = 0; i < get_irn_n_outs(startbl); i++)
+    for (i = get_irn_n_outs(startbl) - 1; i >= 0; --i)
       if (get_irn_mode(get_irn_out(startbl, i)) == mode_X) {
         proj = get_irn_out(startbl, i);
         break;