- /* Check whether we walked all procedures: there could be procedures
- with cyclic calls but no call from the outside. */
- for (i = 0; i < get_irp_n_irgs(); i++) {
- ir_node *sb;
- current_ir_graph = get_irp_irg(i);
-
- /* Test start block: if inner procedure end and end block are not
- * visible and therefore not marked. */
- sb = get_irg_start_block(current_ir_graph);
- if (get_irn_visited(sb) < get_irg_visited(current_ir_graph)) {
- compute_outs(current_ir_graph); /*cg_walk_2(sb, pre, post, env); */
- }
+
+/*
+ * Inits all nodes for setting the outedges
+ * Returns the overall count of edges
+ */
+int count_ip_outs(void) {
+
+ int res = 0;
+
+ cg_walk(init_count, node_arity_count, &res);
+
+ return(res);
+}
+
+static int dummy_count = 0, global_count; /* Only for debugging */
+
+/**
+ * For each node: Sets the pointer to array
+ * in which the outedges are written later.
+ * The current array start is transported in env
+ */
+static void set_array_pointer(ir_node *node, void *env) {
+
+ int n_outs;
+ ir_node ***free = (ir_node ***) env;
+
+ /* Allocate my array */
+ n_outs = PTR_TO_INT(node->out); /* We wrote the count here in count_ip_outs */
+ dummy_count += n_outs;
+ assert(dummy_count <= global_count && "More outedges than initially counted!");
+ node -> out = *free;
+ *free = &((*free)[n_outs]);
+ /* We count the successors again, the space will be sufficient.
+ We use this counter to remember the position for the next back
+ edge. */
+ node -> out[0] = (ir_node *) 0;
+}
+
+
+/**
+ * Adds an outedge from the predecessor to the
+ * current node.
+ */
+static void set_out_pointer(ir_node * node, void * env) {
+ int i, arity = get_irn_arity(node);
+ ir_node *succ;
+ int start = (!is_Block(node)) ? -1 : 0;
+
+ for (i = start; i < arity; i++) {
+ succ = get_irn_n(node, i);
+ succ->out[get_irn_n_outs(succ)+1] = node;
+ succ->out[0] = INT_TO_PTR(get_irn_n_outs(succ) + 1);