diff options
author | Steven Bosscher <steven@gcc.gnu.org> | 2012-11-30 09:46:02 +0000 |
---|---|---|
committer | Steven Bosscher <steven@gcc.gnu.org> | 2012-11-30 09:46:02 +0000 |
commit | 7eba871a24b6e6fa5483531abaf8a1be8a88c0a4 (patch) | |
tree | 4b15801bec76c3248ce31b82175d9ddd088a20d7 /gcc/pretty-print.c | |
parent | 7a36dc06de2219590b17a8a06d0d4cac9bbadd7f (diff) | |
download | gcc-7eba871a24b6e6fa5483531abaf8a1be8a88c0a4.tar.gz |
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
Diffstat (limited to 'gcc/pretty-print.c')
-rw-r--r-- | gcc/pretty-print.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c index c1282c78a9e..198e0425b9b 100644 --- a/gcc/pretty-print.c +++ b/gcc/pretty-print.c @@ -99,6 +99,58 @@ pp_write_text_to_stream (pretty_printer *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. */ static void pp_wrap_text (pretty_printer *pp, const char *start, const char *end) |