/**
* Dumps the vcg file footer
*/
-static void dump_vcg_footer(FILE *F) {
+void dump_vcg_footer(FILE *F) {
fprintf(F, "}\n");
}
-/**
- * close the vcg file
- */
-void vcg_close(FILE *F) {
- dump_vcg_footer(F); /* print footer */
- fclose (F); /* close vcg file */
-}
-
/************************************************************************/
/************************************************************************/
/* Routines that dump all or parts of the firm representation to a file */
/* Dump ir graphs, different formats and additional information. */
/************************************************************************/
-/** Routine to dump a graph, blocks as conventional nodes. */
-void
-dump_ir_graph(ir_graph *irg, const char *suffix )
+typedef void (*do_dump_graph_func) (ir_graph *irg, FILE *out);
+
+static void do_dump(ir_graph *irg, const char *suffix, const char *suffix_ip,
+ const char *suffix_nonip, do_dump_graph_func dump_func)
{
- FILE *f;
- ir_graph *rem;
- char *suffix1;
+ FILE *out;
+ ir_graph *rem;
+ const char *suffix1;
if (!is_filtered_dump_name(get_entity_ident(get_irg_entity(irg))))
return;
- if (dump_backedge_information_flag && get_irg_loopinfo_state(irg) != loopinfo_consistent) {
- construct_backedges(irg);
- }
-
rem = current_ir_graph;
current_ir_graph = irg;
- if (get_interprocedural_view()) suffix1 = "-pure-ip";
- else suffix1 = "-pure";
- f = vcg_open(irg, suffix, suffix1);
- if (f != NULL) {
- dump_vcg_header(f, get_irg_dump_name(irg), NULL);
+ if (get_interprocedural_view())
+ suffix1 = suffix_ip;
+ else
+ suffix1 = suffix_nonip;
+ current_ir_graph = rem;
- /* call the dump graph hook */
- if (dump_ir_graph_hook)
- if (dump_ir_graph_hook(f, irg)) {
- current_ir_graph = rem;
- return;
- }
+ out = vcg_open(irg, suffix, suffix1);
+ if (out != NULL) {
+ dump_func(irg, out);
+ fclose(out);
+ }
+}
- /* walk over the graph */
- /* dump_whole_node must be called in post visiting predecessors */
- ird_walk_graph(irg, NULL, dump_whole_node, f);
+void dump_ir_graph_file(ir_graph *irg, FILE *out)
+{
+ if (dump_backedge_information_flag
+ && get_irg_loopinfo_state(irg) != loopinfo_consistent) {
+ construct_backedges(irg);
+ }
- /* dump the out edges in a separate walk */
- if ((dump_out_edge_flag) && (get_irg_outs_state(irg) != outs_none)) {
- irg_out_walk(get_irg_start(irg), dump_out_edge, NULL, f);
- }
+ dump_vcg_header(out, get_irg_dump_name(irg), NULL);
- vcg_close(f);
+ /* call the dump graph hook */
+ if (dump_ir_graph_hook) {
+ if (dump_ir_graph_hook(out, irg)) {
+ return;
+ }
}
- current_ir_graph = rem;
+
+ /* walk over the graph */
+ /* dump_whole_node must be called in post visiting predecessors */
+ ird_walk_graph(irg, NULL, dump_whole_node, out);
+
+ /* dump the out edges in a separate walk */
+ if ((dump_out_edge_flag) && (get_irg_outs_state(irg) != outs_none)) {
+ irg_out_walk(get_irg_start(irg), dump_out_edge, NULL, out);
+ }
+
+ dump_vcg_footer(out);
}
-/* Dump a firm graph without explicit block nodes. */
-void dump_ir_block_graph(ir_graph *irg, const char *suffix)
+/** Routine to dump a graph, blocks as conventional nodes. */
+void dump_ir_graph(ir_graph *irg, const char *suffix )
{
- FILE *f;
- int i;
- char *suffix1;
-
- if (!is_filtered_dump_name(get_entity_ident(get_irg_entity(irg))))
- return;
+ do_dump(irg, suffix, "-pure-ip", "-pure", dump_ir_graph_file);
+}
- if (get_interprocedural_view()) suffix1 = "-ip";
- else suffix1 = "";
- f = vcg_open(irg, suffix, suffix1);
+void dump_ir_block_graph_file(ir_graph *irg, FILE *out)
+{
+ int i;
- if (f != NULL) {
- dump_vcg_header(f, get_irg_dump_name(irg), NULL);
+ dump_vcg_header(out, get_irg_dump_name(irg), NULL);
- construct_block_lists(irg);
+ construct_block_lists(irg);
- /*
- * If we are in the interprocedural view, we dump not
- * only the requested irg but also all irgs that can be reached
- * from irg.
- */
- for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
- ir_graph *g = get_irp_irg(i);
- ir_node **arr = ird_get_irg_link(g);
- if (arr) {
- dump_graph_from_list(f, g);
- DEL_ARR_F(arr);
- }
+ /*
+ * If we are in the interprocedural view, we dump not
+ * only the requested irg but also all irgs that can be reached
+ * from irg.
+ */
+ for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
+ ir_graph *g = get_irp_irg(i);
+ ir_node **arr = ird_get_irg_link(g);
+ if (arr) {
+ dump_graph_from_list(out, g);
+ DEL_ARR_F(arr);
}
-
- vcg_close(f);
}
+
+ dump_vcg_footer(out);
}
-/* Dump a firm graph without explicit block nodes but grouped in extended blocks. */
-void dump_ir_extblock_graph(ir_graph *irg, const char *suffix)
+/* Dump a firm graph without explicit block nodes. */
+void dump_ir_block_graph(ir_graph *irg, const char *suffix)
{
- FILE *F;
- int i;
- char *suffix1;
- ir_entity *ent;
+ do_dump(irg, suffix, "-ip", "", dump_ir_block_graph_file);
+}
- if (!is_filtered_dump_name(get_entity_ident(get_irg_entity(irg))))
- return;
+void dump_ir_extblock_graph_file(ir_graph *irg, FILE *F)
+{
+ int i;
+ ir_entity *ent = get_irg_entity(irg);
if (get_irg_extblk_state(irg) != extblk_valid)
compute_extbb(irg);
- if (get_interprocedural_view()) suffix1 = "-ip";
- else suffix1 = "";
-
- ent = get_irg_entity(irg);
-
- F = vcg_open(irg, suffix, suffix1);
- if (F != NULL) {
- dump_vcg_header(F, get_irg_dump_name(irg), NULL);
+ dump_vcg_header(F, get_irg_dump_name(irg), NULL);
- construct_extblock_lists(irg);
+ construct_extblock_lists(irg);
- fprintf(F, "graph: { title: \"");
- PRINT_IRGID(irg);
- fprintf(F, "\" label: \"%s\" status:clustered color: white \n",
- get_ent_dump_name(ent));
+ fprintf(F, "graph: { title: \"");
+ PRINT_IRGID(irg);
+ fprintf(F, "\" label: \"%s\" status:clustered color: white \n",
+ get_ent_dump_name(ent));
- dump_graph_info(F, irg);
- print_dbg_info(F, get_entity_dbg_info(ent));
+ dump_graph_info(F, irg);
+ print_dbg_info(F, get_entity_dbg_info(ent));
- for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
- ir_graph *irg = get_irp_irg(i);
- list_tuple *lists = ird_get_irg_link(irg);
-
- if (lists) {
- /* dump the extended blocks first */
- if (ARR_LEN(lists->extbb_list)) {
- ird_set_irg_link(irg, lists->extbb_list);
- dump_extblock_graph(F, irg);
- }
+ for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
+ ir_graph *irg = get_irp_irg(i);
+ list_tuple *lists = ird_get_irg_link(irg);
- /* we may have blocks without extended blocks, bad for instance */
- if (ARR_LEN(lists->blk_list)) {
- ird_set_irg_link(irg, lists->blk_list);
- dump_block_graph(F, irg);
- }
+ if (lists) {
+ /* dump the extended blocks first */
+ if (ARR_LEN(lists->extbb_list)) {
+ ird_set_irg_link(irg, lists->extbb_list);
+ dump_extblock_graph(F, irg);
+ }
- DEL_ARR_F(lists->extbb_list);
- DEL_ARR_F(lists->blk_list);
- xfree(lists);
+ /* we may have blocks without extended blocks, bad for instance */
+ if (ARR_LEN(lists->blk_list)) {
+ ird_set_irg_link(irg, lists->blk_list);
+ dump_block_graph(F, irg);
}
+
+ DEL_ARR_F(lists->extbb_list);
+ DEL_ARR_F(lists->blk_list);
+ xfree(lists);
}
+ }
- /* Close the vcg information for the irg */
- fprintf(F, "}\n\n");
+ /* Close the vcg information for the irg */
+ fprintf(F, "}\n\n");
- vcg_close(F);
- free_extbb(irg);
- }
+ dump_vcg_footer(F);
+ free_extbb(irg);
}
-/* dumps a graph with type information */
-void
-dump_ir_graph_w_types(ir_graph *irg, const char *suffix)
+/* Dump a firm graph without explicit block nodes but grouped in extended blocks. */
+void dump_ir_extblock_graph(ir_graph *irg, const char *suffix)
{
- FILE *f;
- char *suffix1;
-
- /* 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;
+ do_dump(irg, suffix, "-ip", "", dump_ir_extblock_graph_file);
+}
- if (get_interprocedural_view()) suffix1 = "-pure-wtypes-ip";
- else suffix1 = "-pure-wtypes";
- f = vcg_open(irg,suffix, suffix1);
- if (f != NULL) {
- ir_graph *rem = current_ir_graph;
- int rem_dump_const_local;
+void dump_ir_graph_w_types_file(ir_graph *irg, FILE *out)
+{
+ ir_graph *rem = current_ir_graph;
+ int rem_dump_const_local;
- current_ir_graph = irg;
- rem_dump_const_local = dump_const_local;
- /* dumping types does not work with local nodes */
- dump_const_local = 0;
+ rem = current_ir_graph;
+ current_ir_graph = irg;
+ rem_dump_const_local = dump_const_local;
+ /* dumping types does not work with local nodes */
+ dump_const_local = 0;
- dump_vcg_header(f, get_irg_dump_name(irg), NULL);
+ dump_vcg_header(out, get_irg_dump_name(irg), NULL);
- /* dump common ir graph */
- irg_walk(get_irg_end(irg), NULL, dump_whole_node, f);
- /* dump type info */
- type_walk_irg(irg, dump_type_info, NULL, f);
- inc_irg_visited(get_const_code_irg());
- /* dump edges from graph to type info */
- irg_walk(get_irg_end(irg), dump_node2type_edges, NULL, f);
+ /* dump common ir graph */
+ irg_walk(get_irg_end(irg), NULL, dump_whole_node, out);
+ /* dump type info */
+ type_walk_irg(irg, dump_type_info, NULL, out);
+ inc_irg_visited(get_const_code_irg());
+ /* dump edges from graph to type info */
+ irg_walk(get_irg_end(irg), dump_node2type_edges, NULL, out);
- vcg_close(f);
- dump_const_local = rem_dump_const_local;
- current_ir_graph = rem;
- }
+ dump_vcg_footer(out);
+ dump_const_local = rem_dump_const_local;
+ current_ir_graph = rem;
}
-void
-dump_ir_block_graph_w_types(ir_graph *irg, const char *suffix)
+/* dumps a graph with type information */
+void dump_ir_graph_w_types(ir_graph *irg, const char *suffix)
{
- FILE *f;
- int i;
- char *suffix1;
-
- /* 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;
+ do_dump(irg, suffix, "-pure-wtypes-ip", "-pure-wtypes",
+ dump_ir_graph_w_types_file);
+}
- if (get_interprocedural_view()) suffix1 = "-wtypes-ip";
- else suffix1 = "-wtypes";
- f = vcg_open(irg, suffix, suffix1);
- if (f != NULL) {
- ir_graph *rem = current_ir_graph;
- int rem_dump_const_local;
+void dump_ir_block_graph_w_types_file(ir_graph *irg, FILE *out)
+{
+ int i;
+ int rem_dump_const_local;
+ ir_graph *rem = current_ir_graph;
- rem_dump_const_local = dump_const_local;
- /* dumping types does not work with local nodes */
- dump_const_local = 0;
+ rem_dump_const_local = dump_const_local;
+ /* dumping types does not work with local nodes */
+ dump_const_local = 0;
- dump_vcg_header(f, get_irg_dump_name(irg), NULL);
+ dump_vcg_header(out, get_irg_dump_name(irg), NULL);
- /* dump common blocked ir graph */
- construct_block_lists(irg);
+ /* dump common blocked ir graph */
+ construct_block_lists(irg);
- for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
- ir_node **arr = ird_get_irg_link(get_irp_irg(i));
- if (arr) {
- dump_graph_from_list(f, get_irp_irg(i));
- DEL_ARR_F(arr);
- }
+ for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
+ ir_node **arr = ird_get_irg_link(get_irp_irg(i));
+ if (arr) {
+ dump_graph_from_list(out, get_irp_irg(i));
+ DEL_ARR_F(arr);
}
+ }
- /* dump type info */
- current_ir_graph = irg;
- type_walk_irg(irg, dump_type_info, NULL, f);
- inc_irg_visited(get_const_code_irg());
+ /* dump type info */
+ current_ir_graph = irg;
+ type_walk_irg(irg, dump_type_info, NULL, out);
+ inc_irg_visited(get_const_code_irg());
- /* dump edges from graph to type info */
- irg_walk(get_irg_end(irg), dump_node2type_edges, NULL, f);
+ /* dump edges from graph to type info */
+ irg_walk(get_irg_end(irg), dump_node2type_edges, NULL, out);
- vcg_close(f);
- dump_const_local = rem_dump_const_local;
- current_ir_graph = rem;
- }
+ dump_vcg_footer(out);
+ dump_const_local = rem_dump_const_local;
+ current_ir_graph = rem;
+}
+
+void dump_ir_block_graph_w_types(ir_graph *irg, const char *suffix)
+{
+ do_dump(irg, suffix, "-wtypes-ip", "-wtypes",
+ dump_ir_block_graph_w_types_file);
}
/*---------------------------------------------------------------------*/
}
}
-void
-dump_cfg(ir_graph *irg, const char *suffix)
+void dump_cfg(ir_graph *irg, const char *suffix)
{
FILE *f;
/* if a filter is set, dump only the irg's that match the filter */
#ifdef INTERPROCEDURAL_VIEW
set_interprocedural_view(ipv);
#endif
- vcg_close(f);
+ dump_vcg_footer(f);
+ fclose(f);
current_ir_graph = rem;
}
}
pset *mark_set = pset_new_ptr(1);
dump_vcg_header(F, get_irg_dump_name(get_irn_irg(root)), NULL);
descend_and_dump(F, root, depth, mark_set);
- vcg_close(F);
+ dump_vcg_footer(F);
+ fclose(F);
del_pset(mark_set);
}
}
}
edge_label = rem;
- vcg_close(F);
+ dump_vcg_footer(F);
+ fclose(F);
}
}
DEL_ARR_F(ird_get_irg_link(current_ir_graph));
}
- vcg_close(f);
+ dump_vcg_footer(f);
+ fclose(f);
set_interprocedural_view(rem_view);
}
}
walk. So now increase it finally. */
inc_irg_visited(get_const_code_irg());
- vcg_close(f);
+ dump_vcg_footer(f);
+ fclose(f);
current_ir_graph = rem;
}
}
dump_vcg_header(f, "All_types", NULL);
type_walk(dump_type_info, NULL, f);
inc_irg_visited(get_const_code_irg());
- vcg_close(f);
+
+ dump_vcg_footer(f);
+ fclose(f);
}
}
env.dump_ent = entities;
dump_vcg_header(f, "class_hierarchy", NULL);
type_walk(dump_class_hierarchy_node, NULL, &env);
- vcg_close(f);
+
+ dump_vcg_footer(f);
+ fclose(f);
}
}
if (get_irg_loop(irg)) dump_loops_standalone(f, get_irg_loop(irg));
- vcg_close(f);
+ dump_vcg_footer(f);
+ fclose(f);
edge_label = el_rem;
current_ir_graph = rem;
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);
+ dump_vcg_footer(F);
+ fclose(F);
}
}
eset_destroy(loopnodes);
eset_destroy(extnodes);
- vcg_close(F);
+
+ dump_vcg_footer(F);
+ fclose(F);
}
}