Commit 7eba871a by Steven Bosscher

coretypes.h (struct pretty_print_info): Make a coretype.

	* coretypes.h (struct pretty_print_info): Make a coretype.
	(typedef pretty_printer): Likewise.
	* pretty-print.h (typedef pretty_printer): Not needed here anymore.
	* pretty-print.c (pp_write_text_as_dot_label_to_stream): New function.
	* rtl.h (str_pattern_slim): New prototype.
	(print_value, print_pattern, print_insn): Adjust prototypes to take
	a pretty-printer rather than a char buffer.
	* sched-vis.c (safe_concat): Remove.
	(print_exp): Print into a pretty-printer.
	(print_value): Likewise.
	(print_pattern): Likewise.
	(print_insn): Likewise.
	(print_insn_with_notes): New static function.
	(init_rtl_slim_pretty_print): New function.
	(dump_value_slim): Simplify.  Print into and flush a pretty-printer.
	(dump_insn_slim): Likewise.
	(dump_rtl_slim): Likewise.
	(str_pattern_slim): New function.
	* haifa-sched.c (model_recompute): Use str_pattern_slim instead of
	static buffers.
	(model_record_pressures): Likewise.
	(schedule_insn): Likewise.
	* sel-sched-dump.c (dump_insn_rtx_1): Likewise.
	(sel_prepare_string_for_dot_label): Refer to graph.c CFG dumper code.
	* graph.c: Include pretty-print.h.
	(init_graph_slim_pretty_print): New function.
	(print_escaped_line): Removed here, and reincarnated as
	pp_write_text_as_dot_label_to_stream.
	(draw_cfg_node): Print into a pretty printer.
	(draw_cfg_node_succ_edges): Likewise.
	(print_rtl_graph_with_bb): Likewise.
	* Makefile.in (graph.o): Fix dependencies.
	(tree-optimize.o, toplev.o, sched-vis.o): Likewise.

