Commit fcf29b0d authored by Matthias Braun's avatar Matthias Braun
Browse files

irdump: cleanup, make dump_blocks_as_subgraphs() available to other modules

parent ea61b46a
...@@ -1324,10 +1324,8 @@ static void dump_whole_block(FILE *F, const ir_node *block) ...@@ -1324,10 +1324,8 @@ static void dump_whole_block(FILE *F, const ir_node *block)
/** dumps a graph block-wise. Expects all blockless nodes in arr in irgs link. /** dumps a graph block-wise. Expects all blockless nodes in arr in irgs link.
* The outermost nodes: blocks and nodes not op_pin_state_pinned, Bad, Unknown. */ * The outermost nodes: blocks and nodes not op_pin_state_pinned, Bad, Unknown. */
static void dump_block_graph(FILE *F, ir_graph *irg) static void dump_block_graph(FILE *F, ir_graph *irg, ir_node **arr)
{ {
ir_node **arr = (ir_node**)ird_get_irg_link(irg);
for (size_t i = 0, n = ARR_LEN(arr); i < n; ++i) { for (size_t i = 0, n = ARR_LEN(arr); i < n; ++i) {
ir_node *node = arr[i]; ir_node *node = arr[i];
if (is_Block(node)) { if (is_Block(node)) {
...@@ -1403,27 +1401,6 @@ static void dump_graph_info(FILE *F, ir_graph *irg) ...@@ -1403,27 +1401,6 @@ static void dump_graph_info(FILE *F, ir_graph *irg)
fprintf(F, "\"\n"); fprintf(F, "\"\n");
} }
/** Dumps an irg as a graph clustered by block nodes.
* If interprocedural view edges can point to nodes out of this graph.
*/
static void dump_graph_from_list(FILE *F, ir_graph *irg)
{
ir_entity *ent = get_irg_entity(irg);
fprintf(F, "graph: { title: ");
print_irgid(F, irg);
fprintf(F, " label: \"%s\" status:clustered color:%s\n",
get_ent_dump_name(ent), color_names[ird_color_prog_background]);
dump_graph_info(F, irg);
print_dbg_info(F, get_entity_dbg_info(ent));
dump_block_graph(F, irg);
/* Close the vcg information for the irg */
fprintf(F, "}\n\n");
}
/*******************************************************************/ /*******************************************************************/
/* Basic type and entity nodes and edges. */ /* Basic type and entity nodes and edges. */
/*******************************************************************/ /*******************************************************************/
...@@ -1794,31 +1771,25 @@ void dump_vcg_footer(FILE *F) ...@@ -1794,31 +1771,25 @@ void dump_vcg_footer(FILE *F)
fprintf(F, "}\n"); fprintf(F, "}\n");
} }
void dump_blocks_as_subgraphs(FILE *out, ir_graph *irg)
static void dump_blocks_as_subgraphs(FILE *out, ir_graph *irg)
{ {
construct_block_lists(irg); ir_node **arr = construct_block_lists(irg);
dump_block_graph(out, irg, arr);
/* 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.
*/
foreach_irp_irg_r(i, other_irg) {
ir_node **arr = (ir_node**)ird_get_irg_link(other_irg);
if (arr == NULL)
continue;
dump_graph_from_list(out, other_irg);
DEL_ARR_F(arr);
}
} }
void dump_ir_graph_file(FILE *out, ir_graph *irg) void dump_ir_graph_file(FILE *out, ir_graph *irg)
{ {
dump_vcg_header(out, get_irg_dump_name(irg), NULL, NULL); dump_vcg_header(out, get_irg_dump_name(irg), NULL, NULL);
ir_entity *ent = get_irg_entity(irg);
fprintf(out, "graph: { title: ");
print_irgid(out, irg);
fprintf(out, " label: \"%s\" status:clustered color:%s\n",
get_ent_dump_name(ent), color_names[ird_color_prog_background]);
dump_graph_info(out, irg);
print_dbg_info(out, get_entity_dbg_info(ent));
/* dump nodes */ /* dump nodes */
if (flags & ir_dump_flag_blocks_as_subgraphs) { if (flags & ir_dump_flag_blocks_as_subgraphs) {
dump_blocks_as_subgraphs(out, irg); dump_blocks_as_subgraphs(out, irg);
...@@ -1827,6 +1798,9 @@ void dump_ir_graph_file(FILE *out, ir_graph *irg) ...@@ -1827,6 +1798,9 @@ void dump_ir_graph_file(FILE *out, ir_graph *irg)
ird_walk_graph(irg, NULL, dump_node_with_edges, out); ird_walk_graph(irg, NULL, dump_node_with_edges, out);
} }
/* Close the vcg information for the irg */
fprintf(out, "}\n\n");
/* dump type info */ /* dump type info */
if (flags & ir_dump_flag_with_typegraph) { if (flags & ir_dump_flag_with_typegraph) {
type_walk_irg(irg, dump_type_info, NULL, out); type_walk_irg(irg, dump_type_info, NULL, out);
......
...@@ -40,6 +40,7 @@ void dump_ir_data_edges(FILE *F, const ir_node *n); ...@@ -40,6 +40,7 @@ void dump_ir_data_edges(FILE *F, const ir_node *n);
void dump_begin_block_subgraph(FILE *F, const ir_node *block); void dump_begin_block_subgraph(FILE *F, const ir_node *block);
void dump_end_block_subgraph(FILE *F, const ir_node *block); void dump_end_block_subgraph(FILE *F, const ir_node *block);
void dump_block_edges(FILE *F, const ir_node *block); void dump_block_edges(FILE *F, const ir_node *block);
void dump_blocks_as_subgraphs(FILE *out, ir_graph *irg);
/** Write the irnode and all its attributes to the file passed. /** Write the irnode and all its attributes to the file passed.
* (plain text format) */ * (plain text format) */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment