rtl.h (print_insn_with_notes): Remove prototype.

* rtl.h (print_insn_with_notes): Remove prototype.
	(rtl_dump_bb_for_graph): New prototype.
	* sched-vis.c (print_insn_with_notes): Make static again.  Fix
	printing of notes.
	(rtl_dump_bb_for_graph): New function.
	* cfghooks.h (struct cfg_hooks) <dump_bb_for_graph>: New hook.
	(dump_bb_for_graph): New prototype.
	* cfghooks.c (dump_bb_for_graph): New function.
	* tree-cfg.c (gimple_cfg_hooks): Register gimple_dump_bb_for_graph
	as dump_bb_for_graph hook implementation for GIMPLE.
	* cfgrtl.c (rtl_cfg_hooks): Likewise for rtl_dump_bb_for_graph.
	(cfg_layout_rtl_cfg_hooks): Likewise.
	* graph.c (draw_cfg_node): Don't include sbitmap.h, rtl.h, tree.h,
	gimple.h, and gimple-pretty-print.h.
	(draw_cfg_node, draw_cfg_node_succ_edges): Use the uniqe function
	definition number instead of the function declaration UID.
	(print_graph_cfg): Take a struct function instead of a tree.
	Use the dump_bb_for_graph hook to dump the basic block content.
	* graph.h (print_graph_cfg): Update prototype.
	* passes.c (execute_function_dump): Update print_graph_cfg call.
	* Makefile.in (graph.o): Fixup dependencies.

From-SVN: r194157
This commit is contained in:
Steven Bosscher 2012-12-04 18:38:26 +00:00
parent 66686181a4
commit 2c895bd193
11 changed files with 90 additions and 47 deletions

View File

@ -1,3 +1,27 @@
2012-12-04 Steven Bosscher <steven@gcc.gnu.org>
* rtl.h (print_insn_with_notes): Remove prototype.
(rtl_dump_bb_for_graph): New prototype.
* sched-vis.c (print_insn_with_notes): Make static again. Fix
printing of notes.
(rtl_dump_bb_for_graph): New function.
* cfghooks.h (struct cfg_hooks) <dump_bb_for_graph>: New hook.
(dump_bb_for_graph): New prototype.
* cfghooks.c (dump_bb_for_graph): New function.
* tree-cfg.c (gimple_cfg_hooks): Register gimple_dump_bb_for_graph
as dump_bb_for_graph hook implementation for GIMPLE.
* cfgrtl.c (rtl_cfg_hooks): Likewise for rtl_dump_bb_for_graph.
(cfg_layout_rtl_cfg_hooks): Likewise.
* graph.c (draw_cfg_node): Don't include sbitmap.h, rtl.h, tree.h,
gimple.h, and gimple-pretty-print.h.
(draw_cfg_node, draw_cfg_node_succ_edges): Use the uniqe function
definition number instead of the function declaration UID.
(print_graph_cfg): Take a struct function instead of a tree.
Use the dump_bb_for_graph hook to dump the basic block content.
* graph.h (print_graph_cfg): Update prototype.
* passes.c (execute_function_dump): Update print_graph_cfg call.
* Makefile.in (graph.o): Fixup dependencies.
2012-12-04 Marcus Shawcroft <marcus.shawcroft@arm.com>
* config/aarch64/aarch64.c (aarch64_build_builtin_va_list): Set

View File

@ -1846,7 +1846,7 @@ gcc.srcextra: gengtype-lex.c
-cp -p $^ $(srcdir)
graph.o: graph.c graph.h $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(DIAGNOSTIC_CORE_H) $(TM_H) $(RTL_H) $(BASIC_BLOCK_H) $(PRETTY_PRINT_H)
$(DIAGNOSTIC_CORE_H) $(BASIC_BLOCK_H) $(PRETTY_PRINT_H) dumpfile.h
sbitmap.o: sbitmap.c sbitmap.h $(CONFIG_H) $(SYSTEM_H) coretypes.h
sparseset.o: sparseset.c $(SYSTEM_H) sparseset.h $(CONFIG_H)

View File

@ -280,6 +280,22 @@ dump_bb (FILE *outf, basic_block bb, int indent, int flags)
fputc ('\n', outf);
}
/* Dumps basic block BB to pretty-printer PP, for use as a label of
a DOT graph record-node. The implementation of this hook is
expected to write the label to the stream that is attached to PP.
Field separators between instructions are pipe characters printed
verbatim. Instructions should be written with some characters
escaped, using pp_write_text_as_dot_label_to_stream(). */
void
dump_bb_for_graph (pretty_printer *pp, basic_block bb)
{
if (!cfg_hooks->dump_bb_for_graph)
internal_error ("%s does not support dump_bb_for_graph",
cfg_hooks->name);
cfg_hooks->dump_bb_for_graph (pp, bb);
}
/* Dump the complete CFG to FILE. FLAGS are the TDF_* flags in dumpfile.h. */
void
dump_flow_info (FILE *file, int flags)

