- This computes the outedges for in interprocedural graph.
-*/
-
-void compute_ip_outs(ir_graph *irg) {
- int i;
- ir_graph *rem = current_ir_graph;
- int rem_view = interprocedural_view;
-
- interprocedural_view = true;
-
- inc_max_irg_visited();
- /* Fix all irg_visited flags */
- for (i = 0; i < get_irp_n_irgs(); i++)
- set_irg_visited(get_irp_irg(i), get_max_irg_visited());
-
- /* Walk starting at unreachable procedures. Only these
- * have End blocks visible in interprocedural view. */
- for (i = 0; i < get_irp_n_irgs(); i++) {
- ir_node *sb;
- current_ir_graph = get_irp_irg(i);
-
- sb = get_irg_start_block(current_ir_graph);
-
- if ((get_Block_n_cfgpreds(sb) > 1) ||
- (get_nodes_block(get_Block_cfgpred(sb, 0)) != sb)) continue;
-
- compute_outs(current_ir_graph); /*cg_walk_2(get_irg_end(current_ir_graph), pre, post, env);*/
- }
-
- /* 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); */
- }
- }
-
-
- /* Walk all endless loops in inner procedures.
- * We recognize an inner procedure if the End node is not visited. */
-
- /* AS: Don't know if we need this... Goetz? */
-
-#if 0
- for (i = 0; i < get_irp_n_irgs(); i++) {
- ir_node *e;
- current_ir_graph = get_irp_irg(i);
- e = get_irg_end(current_ir_graph);
- if (get_irn_visited(e) < get_irg_visited(current_ir_graph)) {
- /* Don't visit the End node. */
- /* int j;
- for (j = 0; j < get_End_n_keepalives(e); j++)
- cg_walk_2(get_End_keepalive(e, j), pre, post, env);*/
- printf("Found one inner procedure\n");
- compute_outs(current_ir_graph);
- }
- }
-#endif
+ * 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;
+}