Moved from irgopt.c
[libfirm] / ir / ana / irouts.c
index 2c1ebf1..a4b01cd 100644 (file)
@@ -29,8 +29,7 @@
 
 #include "irouts.h"
 #include "irnode_t.h"
-#include "irgraph_t.h"     /* To access irg->outs field (which is private to this module)
-                  without public access routine */
+#include "irgraph_t.h"
 #include "irprog_t.h"
 #include "irgwalk.h"
 #include "string.h"
@@ -140,7 +139,7 @@ void irg_out_walk(ir_node *node,
             irg_walk_func *pre, irg_walk_func *post,
             void *env) {
   assert(node);
-  if (get_irg_outs_state(current_ir_graph) != no_outs) {
+  if (get_irg_outs_state(current_ir_graph) != outs_none) {
     inc_irg_visited (current_ir_graph);
     irg_out_walk_2(node, pre, post, env);
   }
@@ -291,7 +290,7 @@ void compute_outs(ir_graph *irg) {
 
   /* Update graph state */
   assert(get_irg_phase_state(current_ir_graph) != phase_building);
-  if (current_ir_graph->outs_state != no_outs) free_outs(current_ir_graph);
+  if (current_ir_graph->outs_state != outs_none) free_outs(current_ir_graph);
   current_ir_graph->outs_state = outs_consistent;
 
   /* This first iteration counts the overall number of out edges and the
@@ -354,15 +353,16 @@ static void init_count(ir_node * node, void * env)
 
 static void node_arity_count(ir_node * node, void * env)
 {
-  int *anz = (int *) env, arity, i, start;
+  int *anz = (int *) env, arity, n_outs, i, start;
   ir_node *succ;
 
-  arity = 1 + get_irn_arity(node)
-            + ((is_Block(node)) ? 0 : 1);
-  *anz += arity;
-
+  arity = get_irn_arity(node);
   start = (is_Block(node)) ? 0 : -1;
-  for(i = start; i < get_irn_arity(node); i++) {
+
+  n_outs = 1 + arity + (-start);  // ((is_Block(node)) ? 0 : 1);   // Why + 1??
+  *anz += n_outs;
+
+  for(i = start; i < arity; i++) {
     succ = get_irn_n(node, i);
     succ->out = (ir_node **)((int)succ->out + 1);
   }
@@ -415,11 +415,11 @@ static void set_array_pointer(ir_node *node, void *env) {
    ------------------------------------------- */
 
 static void set_out_pointer(ir_node * node, void * env) {
-  int i;
+  int i, arity = get_irn_arity(node);
   ir_node *succ;
   int start = (!is_Block(node)) ? -1 : 0;
 
-  for(i = start; i < get_irn_arity(node); i++) {
+  for(i = start; i < arity; i++) {
     succ = get_irn_n(node, i);
     succ->out[get_irn_n_outs(succ)+1] = node;
     succ->out[0] = (ir_node *) (get_irn_n_outs(succ) + 1);
@@ -453,7 +453,7 @@ void compute_ip_outs(void) {
   assert(get_irp_ip_view_state() == ip_view_valid &&
      "Cannot construct outs for invalid ip view.");
 
-  if (irp->outs_state != no_outs) {
+  if (irp->outs_state != outs_none) {
     free_ip_outs();
   }
 
@@ -470,14 +470,14 @@ void free_ip_outs(void)
     free(out_edges);
     set_irp_ip_outedges(NULL);
   }
-  irp->outs_state = no_outs;
+  irp->outs_state = outs_none;
 }
 
 
 void free_outs(ir_graph *irg) {
 
-  /*   current_ir_graph->outs_state = no_outs; */
-  irg->outs_state = no_outs;
+  /*   current_ir_graph->outs_state = outs_none; */
+  irg->outs_state = outs_none;
 
   if (irg->outs) {
 #ifdef DEBUG_libfirm