View File

@ -29,6 +29,7 @@ struct cfg_hooks
/* Debugging. */
int (*verify_flow_info) (void);
void (*dump_bb) (FILE *, basic_block, int, int);
void (*dump_bb_for_graph) (pretty_printer *, basic_block);
/* Basic CFG manipulation. */
@ -152,6 +153,8 @@ struct cfg_hooks
extern void verify_flow_info (void);
extern void dump_bb (FILE *, basic_block, int, int);
extern void dump_bb_for_graph (pretty_printer *, basic_block);
extern edge redirect_edge_and_branch (edge, basic_block);
extern basic_block redirect_edge_and_branch_force (edge, basic_block);
extern bool can_remove_branch_p (const_edge);

View File

@ -4529,6 +4529,7 @@ struct cfg_hooks rtl_cfg_hooks = {
"rtl",
rtl_verify_flow_info,
rtl_dump_bb,
rtl_dump_bb_for_graph,
rtl_create_basic_block,
rtl_redirect_edge_and_branch,
rtl_redirect_edge_and_branch_force,
@ -4570,6 +4571,7 @@ struct cfg_hooks cfg_layout_rtl_cfg_hooks = {
"cfglayout mode",
rtl_verify_flow_info_1,
rtl_dump_bb,
rtl_dump_bb_for_graph,
cfg_layout_create_basic_block,
cfg_layout_redirect_edge_and_branch,
cfg_layout_redirect_edge_and_branch_force,

View File

@ -24,15 +24,10 @@ along with GCC; see the file COPYING3. If not see
#include "system.h"
#include "coretypes.h"
#include "diagnostic-core.h" /* for fatal_error */
#include "sbitmap.h"
#include "basic-block.h"
#include "rtl.h"
#include "tree.h"
#include "gimple.h"
#include "graph.h"
#include "dumpfile.h"
#include "pretty-print.h"
#include "gimple-pretty-print.h"
/* DOT files with the .dot extension are recognized as document templates
by a well-known piece of word processing software out of Redmond, WA.
@ -80,10 +75,10 @@ init_graph_slim_pretty_print (FILE *fp)
return &graph_slim_pp;
}
/* Draw a basic block BB belonging to the function with FNDECL_UID
/* Draw a basic block BB belonging to the function with FUNCDEF_NO
as its unique number. */
static void
draw_cfg_node (pretty_printer *pp, int fndecl_uid, basic_block bb)
draw_cfg_node (pretty_printer *pp, int funcdef_no, basic_block bb)
{
const char *shape;
const char *fillcolor;
@ -105,7 +100,7 @@ draw_cfg_node (pretty_printer *pp, int fndecl_uid, basic_block bb)
pp_printf (pp,
"\tfn_%d_basic_block_%d "
"[shape=%s,style=filled,fillcolor=%s,label=\"",
fndecl_uid, bb->index, shape, fillcolor);
funcdef_no, bb->index, shape, fillcolor);
if (bb->index == ENTRY_BLOCK)
pp_string (pp, "ENTRY");
@ -115,28 +110,7 @@ draw_cfg_node (pretty_printer *pp, int fndecl_uid, basic_block bb)
{
pp_character (pp, '{');
pp_write_text_to_stream (pp);
/* This would be easier if there'd be an IR independent iterator... */
if (current_ir_type () == IR_GIMPLE)
gimple_dump_bb_for_graph (pp, bb);
else
{
rtx insn;
bool first = true;
/* TODO: inter-bb stuff. */
FOR_BB_INSNS (bb, insn)
{
if (! first)
{
pp_character (pp, '|');
pp_write_text_to_stream (pp);
}
first = false;
print_insn_with_notes (pp, insn);
pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
}
}
dump_bb_for_graph (pp, bb);
pp_character (pp, '}');
}
@ -145,9 +119,9 @@ draw_cfg_node (pretty_printer *pp, int fndecl_uid, basic_block bb)
}
/* Draw all successor edges of a basic block BB belonging to the function
with FNDECL_UID as its unique number. */
with FUNCDEF_NO as its unique number. */
static void
draw_cfg_node_succ_edges (pretty_printer *pp, int fndecl_uid, basic_block bb)
draw_cfg_node_succ_edges (pretty_printer *pp, int funcdef_no, basic_block bb)
{
edge e;
edge_iterator ei;
@ -181,8 +155,8 @@ draw_cfg_node_succ_edges (pretty_printer *pp, int fndecl_uid, basic_block bb)
pp_printf (pp,
"\tfn_%d_basic_block_%d:s -> fn_%d_basic_block_%d:n "
"[style=%s,color=%s,weight=%d,constraint=%s];\n",
fndecl_uid, e->src->index,
fndecl_uid, e->dest->index,
funcdef_no, e->src->index,
funcdef_no, e->dest->index,
style, color, weight,
(e->flags & (EDGE_FAKE | EDGE_DFS_BACK)) ? "false" : "true");
}
@ -192,10 +166,10 @@ draw_cfg_node_succ_edges (pretty_printer *pp, int fndecl_uid, basic_block bb)
/* Print a graphical representation of the CFG of function FUN. */
void
print_graph_cfg (const char *base, tree fndecl)
print_graph_cfg (const char *base, struct function *fun)
{
const char *funcname = fndecl_name (fndecl);
int fndecl_uid = DECL_UID (fndecl);
const char *funcname = function_name (fun);
int funcdef_no = fun->funcdef_no;
FILE *fp = open_graph_file (base, "a");
int *rpo = XNEWVEC (int, n_basic_blocks);
basic_block bb;
@ -212,7 +186,7 @@ print_graph_cfg (const char *base, tree fndecl)
of the nodes. */
n = pre_and_rev_post_order_compute (NULL, rpo, true);
for (i = 0; i < n; i++)
draw_cfg_node (pp, fndecl_uid, BASIC_BLOCK (rpo[i]));
draw_cfg_node (pp, funcdef_no, BASIC_BLOCK (rpo[i]));
/* Draw all edges at the end to get subgraphs right for GraphViz,
which requires nodes to be defined before edges to cluster
@ -224,7 +198,7 @@ print_graph_cfg (const char *base, tree fndecl)
for ourselves is also not desirable.) */
mark_dfs_back_edges ();
FOR_ALL_BB (bb)
draw_cfg_node_succ_edges (pp, fndecl_uid, bb);
draw_cfg_node_succ_edges (pp, funcdef_no, bb);
pp_printf (pp, "\t}\n");
pp_flush (pp);

View File

@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see
#ifndef GCC_GRAPH_H
#define GCC_GRAPH_H
extern void print_graph_cfg (const char *, tree);
extern void print_graph_cfg (const char *, struct function *);
extern void clean_graph_dump_file (const char *);
extern void finish_graph_dump_file (const char *);

View File

@ -1770,7 +1770,7 @@ execute_function_dump (void *data ATTRIBUTE_UNUSED)
if ((cfun->curr_properties & PROP_cfg)
&& (dump_flags & TDF_GRAPH))
print_graph_cfg (dump_file_name, cfun->decl);
print_graph_cfg (dump_file_name, cfun);
}
}

