Commit 7810c4eb by David Malcolm Committed by David Malcolm

Add a "compact" mode to print_rtx_function

gcc/ChangeLog:
	* function-tests.c (selftest::test_expansion_to_rtl): Add "true"
	for new "compact" param of print_rtx_function.  Check for "cinsn"
	rather than "insn".
	* print-rtl-function.c (flag_compact): New decl.
	(print_rtx_function): Add param "compact" and use it to set
	flag_compact, adding a description of the effect to the leading
	comment, and updating the example output.
	* print-rtl.c (flag_compact): New variable.
	(print_rtx_operand_code_0): Omit the JUMP_LABEL reference in compact
	mode.
	(print_rtx_operand_code_i): When printing source locations, wrap
	xloc.file in quotes.  Don't print INSN_CODEs in compact mode.
	(print_rtx_operand_code_r): Don't print regnos for hard regs and
	virtuals in compact mode.
	(print_rtx_operand_code_u): Don't print insn UIDs in compact mode,
	apart from in LABEL_REFs.
	(print_rtx_operand): In case 'w', don't print in hex in compact mode.
	Don't print basic block ids in compact mode.
	(print_rtx):  In compact mode, prefix the code of insns with "c",
	only print the INSN_UID of CODE_LABELs, and omit their LABEL_NUSES.
	* print-rtl.h (print_rtx_function): Add "compact" param.

gcc/testsuite/ChangeLog:
	* gcc.target/i386/vararg-loc.c: Update for quoting of xloc.file
	in INSN_LOCATION.

