- FILE *f;
- ir_graph *rem = current_ir_graph;
- int el_rem = edge_label;
- edge_label = 1;
-
- /* if a filter is set, dump only the irg's that match the filter */
- if (!is_filtered_dump_name(get_entity_ident(get_irg_entity(irg)))) return;
-
- current_ir_graph = irg;
-
- f = vcg_open(irg, suffix, "-looptree");
- dump_vcg_header(f, get_irg_dump_name(irg), "top_to_bottom");
-
- if (get_irg_loop(irg)) dump_loops_standalone(f, get_irg_loop(irg));
-
- vcg_close(f);
-
- edge_label = el_rem;
- current_ir_graph = rem;
-}
-
-void dump_callgraph_loop_tree(const char *suffix) {
- FILE *F;
- F = vcg_open_name("Callgraph_looptree", suffix);
- dump_vcg_header(F, "callgraph looptree", "top_to_bottom");
- dump_loops_standalone(F, irp->outermost_cg_loop);
- vcg_close(F);
-}
-
-
-/*-----------------------------------------------------------------------------*/
-/* Dumps the firm nodes in the loop tree to a graph along with the loop nodes. */
-/*-----------------------------------------------------------------------------*/
-
-void collect_nodeloop(FILE *F, ir_loop *loop, eset *loopnodes) {
- int i, son_number = 0, node_number = 0;
-
- if (dump_loop_information_flag) dump_loop_node(F, loop);
-
- for (i = 0; i < get_loop_n_elements(loop); i++) {
- loop_element le = get_loop_element(loop, i);
- if (*(le.kind) == k_ir_loop) {
- if (dump_loop_information_flag) dump_loop_son_edge(F, loop, son_number++);
- /* Recur */
- collect_nodeloop(F, le.son, loopnodes);
- } else {
- if (dump_loop_information_flag) dump_loop_node_edge(F, loop, node_number++);
- eset_insert(loopnodes, le.node);
- }
- }
-}
-
-void collect_nodeloop_external_nodes(ir_loop *loop, eset *loopnodes, eset *extnodes) {
- int i, j, start;
-
- for(i = 0; i < get_loop_n_elements(loop); i++) {
- loop_element le = get_loop_element(loop, i);
- if (*(le.kind) == k_ir_loop) {
- /* Recur */
- collect_nodeloop_external_nodes(le.son, loopnodes, extnodes);
- } else {
- if (is_Block(le.node)) start = 0; else start = -1;
- for (j = start; j < get_irn_arity(le.node); j++) {
- ir_node *pred = get_irn_n(le.node, j);
- if (!eset_contains(loopnodes, pred)) {
- eset_insert(extnodes, pred);
- if (!is_Block(pred)) {
- pred = get_nodes_block(pred);
- if (!eset_contains(loopnodes, pred)) eset_insert(extnodes, pred);
- }
- }
- }
- }
- }
-}
-
-void dump_loop(ir_loop *l, const char *suffix) {
- FILE *F;
- char name[50];
- eset *loopnodes = eset_create();
- eset *extnodes = eset_create();
- ir_node *n, *b;
-
- snprintf(name, sizeof(name), "loop_%d", get_loop_loop_nr(l));
- F = vcg_open_name (name, suffix);
- dump_vcg_header(F, name, NULL);
-
- /* collect all nodes to dump */
- collect_nodeloop(F, l, loopnodes);
- collect_nodeloop_external_nodes(l, loopnodes, extnodes);
-
- /* build block lists */
- for (n = eset_first(loopnodes); n != NULL; n = eset_next(loopnodes))
- set_irn_link(n, NULL);
- for (n = eset_first(extnodes); n != NULL; n = eset_next(extnodes))
- set_irn_link(n, NULL);
- for (n = eset_first(loopnodes); n != NULL; n = eset_next(loopnodes))
- if (!is_Block(n)) {
- b = get_nodes_block(n);
- set_irn_link(n, get_irn_link(b));
- set_irn_link(b, n);
- }
- for (n = eset_first(extnodes); n != NULL; n = eset_next(extnodes))
- if (!is_Block(n)) {
- b = get_nodes_block(n);
- set_irn_link(n, get_irn_link(b));
- set_irn_link(b, n);
- }
-
- for (b = eset_first(loopnodes); b != NULL; b = eset_next(loopnodes))
- if (is_Block(b)) {
- fprintf(F, "graph: { title: \"");
- PRINT_NODEID(b);
- fprintf(F, "\" label: \"");
- dump_node_opcode(F, b);
- fprintf (F, " %ld", get_irn_node_nr(b));
- fprintf(F, "\" status:clustered color:yellow\n");
-
- /* dump the blocks edges */
- dump_ir_data_edges(F, b);
-
- /* dump the nodes that go into the block */
- for (n = get_irn_link(b); n; n = get_irn_link(n)) {
- if (eset_contains(extnodes, n))
- overrule_nodecolor = ird_color_lightblue;
- dump_node(F, n);
- overrule_nodecolor = ird_color_default;
- if (!eset_contains(extnodes, n)) dump_ir_data_edges(F, n);
- }
-
- /* Close the vcg information for the block */
- fprintf(F, "}\n");
- dump_const_node_local(F, b);
- fprintf(F, "\n");
- }
- for (b = eset_first(extnodes); b != NULL; b = eset_next(extnodes))
- if (is_Block(b)) {
- fprintf(F, "graph: { title: \"");
- PRINT_NODEID(b);
- fprintf(F, "\" label: \"");
- dump_node_opcode(F, b);
- fprintf (F, " %ld", get_irn_node_nr(b));
- fprintf(F, "\" status:clustered color:lightblue\n");
-
- /* dump the nodes that go into the block */
- for (n = get_irn_link(b); n; n = get_irn_link(n)) {
- if (!eset_contains(loopnodes, n))
- overrule_nodecolor = ird_color_lightblue;
- dump_node(F, n);
- overrule_nodecolor = ird_color_default;
- if (eset_contains(loopnodes, n)) dump_ir_data_edges(F, n);
- }
-
- /* Close the vcg information for the block */
- fprintf(F, "}\n");
- dump_const_node_local(F, b);
- fprintf(F, "\n");
- }
-
- eset_destroy(loopnodes);
- eset_destroy(extnodes);
- vcg_close(F);
+ FILE *f;
+
+ /* if a filter is set, dump only the irg's that match the filter */
+ if (!is_filtered_dump_name(get_entity_ident(get_irg_entity(irg))))
+ return;
+
+ f = vcg_open(irg, suffix, "-looptree");
+ if (f != NULL) {
+ ir_graph *rem = current_ir_graph;
+ int el_rem = edge_label;
+
+ current_ir_graph = irg;
+ edge_label = 1;
+
+ dump_vcg_header(f, get_irg_dump_name(irg), "Tree", "top_to_bottom");
+
+ if (get_irg_loop(irg))
+ dump_loops_standalone(f, get_irg_loop(irg));
+
+ dump_vcg_footer(f);
+ fclose(f);
+
+ edge_label = el_rem;
+ current_ir_graph = rem;
+ }
+}
+
+void dump_callgraph_loop_tree(const char *suffix)
+{
+ FILE *F;
+ F = vcg_open_name("Callgraph_looptree", suffix);
+ dump_vcg_header(F, "callgraph looptree", "Tree", "top_to_bottom");
+ dump_loops_standalone(F, irp->outermost_cg_loop);
+ dump_vcg_footer(F);
+ fclose(F);
+}
+
+
+/*----------------------------------------------------------------------------*/
+/* Dumps the firm nodes in the loop tree to a graph along with the loop nodes.*/
+/*----------------------------------------------------------------------------*/
+
+void collect_nodeloop(FILE *F, ir_loop *loop, eset *loopnodes)
+{
+ int i, son_number = 0, node_number = 0;
+
+ if (dump_loop_information_flag) dump_loop_node(F, loop);
+
+ for (i = 0; i < get_loop_n_elements(loop); i++) {
+ loop_element le = get_loop_element(loop, i);
+ if (*(le.kind) == k_ir_loop) {
+ if (dump_loop_information_flag) dump_loop_son_edge(F, loop, son_number++);
+ /* Recur */
+ collect_nodeloop(F, le.son, loopnodes);
+ } else {
+ if (dump_loop_information_flag) dump_loop_node_edge(F, loop, node_number++);
+ eset_insert(loopnodes, le.node);
+ }
+ }
+}
+
+void collect_nodeloop_external_nodes(ir_loop *loop, eset *loopnodes, eset *extnodes)
+{
+ int i, j, start;
+
+ for (i = 0; i < get_loop_n_elements(loop); i++) {
+ loop_element le = get_loop_element(loop, i);
+ if (*(le.kind) == k_ir_loop) {
+ /* Recur */
+ collect_nodeloop_external_nodes(le.son, loopnodes, extnodes);
+ } else {
+ if (is_Block(le.node)) start = 0; else start = -1;
+ for (j = start; j < get_irn_arity(le.node); j++) {
+ ir_node *pred = get_irn_n(le.node, j);
+ if (!eset_contains(loopnodes, pred)) {
+ eset_insert(extnodes, pred);
+ if (!is_Block(pred)) {
+ pred = get_nodes_block(pred);
+ if (!eset_contains(loopnodes, pred)) eset_insert(extnodes, pred);
+ }
+ }
+ }
+ }
+ }
+}
+
+void dump_loop(ir_loop *l, const char *suffix)
+{
+ FILE *F;
+ char name[50];
+
+ snprintf(name, sizeof(name), "loop_%d", get_loop_loop_nr(l));
+ F = vcg_open_name(name, suffix);
+ if (F != NULL) {
+ eset *loopnodes = eset_create();
+ eset *extnodes = eset_create();
+ ir_node *n, *b;
+
+ dump_vcg_header(F, name, NULL, NULL);
+
+ /* collect all nodes to dump */
+ collect_nodeloop(F, l, loopnodes);
+ collect_nodeloop_external_nodes(l, loopnodes, extnodes);
+
+ /* build block lists */
+ for (n = eset_first(loopnodes); n != NULL; n = eset_next(loopnodes))
+ set_irn_link(n, NULL);
+ for (n = eset_first(extnodes); n != NULL; n = eset_next(extnodes))
+ set_irn_link(n, NULL);
+ for (n = eset_first(loopnodes); n != NULL; n = eset_next(loopnodes)) {
+ if (!is_Block(n)) {
+ b = get_nodes_block(n);
+ set_irn_link(n, get_irn_link(b));
+ set_irn_link(b, n);
+ }
+ }
+ for (n = eset_first(extnodes); n != NULL; n = eset_next(extnodes)) {
+ if (!is_Block(n)) {
+ b = get_nodes_block(n);
+ set_irn_link(n, get_irn_link(b));
+ set_irn_link(b, n);
+ }
+ }
+
+ for (b = eset_first(loopnodes); b != NULL; b = eset_next(loopnodes)) {
+ if (is_Block(b)) {
+ fprintf(F, "graph: { title: \"");
+ PRINT_NODEID(b);
+ fprintf(F, "\" label: \"");
+ dump_node_opcode(F, b);
+ fprintf(F, " %ld:%d", get_irn_node_nr(b), get_irn_idx(b));
+ fprintf(F, "\" status:clustered color:yellow\n");
+
+ /* dump the blocks edges */
+ dump_ir_data_edges(F, b);
+
+ /* dump the nodes that go into the block */
+ for (n = get_irn_link(b); n; n = get_irn_link(n)) {
+ if (eset_contains(extnodes, n))
+ overrule_nodecolor = ird_color_block_inout;
+ dump_node(F, n);
+ overrule_nodecolor = ird_color_default_node;
+ if (!eset_contains(extnodes, n)) dump_ir_data_edges(F, n);
+ }
+
+ /* Close the vcg information for the block */
+ fprintf(F, "}\n");
+ dump_const_node_local(F, b);
+ fprintf(F, "\n");
+ }
+ }
+ for (b = eset_first(extnodes); b != NULL; b = eset_next(extnodes)) {
+ if (is_Block(b)) {
+ fprintf(F, "graph: { title: \"");
+ PRINT_NODEID(b);
+ fprintf(F, "\" label: \"");
+ dump_node_opcode(F, b);
+ fprintf(F, " %ld:%d", get_irn_node_nr(b), get_irn_idx(b));
+ fprintf(F, "\" status:clustered color:lightblue\n");
+
+ /* dump the nodes that go into the block */
+ for (n = get_irn_link(b); n; n = get_irn_link(n)) {
+ if (!eset_contains(loopnodes, n))
+ overrule_nodecolor = ird_color_block_inout;
+ dump_node(F, n);
+ overrule_nodecolor = ird_color_default_node;
+ if (eset_contains(loopnodes, n)) dump_ir_data_edges(F, n);
+ }
+
+ /* Close the vcg information for the block */
+ fprintf(F, "}\n");
+ dump_const_node_local(F, b);
+ fprintf(F, "\n");
+ }
+ }
+ eset_destroy(loopnodes);
+ eset_destroy(extnodes);
+
+ dump_vcg_footer(F);
+ fclose(F);
+ }