View File

@ -2606,7 +2606,7 @@ extern void dump_rtl_slim (FILE *, const_rtx, const_rtx, int, int);
extern void print_value (pretty_printer *, const_rtx, int);
extern void print_pattern (pretty_printer *, const_rtx, int);
extern void print_insn (pretty_printer *, const_rtx, int);
extern void print_insn_with_notes (pretty_printer *, const_rtx);
extern void rtl_dump_bb_for_graph (pretty_printer *, basic_block);
extern const char *str_pattern_slim (const_rtx);
/* In function.c */

View File

@ -716,10 +716,10 @@ print_insn (pretty_printer *pp, const_rtx x, int verbose)
}
} /* print_insn */
/* Prerry-print a slim dump of X (an insn) to PP, including any register
/* Pretty-print a slim dump of X (an insn) to PP, including any register
note attached to the instruction. */
void
static void
print_insn_with_notes (pretty_printer *pp, const_rtx x)
{
pp_string (pp, print_rtx_head);
@ -728,9 +728,9 @@ print_insn_with_notes (pretty_printer *pp, const_rtx x)
if (INSN_P (x) && REG_NOTES (x))
for (rtx note = REG_NOTES (x); note; note = XEXP (note, 1))
{
pp_printf (pp, "%s %s", print_rtx_head,
pp_printf (pp, "%s %s ", print_rtx_head,
GET_REG_NOTE_NAME (REG_NOTE_KIND (note)));
print_pattern (pp, XEXP (note, 0), 1);
print_pattern (pp, XEXP (note, 0), 1);
pp_newline (pp);
}
}
@ -800,6 +800,29 @@ dump_rtl_slim (FILE *f, const_rtx first, const_rtx last,
pp_flush (pp);
}
/* Dumps basic block BB to pretty-printer PP in slim form and without and
no indentation, for use as a label of a DOT graph record-node. */
void
rtl_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
{
rtx insn;
bool first = true;
/* TODO: inter-bb stuff. */
FOR_BB_INSNS (bb, insn)
{
if (! first)
{
pp_character (pp, '|');
pp_write_text_to_stream (pp);
}
first = false;
print_insn_with_notes (pp, insn);
pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
}
}
/* Pretty-print pattern X of some insn in non-verbose mode.
Return a string pointer to the pretty-printer buffer.

View File

@ -7620,6 +7620,7 @@ struct cfg_hooks gimple_cfg_hooks = {
"gimple",
gimple_verify_flow_info,
gimple_dump_bb, /* dump_bb */
gimple_dump_bb_for_graph, /* dump_bb_for_graph */
create_bb, /* create_basic_block */
gimple_redirect_edge_and_branch, /* redirect_edge_and_branch */
gimple_redirect_edge_and_branch_force, /* redirect_edge_and_branch_force */