From-SVN: r241120
parent 950e6f41
2016-10-13 David Malcolm <dmalcolm@redhat.com>
* function-tests.c (selftest::test_expansion_to_rtl): Add "true"
for new "compact" param of print_rtx_function. Check for "cinsn"
rather than "insn".
* print-rtl-function.c (flag_compact): New decl.
(print_rtx_function): Add param "compact" and use it to set
flag_compact, adding a description of the effect to the leading
comment, and updating the example output.
* print-rtl.c (flag_compact): New variable.
(print_rtx_operand_code_0): Omit the JUMP_LABEL reference in compact
mode.
(print_rtx_operand_code_i): When printing source locations, wrap
xloc.file in quotes. Don't print INSN_CODEs in compact mode.
(print_rtx_operand_code_r): Don't print regnos for hard regs and
virtuals in compact mode.
(print_rtx_operand_code_u): Don't print insn UIDs in compact mode,
apart from in LABEL_REFs.
(print_rtx_operand): In case 'w', don't print in hex in compact mode.
Don't print basic block ids in compact mode.
(print_rtx): In compact mode, prefix the code of insns with "c",
only print the INSN_UID of CODE_LABELs, and omit their LABEL_NUSES.
* print-rtl.h (print_rtx_function): Add "compact" param.
2016-10-13 Richard Earnshaw <rearnsha@arm.com> 2016-10-13 Richard Earnshaw <rearnsha@arm.com>
* arm.h (TARGET_VFP): Delete. * arm.h (TARGET_VFP): Delete.
......
...@@ -648,7 +648,7 @@ test_expansion_to_rtl () ...@@ -648,7 +648,7 @@ test_expansion_to_rtl ()
/* Verify that print_rtl_function is sane. */ /* Verify that print_rtl_function is sane. */
named_temp_file tmp_out (".rtl"); named_temp_file tmp_out (".rtl");
FILE *outfile = fopen (tmp_out.get_filename (), "w"); FILE *outfile = fopen (tmp_out.get_filename (), "w");
print_rtx_function (outfile, fun); print_rtx_function (outfile, fun, true);
fclose (outfile); fclose (outfile);
char *dump = read_file (SELFTEST_LOCATION, tmp_out.get_filename ()); char *dump = read_file (SELFTEST_LOCATION, tmp_out.get_filename ());
...@@ -656,7 +656,7 @@ test_expansion_to_rtl () ...@@ -656,7 +656,7 @@ test_expansion_to_rtl ()
ASSERT_STR_CONTAINS (dump, " (insn-chain\n"); ASSERT_STR_CONTAINS (dump, " (insn-chain\n");
ASSERT_STR_CONTAINS (dump, " (block 2\n"); ASSERT_STR_CONTAINS (dump, " (block 2\n");
ASSERT_STR_CONTAINS (dump, " (edge-from entry (flags \"FALLTHRU\"))\n"); ASSERT_STR_CONTAINS (dump, " (edge-from entry (flags \"FALLTHRU\"))\n");
ASSERT_STR_CONTAINS (dump, " (insn "); /* ...etc. */ ASSERT_STR_CONTAINS (dump, " (cinsn "); /* ...etc. */
ASSERT_STR_CONTAINS (dump, " (edge-to exit (flags \"FALLTHRU\"))\n"); ASSERT_STR_CONTAINS (dump, " (edge-to exit (flags \"FALLTHRU\"))\n");
ASSERT_STR_CONTAINS (dump, " ) ;; block 2\n"); ASSERT_STR_CONTAINS (dump, " ) ;; block 2\n");
ASSERT_STR_CONTAINS (dump, " ) ;; insn-chain\n"); ASSERT_STR_CONTAINS (dump, " ) ;; insn-chain\n");
......
...@@ -33,6 +33,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -33,6 +33,8 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks.h" #include "langhooks.h"
#include "emit-rtl.h" #include "emit-rtl.h"
extern bool flag_compact;
/* Print an "(edge-from)" or "(edge-to)" directive describing E /* Print an "(edge-from)" or "(edge-to)" directive describing E
to OUTFILE. */ to OUTFILE. */
...@@ -126,55 +128,63 @@ can_have_basic_block_p (const rtx_insn *insn) ...@@ -126,55 +128,63 @@ can_have_basic_block_p (const rtx_insn *insn)
the basic blocks of insns in the chain, wrapping those that are within the basic blocks of insns in the chain, wrapping those that are within
blocks within "(block)" directives. blocks within "(block)" directives.
Example output: If COMPACT, then instructions are printed in a compact form:
- INSN_UIDs are omitted, except for jumps and CODE_LABELs,
- INSN_CODEs are omitted,
- register numbers are omitted for hard and virtual regs
- insn names are prefixed with "c" (e.g. "cinsn", "cnote", etc)
Example output (with COMPACT==true):
(function "times_two" (function "times_two"
(insn-chain (insn-chain
(note 1 0 4 (nil) NOTE_INSN_DELETED) (cnote NOTE_INSN_DELETED)
(block 2 (block 2
(edge-from entry (flags "FALLTHRU")) (edge-from entry (flags "FALLTHRU"))
(note 4 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK) (cnote [bb 2] NOTE_INSN_BASIC_BLOCK)
(insn 2 4 3 2 (set (mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars) (cinsn (set (mem/c:SI (plus:DI (reg/f:DI virtual-stack-vars)
(const_int -4 [0xfffffffffffffffc])) [1 i+0 S4 A32]) (const_int -4)) [1 i+0 S4 A32])
(reg:SI 5 di [ i ])) t.c:2 -1 (reg:SI di [ i ])) "t.c":2
(nil)) (nil))
(note 3 2 6 2 NOTE_INSN_FUNCTION_BEG) (cnote NOTE_INSN_FUNCTION_BEG)
(insn 6 3 7 2 (set (reg:SI 89) (cinsn (set (reg:SI 89)
(mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars) (mem/c:SI (plus:DI (reg/f:DI virtual-stack-vars)
(const_int -4 [0xfffffffffffffffc])) [1 i+0 S4 A32])) t.c:3 -1 (const_int -4)) [1 i+0 S4 A32])) "t.c":3
(nil)) (nil))
(insn 7 6 10 2 (parallel [ (cinsn (parallel [
(set (reg:SI 87 [ _2 ]) (set (reg:SI 87 [ _2 ])
(ashift:SI (reg:SI 89) (ashift:SI (reg:SI 89)
(const_int 1 [0x1]))) (const_int 1)))
(clobber (reg:CC 17 flags)) (clobber (reg:CC flags))
]) t.c:3 -1 ]) "t.c":3
(expr_list:REG_EQUAL (ashift:SI (mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars) (expr_list:REG_EQUAL (ashift:SI (mem/c:SI (plus:DI (reg/f:DI virtual-stack-vars)
(const_int -4 [0xfffffffffffffffc])) [1 i+0 S4 A32]) (const_int -4)) [1 i+0 S4 A32])
(const_int 1 [0x1])) (const_int 1))
(nil))) (nil)))
(insn 10 7 14 2 (set (reg:SI 88 [ <retval> ]) (cinsn (set (reg:SI 88 [ <retval> ])
(reg:SI 87 [ _2 ])) t.c:3 -1 (reg:SI 87 [ _2 ])) "t.c":3
(nil)) (nil))
(insn 14 10 15 2 (set (reg/i:SI 0 ax) (cinsn (set (reg/i:SI ax)
(reg:SI 88 [ <retval> ])) t.c:4 -1 (reg:SI 88 [ <retval> ])) "t.c":4
(nil)) (nil))
(insn 15 14 0 2 (use (reg/i:SI 0 ax)) t.c:4 -1 (cinsn (use (reg/i:SI ax)) "t.c":4
(nil)) (nil))
(edge-to exit (flags "FALLTHRU")) (edge-to exit (flags "FALLTHRU"))
) ;; block 2 ) ;; block 2
) ;; insn-chain ) ;; insn-chain
(crtl (crtl
(return_rtx (return_rtx
(reg/i:SI 0 ax) (reg/i:SI ax)
) ;; return_rtx ) ;; return_rtx
) ;; crtl ) ;; crtl
) ;; function "times_two" ) ;; function "times_two"
*/ */
DEBUG_FUNCTION void DEBUG_FUNCTION void
print_rtx_function (FILE *outfile, function *fn) print_rtx_function (FILE *outfile, function *fn, bool compact)
{ {
flag_compact = compact;
tree fdecl = fn->decl; tree fdecl = fn->decl;
const char *dname = lang_hooks.decl_printable_name (fdecl, 2); const char *dname = lang_hooks.decl_printable_name (fdecl, 2);
...@@ -210,4 +220,6 @@ print_rtx_function (FILE *outfile, function *fn) ...@@ -210,4 +220,6 @@ print_rtx_function (FILE *outfile, function *fn)
fprintf (outfile, " ) ;; crtl\n"); fprintf (outfile, " ) ;; crtl\n");
fprintf (outfile, ") ;; function \"%s\"\n", dname); fprintf (outfile, ") ;; function \"%s\"\n", dname);
flag_compact = false;
} }
...@@ -60,6 +60,13 @@ static int indent; ...@@ -60,6 +60,13 @@ static int indent;
static bool in_call_function_usage; static bool in_call_function_usage;
/* If true, use compact dump format:
- INSN_UIDs are omitted, except for jumps and CODE_LABELs,
- INSN_CODEs are omitted,
- register numbers are omitted for hard and virtual regs
- insn names are prefixed with "c" (e.g. "cinsn", "cnote", etc). */
bool flag_compact;
static void print_rtx (const_rtx); static void print_rtx (const_rtx);
/* String printed at beginning of each RTL when it is dumped. /* String printed at beginning of each RTL when it is dumped.
...@@ -176,7 +183,8 @@ print_rtx_operand_code_0 (const_rtx in_rtx ATTRIBUTE_UNUSED, ...@@ -176,7 +183,8 @@ print_rtx_operand_code_0 (const_rtx in_rtx ATTRIBUTE_UNUSED,
break; break;
} }
} }
else if (idx == 7 && JUMP_P (in_rtx) && JUMP_LABEL (in_rtx) != NULL) else if (idx == 7 && JUMP_P (in_rtx) && JUMP_LABEL (in_rtx) != NULL
&& !flag_compact)
{ {
/* Output the JUMP_LABEL reference. */ /* Output the JUMP_LABEL reference. */
fprintf (outfile, "\n%s%*s -> ", print_rtx_head, indent * 2, ""); fprintf (outfile, "\n%s%*s -> ", print_rtx_head, indent * 2, "");
...@@ -284,7 +292,7 @@ print_rtx_operand_code_i (const_rtx in_rtx, int idx) ...@@ -284,7 +292,7 @@ print_rtx_operand_code_i (const_rtx in_rtx, int idx)
if (INSN_HAS_LOCATION (in_insn)) if (INSN_HAS_LOCATION (in_insn))
{ {
expanded_location xloc = insn_location (in_insn); expanded_location xloc = insn_location (in_insn);
fprintf (outfile, " %s:%i", xloc.file, xloc.line); fprintf (outfile, " \"%s\":%i", xloc.file, xloc.line);
} }
#endif #endif
} }
...@@ -335,6 +343,13 @@ print_rtx_operand_code_i (const_rtx in_rtx, int idx) ...@@ -335,6 +343,13 @@ print_rtx_operand_code_i (const_rtx in_rtx, int idx)
const char *name; const char *name;
int is_insn = INSN_P (in_rtx); int is_insn = INSN_P (in_rtx);
/* Don't print INSN_CODEs in compact mode. */
if (flag_compact && is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, idx))
{
sawclose = 0;
return;
}
if (flag_dump_unnumbered if (flag_dump_unnumbered
&& (is_insn || NOTE_P (in_rtx))) && (is_insn || NOTE_P (in_rtx)))
fputc ('#', outfile); fputc ('#', outfile);
...@@ -358,26 +373,28 @@ print_rtx_operand_code_r (const_rtx in_rtx) ...@@ -358,26 +373,28 @@ print_rtx_operand_code_r (const_rtx in_rtx)
unsigned int regno = REGNO (in_rtx); unsigned int regno = REGNO (in_rtx);
#ifndef GENERATOR_FILE #ifndef GENERATOR_FILE
/* For hard registers and virtuals, always print the
regno, except in compact mode. */
if (regno <= LAST_VIRTUAL_REGISTER && !flag_compact)
fprintf (outfile, " %d", regno);
if (regno < FIRST_PSEUDO_REGISTER) if (regno < FIRST_PSEUDO_REGISTER)
fprintf (outfile, " %d %s", regno, reg_names[regno]); fprintf (outfile, " %s", reg_names[regno]);
else if (regno <= LAST_VIRTUAL_REGISTER) else if (regno <= LAST_VIRTUAL_REGISTER)
{ {
if (regno == VIRTUAL_INCOMING_ARGS_REGNUM) if (regno == VIRTUAL_INCOMING_ARGS_REGNUM)
fprintf (outfile, " %d virtual-incoming-args", regno); fprintf (outfile, " virtual-incoming-args");
else if (regno == VIRTUAL_STACK_VARS_REGNUM) else if (regno == VIRTUAL_STACK_VARS_REGNUM)
fprintf (outfile, " %d virtual-stack-vars", regno); fprintf (outfile, " virtual-stack-vars");
else if (regno == VIRTUAL_STACK_DYNAMIC_REGNUM) else if (regno == VIRTUAL_STACK_DYNAMIC_REGNUM)
fprintf (outfile, " %d virtual-stack-dynamic", regno); fprintf (outfile, " virtual-stack-dynamic");
else if (regno == VIRTUAL_OUTGOING_ARGS_REGNUM) else if (regno == VIRTUAL_OUTGOING_ARGS_REGNUM)
fprintf (outfile, " %d virtual-outgoing-args", regno); fprintf (outfile, " virtual-outgoing-args");
else if (regno == VIRTUAL_CFA_REGNUM) else if (regno == VIRTUAL_CFA_REGNUM)
fprintf (outfile, " %d virtual-cfa", regno); fprintf (outfile, " virtual-cfa");
else if (regno == VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM) else if (regno == VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM)
fprintf (outfile, " %d virtual-preferred-stack-boundary", fprintf (outfile, " virtual-preferred-stack-boundary");
regno);
else else
fprintf (outfile, " %d virtual-reg-%d", regno, fprintf (outfile, " virtual-reg-%d", regno-FIRST_VIRTUAL_REGISTER);
regno-FIRST_VIRTUAL_REGISTER);
} }
else else
#endif #endif
...@@ -410,6 +427,10 @@ print_rtx_operand_code_r (const_rtx in_rtx) ...@@ -410,6 +427,10 @@ print_rtx_operand_code_r (const_rtx in_rtx)
static void static void
print_rtx_operand_code_u (const_rtx in_rtx, int idx) print_rtx_operand_code_u (const_rtx in_rtx, int idx)
{ {
/* Don't print insn UIDs in compact mode, apart from in LABEL_REFs. */
if (flag_compact && GET_CODE (in_rtx) != LABEL_REF)
return;
if (XEXP (in_rtx, idx) != NULL) if (XEXP (in_rtx, idx) != NULL)
{ {
rtx sub = XEXP (in_rtx, idx); rtx sub = XEXP (in_rtx, idx);
...@@ -492,7 +513,7 @@ print_rtx_operand (const_rtx in_rtx, int idx) ...@@ -492,7 +513,7 @@ print_rtx_operand (const_rtx in_rtx, int idx)
if (! flag_simple) if (! flag_simple)
fprintf (outfile, " "); fprintf (outfile, " ");
fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, idx)); fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, idx));
if (! flag_simple) if (! flag_simple && !flag_compact)
fprintf (outfile, " [" HOST_WIDE_INT_PRINT_HEX "]", fprintf (outfile, " [" HOST_WIDE_INT_PRINT_HEX "]",
(unsigned HOST_WIDE_INT) XWINT (in_rtx, idx)); (unsigned HOST_WIDE_INT) XWINT (in_rtx, idx));
break; break;
...@@ -533,6 +554,9 @@ print_rtx_operand (const_rtx in_rtx, int idx) ...@@ -533,6 +554,9 @@ print_rtx_operand (const_rtx in_rtx, int idx)
break; break;
case 'B': case 'B':
/* Don't print basic block ids in compact mode. */
if (flag_compact)
break;
#ifndef GENERATOR_FILE #ifndef GENERATOR_FILE
if (XBBDEF (in_rtx, idx)) if (XBBDEF (in_rtx, idx))
fprintf (outfile, " %i", XBBDEF (in_rtx, idx)->index); fprintf (outfile, " %i", XBBDEF (in_rtx, idx)->index);
...@@ -575,7 +599,20 @@ print_rtx (const_rtx in_rtx) ...@@ -575,7 +599,20 @@ print_rtx (const_rtx in_rtx)
} }
/* Print name of expression code. */ /* Print name of expression code. */
if (flag_simple && CONST_INT_P (in_rtx))
/* In compact mode, prefix the code of insns with "c",
giving "cinsn", "cnote" etc. */
if (flag_compact && is_a <const rtx_insn *, const struct rtx_def> (in_rtx))
{
/* "ccode_label" is slightly awkward, so special-case it as
just "clabel". */
rtx_code code = GET_CODE (in_rtx);
if (code == CODE_LABEL)
fprintf (outfile, "(clabel");
else
fprintf (outfile, "(c%s", GET_RTX_NAME (code));
}
else if (flag_simple && CONST_INT_P (in_rtx))
fputc ('(', outfile); fputc ('(', outfile);
else else
fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx))); fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx)));
...@@ -639,7 +676,10 @@ print_rtx (const_rtx in_rtx) ...@@ -639,7 +676,10 @@ print_rtx (const_rtx in_rtx)
idx = 5; idx = 5;
#endif #endif
if (INSN_CHAIN_CODE_P (GET_CODE (in_rtx))) /* For insns, print the INSN_UID.
In compact mode, we only print the INSN_UID of CODE_LABELs. */
if (INSN_CHAIN_CODE_P (GET_CODE (in_rtx))
&& (!flag_compact || GET_CODE (in_rtx) == CODE_LABEL))
{ {
if (flag_dump_unnumbered) if (flag_dump_unnumbered)
fprintf (outfile, " #"); fprintf (outfile, " #");
...@@ -704,7 +744,8 @@ print_rtx (const_rtx in_rtx) ...@@ -704,7 +744,8 @@ print_rtx (const_rtx in_rtx)
#endif #endif
case CODE_LABEL: case CODE_LABEL:
fprintf (outfile, " [%d uses]", LABEL_NUSES (in_rtx)); if (!flag_compact)
fprintf (outfile, " [%d uses]", LABEL_NUSES (in_rtx));
switch (LABEL_KIND (in_rtx)) switch (LABEL_KIND (in_rtx))
{ {
case LABEL_NORMAL: break; case LABEL_NORMAL: break;
......
...@@ -36,6 +36,6 @@ extern void print_insn (pretty_printer *pp, const rtx_insn *x, int verbose); ...@@ -36,6 +36,6 @@ extern void print_insn (pretty_printer *pp, const rtx_insn *x, int verbose);
extern void rtl_dump_bb_for_graph (pretty_printer *, basic_block); extern void rtl_dump_bb_for_graph (pretty_printer *, basic_block);
extern const char *str_pattern_slim (const_rtx); extern const char *str_pattern_slim (const_rtx);
extern void print_rtx_function (FILE *file, function *fn); extern void print_rtx_function (FILE *file, function *fn, bool compact);
#endif // GCC_PRINT_RTL_H #endif // GCC_PRINT_RTL_H
2016-10-13 David Malcolm <dmalcolm@redhat.com>
* gcc.target/i386/vararg-loc.c: Update for quoting of xloc.file
in INSN_LOCATION.
2016-10-13 Bin Cheng <bin.cheng@arm.com> 2016-10-13 Bin Cheng <bin.cheng@arm.com>
* gcc.target/i386/l_fma_float_1.c: Revise test. * gcc.target/i386/l_fma_float_1.c: Revise test.
......
...@@ -22,6 +22,6 @@ f (int a, ...) /* 8. */ ...@@ -22,6 +22,6 @@ f (int a, ...) /* 8. */
return sum; return sum;
} }
/* { dg-final { scan-rtl-dump-not "vararg-loc\\.c:\[6789\] " "final" } } */ /* { dg-final { scan-rtl-dump-not "vararg-loc\\.c.:\[6789\] " "final" } } */
/* { dg-final { scan-rtl-dump "vararg-loc\\.c:18 " "final" } } */ /* { dg-final { scan-rtl-dump "vararg-loc\\.c.:18 " "final" } } */
/* { dg-final { scan-rtl-dump "vararg-loc\\.c:20 " "final" } } */ /* { dg-final { scan-rtl-dump "vararg-loc\\.c.:20 " "final" } } */
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