diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 1998-11-23 16:41:12 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 1998-11-23 16:41:12 +0000 |
commit | 3eaf50a4c7db88c2168171d9d804f64d5bed13d5 (patch) | |
tree | 3f85798dacd6012a8cc02dc68f10cb4cc26f1b8f /gcc/print-rtl.c | |
parent | 8be93a1c4ec38a588aa34164f0f5c4bea75f1906 (diff) | |
download | gcc-3eaf50a4c7db88c2168171d9d804f64d5bed13d5.tar.gz |
Ulrich Drepper <drepper@cygnus.com>
* Makefile.in (OBJS): Add graph.o
(graph.o): New dependency list.
* flags.h: Declare dump_for_graph and define graph_dump_types type.
* print-rtl.c (dump_for_graph): Define new variable.
(print_rtx): Rewrite to allow use in graph dumping functions.
* toplev.c: Declare print_rtl_graph_with_bb, clean_graph_dump_file,
finish_graph_dump_file.
Define graph_dump_format.
(compile_file): If graph dumping is enabled also clear these files.
Finish graph dump files.
(rest_of_compilation): Also dump graph information if enabled.
(main): Recognize -dv to enabled VCG based graph dumping.
* graph.c: New file. Graph dumping functions.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@23813 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/print-rtl.c')
-rw-r--r-- | gcc/print-rtl.c | 97 |
1 files changed, 62 insertions, 35 deletions
diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c index 1a0a16d82a8..234b6e45bf4 100644 --- a/gcc/print-rtl.c +++ b/gcc/print-rtl.c @@ -1,5 +1,5 @@ /* Print RTL for GNU C Compiler. - Copyright (C) 1987, 1988, 1992, 1997 Free Software Foundation, Inc. + Copyright (C) 1987, 1988, 1992, 1997, 1998 Free Software Foundation, Inc. This file is part of GNU CC. @@ -60,13 +60,17 @@ extern char **insn_name_ptr; This must be defined here so that programs like gencodes can be linked. */ int flag_dump_unnumbered = 0; +/* Nonzero if we are dumping graphical description. */ +int dump_for_graph; + /* Print IN_RTX onto OUTFILE. This is the recursive part of printing. */ static void print_rtx (in_rtx) register rtx in_rtx; { - register int i, j; + register int i = 0; + register int j; register char *format_ptr; register int is_insn; @@ -79,39 +83,54 @@ print_rtx (in_rtx) if (in_rtx == 0) { - fprintf (outfile, "(nil)"); + fputs ("(nil)", outfile); sawclose = 1; return; } - /* print name of expression code */ - fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx))); + is_insn = (GET_RTX_CLASS (GET_CODE (in_rtx)) == 'i'); + + /* When printing in VCG format we write INSNs, NOTE, LABEL, and BARRIER + in separate nodes and therefore have to handle them special here. */ + if (dump_for_graph && + (is_insn || GET_CODE (in_rtx) == NOTE || GET_CODE (in_rtx) == CODE_LABEL + || GET_CODE (in_rtx) == BARRIER)) + { + i = 3; + indent = 0; + } + else + { + /* print name of expression code */ + fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx))); - if (in_rtx->in_struct) - fprintf (outfile, "/s"); + if (in_rtx->in_struct) + fputs ("/s", outfile); - if (in_rtx->volatil) - fprintf (outfile, "/v"); + if (in_rtx->volatil) + fputs ("/v", outfile); - if (in_rtx->unchanging) - fprintf (outfile, "/u"); + if (in_rtx->unchanging) + fputs ("/u", outfile); - if (in_rtx->integrated) - fprintf (outfile, "/i"); + if (in_rtx->integrated) + fputs ("/i", outfile); - if (GET_MODE (in_rtx) != VOIDmode) - { - /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */ - if (GET_CODE (in_rtx) == EXPR_LIST || GET_CODE (in_rtx) == INSN_LIST) - fprintf (outfile, ":%s", GET_REG_NOTE_NAME (GET_MODE (in_rtx))); - else - fprintf (outfile, ":%s", GET_MODE_NAME (GET_MODE (in_rtx))); + if (GET_MODE (in_rtx) != VOIDmode) + { + /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */ + if (GET_CODE (in_rtx) == EXPR_LIST || GET_CODE (in_rtx) == INSN_LIST) + fprintf (outfile, ":%s", GET_REG_NOTE_NAME (GET_MODE (in_rtx))); + else + fprintf (outfile, ":%s", GET_MODE_NAME (GET_MODE (in_rtx))); + } } - is_insn = (GET_RTX_CLASS (GET_CODE (in_rtx)) == 'i'); - format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx)); + /* Get the format string and skip the first elements if we have handled + them already. */ + format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx)) + i; - for (i = 0; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++) + for (; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++) switch (*format_ptr++) { case 'S': @@ -141,9 +160,10 @@ print_rtx (in_rtx) } if (XSTR (in_rtx, i) == 0) - fprintf (outfile, " \"\""); + fputs (dump_for_graph ? " \\\"\\\"" : " \"\"", outfile); else - fprintf (outfile, " (\"%s\")", XSTR (in_rtx, i)); + fprintf (outfile, dump_for_graph ? " (\\\"%s\\\")" : " (\"%s\")", + XSTR (in_rtx, i)); sawclose = 1; break; @@ -168,7 +188,7 @@ print_rtx (in_rtx) (spaces + (sizeof spaces - 1 - indent * 2))); sawclose = 0; } - fprintf (outfile, "[ "); + fputs ("[ ", outfile); if (NULL != XVEC (in_rtx, i)) { indent += 2; @@ -184,7 +204,7 @@ print_rtx (in_rtx) fprintf (outfile, "\n%s", (spaces + (sizeof spaces - 1 - indent * 2))); - fprintf (outfile, "] "); + fputs ("] ", outfile); sawclose = 1; indent -= 2; break; @@ -205,7 +225,7 @@ print_rtx (in_rtx) } else if (flag_dump_unnumbered && (is_insn || GET_CODE (in_rtx) == NOTE)) - fprintf (outfile, "#"); + fputc ('#', outfile); else fprintf (outfile, " %d", value); } @@ -230,18 +250,18 @@ print_rtx (in_rtx) if (XEXP (in_rtx, i) != NULL) { if (flag_dump_unnumbered) - fprintf (outfile, "#"); + fputc ('#', outfile); else fprintf (outfile, " %d", INSN_UID (XEXP (in_rtx, i))); } else - fprintf (outfile, " 0"); + fputs (" 0", outfile); sawclose = 0; break; case 'b': if (XBITMAP (in_rtx, i) == NULL) - fprintf (outfile, " {null}"); + fputs (" {null}", outfile); else bitmap_print (outfile, XBITMAP (in_rtx, i), " {", "}"); sawclose = 0; @@ -253,7 +273,7 @@ print_rtx (in_rtx) break; case '*': - fprintf (outfile, " Unknown"); + fputs (" Unknown", outfile); sawclose = 0; break; @@ -276,8 +296,15 @@ print_rtx (in_rtx) } #endif - fprintf (outfile, ")"); - sawclose = 1; + if (dump_for_graph + && (is_insn || GET_CODE (in_rtx) == NOTE + || GET_CODE (in_rtx) == CODE_LABEL || GET_CODE (in_rtx) == BARRIER)) + sawclose = 0; + else + { + fputc (')', outfile); + sawclose = 1; + } } /* Print an rtx on the current line of FILE. Initially indent IND @@ -386,7 +413,7 @@ print_rtl (outf, rtx_first) sawclose = 0; if (rtx_first == 0) - fprintf (outf, "(nil)\n"); + fputs ("(nil)\n", outf); else switch (GET_CODE (rtx_first)) { |