From-SVN: r193990
parent 7a36dc06
2012-11-30 Steven Bosscher <steven@gcc.gnu.org>
* coretypes.h (struct pretty_print_info): Make a coretype.
(typedef pretty_printer): Likewise.
* pretty-print.h (typedef pretty_printer): Not needed here anymore.
* pretty-print.c (pp_write_text_as_dot_label_to_stream): New function.
* rtl.h (str_pattern_slim): New prototype.
(print_value, print_pattern, print_insn): Adjust prototypes to take
a pretty-printer rather than a char buffer.
* sched-vis.c (safe_concat): Remove.
(print_exp): Print into a pretty-printer.
(print_value): Likewise.
(print_pattern): Likewise.
(print_insn): Likewise.
(print_insn_with_notes): New static function.
(init_rtl_slim_pretty_print): New function.
(dump_value_slim): Simplify. Print into and flush a pretty-printer.
(dump_insn_slim): Likewise.
(dump_rtl_slim): Likewise.
(str_pattern_slim): New function.
* haifa-sched.c (model_recompute): Use str_pattern_slim instead of
static buffers.
(model_record_pressures): Likewise.
(schedule_insn): Likewise.
* sel-sched-dump.c (dump_insn_rtx_1): Likewise.
(sel_prepare_string_for_dot_label): Refer to graph.c CFG dumper code.
* graph.c: Include pretty-print.h.
(init_graph_slim_pretty_print): New function.
(print_escaped_line): Removed here, and reincarnated as
pp_write_text_as_dot_label_to_stream.
(draw_cfg_node): Print into a pretty printer.
(draw_cfg_node_succ_edges): Likewise.
(print_rtl_graph_with_bb): Likewise.
* Makefile.in (graph.o): Fix dependencies.
(tree-optimize.o, toplev.o, sched-vis.o): Likewise.
2012-11-30 Jakub Jelinek <jakub@redhat.com> 2012-11-30 Jakub Jelinek <jakub@redhat.com>
* tsan.c (is_load_of_const_p): Removed. * tsan.c (is_load_of_const_p): Removed.
...@@ -1845,9 +1845,8 @@ srcextra: gcc.srcextra lang.srcextra ...@@ -1845,9 +1845,8 @@ srcextra: gcc.srcextra lang.srcextra
gcc.srcextra: gengtype-lex.c gcc.srcextra: gengtype-lex.c
-cp -p $^ $(srcdir) -cp -p $^ $(srcdir)
graph.o: graph.c $(SYSTEM_H) coretypes.h $(TM_H) toplev.h $(DIAGNOSTIC_CORE_H) $(FLAGS_H) \ graph.o: graph.c graph.h $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(RTL_H) $(FUNCTION_H) hard-reg-set.h $(BASIC_BLOCK_H) graph.h $(OBSTACK_H) \ $(DIAGNOSTIC_CORE_H) $(TM_H) $(RTL_H) $(BASIC_BLOCK_H) $(PRETTY_PRINT_H)
$(CONFIG_H) $(EMIT_RTL_H)
sbitmap.o: sbitmap.c sbitmap.h $(CONFIG_H) $(SYSTEM_H) coretypes.h sbitmap.o: sbitmap.c sbitmap.h $(CONFIG_H) $(SYSTEM_H) coretypes.h
sparseset.o: sparseset.c $(SYSTEM_H) sparseset.h $(CONFIG_H) sparseset.o: sparseset.c $(SYSTEM_H) sparseset.h $(CONFIG_H)
...@@ -2509,7 +2508,7 @@ tree-optimize.o : tree-optimize.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \ ...@@ -2509,7 +2508,7 @@ tree-optimize.o : tree-optimize.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(DIAGNOSTIC_H) $(BASIC_BLOCK_H) $(FLAGS_H) $(TM_H) \ $(DIAGNOSTIC_H) $(BASIC_BLOCK_H) $(FLAGS_H) $(TM_H) \
coretypes.h toplev.h $(DIAGNOSTIC_CORE_H) $(FUNCTION_H) langhooks.h \ coretypes.h toplev.h $(DIAGNOSTIC_CORE_H) $(FUNCTION_H) langhooks.h \
$(FLAGS_H) $(CGRAPH_H) $(PLUGIN_H) \ $(FLAGS_H) $(CGRAPH_H) $(PLUGIN_H) \
$(TREE_INLINE_H) $(GGC_H) graph.h $(CGRAPH_H) \ $(TREE_INLINE_H) $(GGC_H) $(CGRAPH_H) \
$(TREE_PASS_H) $(CFGLOOP_H) $(EXCEPT_H) $(TREE_PASS_H) $(CFGLOOP_H) $(EXCEPT_H)
gimplify.o : gimplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(GIMPLE_H) \ gimplify.o : gimplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(GIMPLE_H) \
...@@ -2691,7 +2690,7 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ ...@@ -2691,7 +2690,7 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
version.h $(RTL_H) $(FUNCTION_H) $(FLAGS_H) xcoffout.h $(INPUT_H) \ version.h $(RTL_H) $(FUNCTION_H) $(FLAGS_H) xcoffout.h $(INPUT_H) \
$(INSN_ATTR_H) output.h $(DIAGNOSTIC_H) debug.h insn-config.h intl.h \ $(INSN_ATTR_H) output.h $(DIAGNOSTIC_H) debug.h insn-config.h intl.h \
$(RECOG_H) Makefile toplev.h sdbout.h dbxout.h $(EXPR_H) \ $(RECOG_H) Makefile toplev.h sdbout.h dbxout.h $(EXPR_H) \
hard-reg-set.h $(BASIC_BLOCK_H) graph.h $(EXCEPT_H) $(REGS_H) $(TIMEVAR_H) \ hard-reg-set.h $(BASIC_BLOCK_H) $(EXCEPT_H) $(REGS_H) $(TIMEVAR_H) \
value-prof.h $(PARAMS_H) $(TM_P_H) reload.h ira.h dwarf2asm.h $(TARGET_H) \ value-prof.h $(PARAMS_H) $(TM_P_H) reload.h ira.h dwarf2asm.h $(TARGET_H) \
langhooks.h insn-flags.h $(CFGLOOP_H) hosthooks.h \ langhooks.h insn-flags.h $(CFGLOOP_H) hosthooks.h \
$(CGRAPH_H) $(COVERAGE_H) alloc-pool.h $(GGC_H) \ $(CGRAPH_H) $(COVERAGE_H) alloc-pool.h $(GGC_H) \
...@@ -3333,8 +3332,7 @@ sched-ebb.o : sched-ebb.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ ...@@ -3333,8 +3332,7 @@ sched-ebb.o : sched-ebb.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(FUNCTION_H) $(INSN_ATTR_H) $(DIAGNOSTIC_CORE_H) $(RECOG_H) $(EXCEPT_H) $(TM_P_H) \ $(FUNCTION_H) $(INSN_ATTR_H) $(DIAGNOSTIC_CORE_H) $(RECOG_H) $(EXCEPT_H) $(TM_P_H) \
$(PARAMS_H) $(TARGET_H) $(PARAMS_H) $(TARGET_H)
sched-vis.o : sched-vis.c $(CONFIG_H) $(SYSTEM_H) coretypes.h dumpfile.h $(TM_H) \ sched-vis.o : sched-vis.c $(CONFIG_H) $(SYSTEM_H) coretypes.h dumpfile.h $(TM_H) \
$(RTL_H) $(SCHED_INT_H) hard-reg-set.h $(BASIC_BLOCK_H) $(OBSTACK_H) \ $(INSN_ATTR_H) $(RTL_H) $(TREE_H) $(BASIC_BLOCK_H) $(PRETTY_PRINT_H)
$(INSN_ATTR_H) $(TREE_H)
sel-sched.o : sel-sched.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ sel-sched.o : sel-sched.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(RTL_ERROR_H) $(REGS_H) hard-reg-set.h $(FLAGS_H) insn-config.h \ $(RTL_ERROR_H) $(REGS_H) hard-reg-set.h $(FLAGS_H) insn-config.h \
$(FUNCTION_H) $(INSN_ATTR_H) $(RECOG_H) $(EXCEPT_H) $(PARAMS_H) \ $(FUNCTION_H) $(INSN_ATTR_H) $(RECOG_H) $(EXCEPT_H) $(PARAMS_H) \
......
...@@ -58,10 +58,11 @@ typedef struct rtvec_def *rtvec; ...@@ -58,10 +58,11 @@ typedef struct rtvec_def *rtvec;
typedef const struct rtvec_def *const_rtvec; typedef const struct rtvec_def *const_rtvec;
union tree_node; union tree_node;
typedef union tree_node *tree; typedef union tree_node *tree;
typedef const union tree_node *const_tree;
union gimple_statement_d; union gimple_statement_d;
typedef union gimple_statement_d *gimple; typedef union gimple_statement_d *gimple;
typedef const union tree_node *const_tree;
typedef const union gimple_statement_d *const_gimple; typedef const union gimple_statement_d *const_gimple;
typedef gimple gimple_seq;
union section; union section;
typedef union section section; typedef union section section;
struct gcc_options; struct gcc_options;
...@@ -72,7 +73,8 @@ struct cl_decoded_option; ...@@ -72,7 +73,8 @@ struct cl_decoded_option;
struct cl_option_handlers; struct cl_option_handlers;
struct diagnostic_context; struct diagnostic_context;
typedef struct diagnostic_context diagnostic_context; typedef struct diagnostic_context diagnostic_context;
typedef gimple gimple_seq; struct pretty_print_info;
typedef struct pretty_print_info pretty_printer;
/* Address space number for named address space support. */ /* Address space number for named address space support. */
typedef unsigned char addr_space_t; typedef unsigned char addr_space_t;
......
...@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see
#include "rtl.h" #include "rtl.h"
#include "tree.h" #include "tree.h"
#include "graph.h" #include "graph.h"
#include "pretty-print.h"
/* DOT files with the .dot extension are recognized as document templates /* DOT files with the .dot extension are recognized as document templates
by a well-known piece of word processing software out of Redmond, WA. by a well-known piece of word processing software out of Redmond, WA.
...@@ -56,45 +57,30 @@ open_graph_file (const char *base, const char *mode) ...@@ -56,45 +57,30 @@ open_graph_file (const char *base, const char *mode)
return fp; return fp;
} }
/* Print the output from print_insn or print_pattern with GraphViz-special /* Return a pretty-print buffer for output to file FP. */
characters escaped as necessary. */
void static pretty_printer *
print_escaped_line (FILE *fp, const char *buf) init_graph_slim_pretty_print (FILE *fp)
{ {
const char *p = buf; static bool initialized = false;
static pretty_printer graph_slim_pp;
while (*p) if (! initialized)
{ {
switch (*p) pp_construct (&graph_slim_pp, /*prefix=*/NULL, /*linewidth=*/0);
{ initialized = true;
case '\n':
/* Print newlines as a left-aligned newline. */
fputs ("\\l\\\n", fp);
break;
case '{':
case '}':
case '<':
case '>':
case '|':
case '"':
case ' ':
/* These characters have to be escaped to work with record-shape nodes. */
fputc ('\\', fp);
/* fall through */
default:
fputc (*p, fp);
break;
}
p++;
} }
fputs ("\\l\\\n", fp); else
gcc_assert (! pp_last_position_in_text (&graph_slim_pp));
graph_slim_pp.buffer->stream = 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 FNDECL_UID
as its unique number. */ as its unique number. */
static void static void
draw_cfg_node (FILE *fp, int fndecl_uid, basic_block bb) draw_cfg_node (pretty_printer *pp, int fndecl_uid, basic_block bb)
{ {
rtx insn; rtx insn;
bool first = true; bool first = true;
...@@ -115,48 +101,53 @@ draw_cfg_node (FILE *fp, int fndecl_uid, basic_block bb) ...@@ -115,48 +101,53 @@ draw_cfg_node (FILE *fp, int fndecl_uid, basic_block bb)
: "lightgrey"; : "lightgrey";
} }
fprintf (fp, pp_printf (pp,
"\tfn_%d_basic_block_%d [shape=%s,style=filled,fillcolor=%s,label=\"", "\tfn_%d_basic_block_%d "
fndecl_uid, bb->index, shape, fillcolor); "[shape=%s,style=filled,fillcolor=%s,label=\"",
fndecl_uid, bb->index, shape, fillcolor);
if (bb->index == ENTRY_BLOCK) if (bb->index == ENTRY_BLOCK)
fputs ("ENTRY", fp); pp_string (pp, "ENTRY");
else if (bb->index == EXIT_BLOCK) else if (bb->index == EXIT_BLOCK)
fputs ("EXIT", fp); pp_string (pp, "EXIT");
else else
{ {
fputc ('{', fp); pp_character (pp, '{');
pp_write_text_to_stream (pp);
/* TODO: inter-bb stuff. */ /* TODO: inter-bb stuff. */
FOR_BB_INSNS (bb, insn) FOR_BB_INSNS (bb, insn)
{ {
char buf[2048];
if (! first) if (! first)
fputc ('|', fp); {
pp_character (pp, '|');
pp_write_text_to_stream (pp);
}
first = false;
print_insn (buf, insn, 1); print_insn (pp, insn, 1);
print_escaped_line (fp, buf); pp_newline (pp);
if (INSN_P (insn) && REG_NOTES (insn)) if (INSN_P (insn) && REG_NOTES (insn))
for (rtx note = REG_NOTES (insn); note; note = XEXP (note, 1)) for (rtx note = REG_NOTES (insn); note; note = XEXP (note, 1))
{ {
fprintf (fp, " %s: ", pp_printf (pp, " %s: ",
GET_REG_NOTE_NAME (REG_NOTE_KIND (note))); GET_REG_NOTE_NAME (REG_NOTE_KIND (note)));
print_pattern (buf, XEXP (note, 0), 1); print_pattern (pp, XEXP (note, 0), 1);
print_escaped_line (fp, buf); pp_newline (pp);
} }
pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
first = false;
} }
fputc ('}', fp); pp_character (pp, '}');
} }
fputs ("\"];\n\n", fp); pp_string (pp, "\"];\n\n");
pp_flush (pp);
} }
/* Draw all successor edges of a basic block BB belonging to the function /* Draw all successor edges of a basic block BB belonging to the function
with FNDECL_UID as its unique number. */ with FNDECL_UID as its unique number. */
static void static void
draw_cfg_node_succ_edges (FILE *fp, int fndecl_uid, basic_block bb) draw_cfg_node_succ_edges (pretty_printer *pp, int fndecl_uid, basic_block bb)
{ {
edge e; edge e;
edge_iterator ei; edge_iterator ei;
...@@ -187,14 +178,15 @@ draw_cfg_node_succ_edges (FILE *fp, int fndecl_uid, basic_block bb) ...@@ -187,14 +178,15 @@ draw_cfg_node_succ_edges (FILE *fp, int fndecl_uid, basic_block bb)
if (e->flags & EDGE_ABNORMAL) if (e->flags & EDGE_ABNORMAL)
color = "red"; color = "red";
fprintf (fp, pp_printf (pp,
"\tfn_%d_basic_block_%d:s -> fn_%d_basic_block_%d:n " "\tfn_%d_basic_block_%d:s -> fn_%d_basic_block_%d:n "
"[style=%s,color=%s,weight=%d,constraint=%s];\n", "[style=%s,color=%s,weight=%d,constraint=%s];\n",
fndecl_uid, e->src->index, fndecl_uid, e->src->index,
fndecl_uid, e->dest->index, fndecl_uid, e->dest->index,
style, color, weight, style, color, weight,
(e->flags & (EDGE_FAKE | EDGE_DFS_BACK)) ? "false" : "true"); (e->flags & (EDGE_FAKE | EDGE_DFS_BACK)) ? "false" : "true");
} }
pp_flush (pp);
} }
/* Print a graphical representation of the CFG of function FUN. /* Print a graphical representation of the CFG of function FUN.
...@@ -208,19 +200,19 @@ print_rtl_graph_with_bb (const char *base, tree fndecl) ...@@ -208,19 +200,19 @@ print_rtl_graph_with_bb (const char *base, tree fndecl)
int *rpo = XNEWVEC (int, n_basic_blocks); int *rpo = XNEWVEC (int, n_basic_blocks);
basic_block bb; basic_block bb;
int i, n; int i, n;
pretty_printer *pp = init_graph_slim_pretty_print (fp);
fprintf (fp, pp_printf (pp, "subgraph \"%s\" {\n"
"subgraph \"%s\" {\n" "\tcolor=\"black\";\n"
"\tcolor=\"black\";\n" "\tlabel=\"%s\";\n",
"\tlabel=\"%s\";\n", funcname, funcname);
funcname, funcname);
/* First print all basic blocks. /* First print all basic blocks.
Visit the blocks in reverse post order to get a good ranking Visit the blocks in reverse post order to get a good ranking
of the nodes. */ of the nodes. */
n = pre_and_rev_post_order_compute (NULL, rpo, true); n = pre_and_rev_post_order_compute (NULL, rpo, true);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
draw_cfg_node (fp, fndecl_uid, BASIC_BLOCK (rpo[i])); draw_cfg_node (pp, fndecl_uid, BASIC_BLOCK (rpo[i]));
/* Draw all edges at the end to get subgraphs right for GraphViz, /* Draw all edges at the end to get subgraphs right for GraphViz,
which requires nodes to be defined before edges to cluster which requires nodes to be defined before edges to cluster
...@@ -232,10 +224,10 @@ print_rtl_graph_with_bb (const char *base, tree fndecl) ...@@ -232,10 +224,10 @@ print_rtl_graph_with_bb (const char *base, tree fndecl)
for ourselves is also not desirable.) */ for ourselves is also not desirable.) */
mark_dfs_back_edges (); mark_dfs_back_edges ();
FOR_ALL_BB (bb) FOR_ALL_BB (bb)
draw_cfg_node_succ_edges (fp, fndecl_uid, bb); draw_cfg_node_succ_edges (pp, fndecl_uid, bb);
fputs ("\t}\n", fp);
pp_printf (pp, "\t}\n");
pp_flush (pp);
fclose (fp); fclose (fp);
} }
......
...@@ -2168,8 +2168,6 @@ model_recompute (rtx insn) ...@@ -2168,8 +2168,6 @@ model_recompute (rtx insn)
if (sched_verbose >= 5) if (sched_verbose >= 5)
{ {
char buf[2048];
if (!print_p) if (!print_p)
{ {
fprintf (sched_dump, MODEL_BAR); fprintf (sched_dump, MODEL_BAR);
...@@ -2179,9 +2177,9 @@ model_recompute (rtx insn) ...@@ -2179,9 +2177,9 @@ model_recompute (rtx insn)
print_p = true; print_p = true;
} }
print_pattern (buf, PATTERN (insn), 0);
fprintf (sched_dump, ";;\t\t| %3d %4d %-30s ", fprintf (sched_dump, ";;\t\t| %3d %4d %-30s ",
point, INSN_UID (insn), buf); point, INSN_UID (insn),
str_pattern_slim (PATTERN (insn)));
for (pci = 0; pci < ira_pressure_classes_num; pci++) for (pci = 0; pci < ira_pressure_classes_num; pci++)
{ {
cl = ira_pressure_classes[pci]; cl = ira_pressure_classes[pci];
...@@ -3343,18 +3341,16 @@ model_record_pressures (struct model_insn_info *insn) ...@@ -3343,18 +3341,16 @@ model_record_pressures (struct model_insn_info *insn)
point = model_index (insn->insn); point = model_index (insn->insn);
if (sched_verbose >= 2) if (sched_verbose >= 2)
{ {
char buf[2048];
if (point == 0) if (point == 0)
{ {
fprintf (sched_dump, "\n;;\tModel schedule:\n;;\n"); fprintf (sched_dump, "\n;;\tModel schedule:\n;;\n");
fprintf (sched_dump, ";;\t| idx insn | mpri hght dpth prio |\n"); fprintf (sched_dump, ";;\t| idx insn | mpri hght dpth prio |\n");
} }
print_pattern (buf, PATTERN (insn->insn), 0);
fprintf (sched_dump, ";;\t| %3d %4d | %4d %4d %4d %4d | %-30s ", fprintf (sched_dump, ";;\t| %3d %4d | %4d %4d %4d %4d | %-30s ",
point, INSN_UID (insn->insn), insn->model_priority, point, INSN_UID (insn->insn), insn->model_priority,
insn->depth + insn->alap, insn->depth, insn->depth + insn->alap, insn->depth,
INSN_PRIORITY (insn->insn), buf); INSN_PRIORITY (insn->insn),
str_pattern_slim (PATTERN (insn->insn)));
} }
calculate_reg_deaths (insn->insn, death); calculate_reg_deaths (insn->insn, death);
reg_pressure = INSN_REG_PRESSURE (insn->insn); reg_pressure = INSN_REG_PRESSURE (insn->insn);
...@@ -3715,12 +3711,9 @@ schedule_insn (rtx insn) ...@@ -3715,12 +3711,9 @@ schedule_insn (rtx insn)
if (sched_verbose >= 1) if (sched_verbose >= 1)
{ {
struct reg_pressure_data *pressure_info; struct reg_pressure_data *pressure_info;
char buf[2048];
print_insn (buf, insn, 0);
buf[40] = 0;
fprintf (sched_dump, ";;\t%3i--> %s%-40s:", fprintf (sched_dump, ";;\t%3i--> %s%-40s:",
clock_var, (*current_sched_info->print_insn) (insn, 1), buf); clock_var, (*current_sched_info->print_insn) (insn, 1),
str_pattern_slim (PATTERN (insn)));
if (recog_memoized (insn) < 0) if (recog_memoized (insn) < 0)
fprintf (sched_dump, "nothing"); fprintf (sched_dump, "nothing");
......
...@@ -99,6 +99,58 @@ pp_write_text_to_stream (pretty_printer *pp) ...@@ -99,6 +99,58 @@ pp_write_text_to_stream (pretty_printer *pp)
pp_clear_output_area (pp); pp_clear_output_area (pp);
} }
/* As pp_write_text_to_stream, but for GraphViz label output.
Flush the formatted text of pretty-printer PP onto the attached stream.
Replace characters in PPF that have special meaning in a GraphViz .dot
file.
This routine is not very fast, but it doesn't have to be as this is only
be used by routines dumping intermediate representations in graph form. */
void
pp_write_text_as_dot_label_to_stream (pretty_printer *pp, bool for_record)
{
const char *text = pp_formatted_text (pp);
const char *p = text;
FILE *fp = pp->buffer->stream;
while (*p)
{
switch (*p)
{
/* Print newlines as a left-aligned newline. */
case '\n':
fputs ("\\l\\\n", fp);
break;
/* A pipe is only special for record-shape nodes. */
case '|':
if (for_record)
fputc ('\\', fp);
fputc (*p, fp);
break;
/* The following characters always have to be escaped
for use in labels. */
case '{':
case '}':
case '<':
case '>':
case '"':
case ' ':
fputc ('\\', fp);
/* fall through */
default:
fputc (*p, fp);
break;
}
p++;
}
pp_clear_output_area (pp);
}
/* Wrap a text delimited by START and END into PRETTY-PRINTER. */ /* Wrap a text delimited by START and END into PRETTY-PRINTER. */
static void static void
pp_wrap_text (pretty_printer *pp, const char *start, const char *end) pp_wrap_text (pretty_printer *pp, const char *start, const char *end)
......
...@@ -132,7 +132,6 @@ typedef struct ...@@ -132,7 +132,6 @@ typedef struct
/* The type of a hook that formats client-specific data onto a pretty_pinter. /* The type of a hook that formats client-specific data onto a pretty_pinter.
A client-supplied formatter returns true if everything goes well, A client-supplied formatter returns true if everything goes well,
otherwise it returns false. */ otherwise it returns false. */
typedef struct pretty_print_info pretty_printer;
typedef bool (*printer_fn) (pretty_printer *, text_info *, const char *, typedef bool (*printer_fn) (pretty_printer *, text_info *, const char *,
int, bool, bool, bool); int, bool, bool, bool);
...@@ -343,7 +342,8 @@ extern void pp_base_indent (pretty_printer *); ...@@ -343,7 +342,8 @@ extern void pp_base_indent (pretty_printer *);
extern void pp_base_newline (pretty_printer *); extern void pp_base_newline (pretty_printer *);
extern void pp_base_character (pretty_printer *, int); extern void pp_base_character (pretty_printer *, int);
extern void pp_base_string (pretty_printer *, const char *); extern void pp_base_string (pretty_printer *, const char *);
extern void pp_write_text_to_stream (pretty_printer *pp); extern void pp_write_text_to_stream (pretty_printer *);
extern void pp_write_text_as_dot_label_to_stream (pretty_printer *, bool);
extern void pp_base_maybe_space (pretty_printer *); extern void pp_base_maybe_space (pretty_printer *);
/* Switch into verbatim mode and return the old mode. */ /* Switch into verbatim mode and return the old mode. */
......
...@@ -2597,16 +2597,16 @@ extern int print_rtl_single (FILE *, const_rtx); ...@@ -2597,16 +2597,16 @@ extern int print_rtl_single (FILE *, const_rtx);
extern int print_rtl_single_with_indent (FILE *, const_rtx, int); extern int print_rtl_single_with_indent (FILE *, const_rtx, int);
extern void print_inline_rtx (FILE *, const_rtx, int); extern void print_inline_rtx (FILE *, const_rtx, int);
/* Functions in sched-vis.c. These must be outside INSN_SCHEDULING as /* Functions in sched-vis.c. FIXME: Ideally these functions would
sched-vis.c is compiled always. FIXME: Ideally these functions would
not be in sched-vis.c but in rtl.c, because they are not only used not be in sched-vis.c but in rtl.c, because they are not only used
by the scheduler anymore but for all "slim" RTL dumping. */ by the scheduler anymore but for all "slim" RTL dumping. */
extern void dump_value_slim (FILE *, const_rtx, int); extern void dump_value_slim (FILE *, const_rtx, int);
extern void dump_insn_slim (FILE *, const_rtx); extern void dump_insn_slim (FILE *, const_rtx);
extern void dump_rtl_slim (FILE *, const_rtx, const_rtx, int, int); extern void dump_rtl_slim (FILE *, const_rtx, const_rtx, int, int);
extern void print_value (char *, const_rtx, int); extern void print_value (pretty_printer *, const_rtx, int);
extern void print_pattern (char *, const_rtx, int); extern void print_pattern (pretty_printer *, const_rtx, int);
extern void print_insn (char *, const_rtx, int); extern void print_insn (pretty_printer *, const_rtx, int);
extern const char *str_pattern_slim (const_rtx);
/* In function.c */ /* In function.c */
extern void reposition_prologue_and_epilogue_notes (void); extern void reposition_prologue_and_epilogue_notes (void);
......
...@@ -136,12 +136,7 @@ dump_insn_rtx_1 (rtx insn, int flags) ...@@ -136,12 +136,7 @@ dump_insn_rtx_1 (rtx insn, int flags)
sel_print ("%d;", INSN_UID (insn)); sel_print ("%d;", INSN_UID (insn));
if (flags & DUMP_INSN_RTX_PATTERN) if (flags & DUMP_INSN_RTX_PATTERN)
{ sel_print ("%s;", str_pattern_slim (insn));
char buf[2048];
print_insn (buf, insn, 0);
sel_print ("%s;", buf);
}
if (flags & DUMP_INSN_RTX_BBN) if (flags & DUMP_INSN_RTX_BBN)
{ {
...@@ -522,6 +517,7 @@ sel_print_insn (const_rtx insn, int aligned ATTRIBUTE_UNUSED) ...@@ -522,6 +517,7 @@ sel_print_insn (const_rtx insn, int aligned ATTRIBUTE_UNUSED)
/* Functions for pretty printing of CFG. */ /* Functions for pretty printing of CFG. */
/* FIXME: Using pretty-print here could simplify this stuff. */
/* Replace all occurencies of STR1 to STR2 in BUF. /* Replace all occurencies of STR1 to STR2 in BUF.
The BUF must be large enough to hold the result. */ The BUF must be large enough to hold the result. */
...@@ -564,7 +560,8 @@ replace_str_in_buf (char *buf, const char *str1, const char *str2) ...@@ -564,7 +560,8 @@ replace_str_in_buf (char *buf, const char *str1, const char *str2)
while (p); while (p);
} }
/* Replace characters in BUF that have special meaning in .dot file. */ /* Replace characters in BUF that have special meaning in .dot file.
Similar to pp_write_text_as_dot_label_to_stream. */
static void static void
sel_prepare_string_for_dot_label (char *buf) sel_prepare_string_for_dot_label (char *buf)
{ {
......
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