Split print_rtx into subroutines

gcc/ChangeLog:
	* print-rtl.c (print_rtx): Rename "i" to "idx".  Split out the
	operand-printing "switch" statement into...
	(print_rtx_operand_code_0): ...this new function, ...
	(print_rtx_operand_code_e): ...this new function, ...
	(print_rtx_operand_codes_E_and_V): ...this new function, ...
	(print_rtx_operand_code_i): ...this new function, ...
	(print_rtx_operand_code_r): ...this new function, ...
	(print_rtx_operand_code_u): ...this new function, ...
	(print_rtx_operand): ...and this new function.

From-SVN: r241002
This commit is contained in:
David Malcolm 2016-10-11 19:19:05 +00:00 committed by David Malcolm
parent ec08df86cb
commit acda0629ff
2 changed files with 467 additions and 396 deletions

View File

@ -1,3 +1,15 @@
2016-10-11 David Malcolm <dmalcolm@redhat.com>
* print-rtl.c (print_rtx): Rename "i" to "idx". Split out the
operand-printing "switch" statement into...
(print_rtx_operand_code_0): ...this new function, ...
(print_rtx_operand_code_e): ...this new function, ...
(print_rtx_operand_codes_E_and_V): ...this new function, ...
(print_rtx_operand_code_i): ...this new function, ...
(print_rtx_operand_code_r): ...this new function, ...
(print_rtx_operand_code_u): ...this new function, ...
(print_rtx_operand): ...and this new function.
2016-10-11 Uros Bizjak <ubizjak@gmail.com>
* config/alpha/alpha-passes.def: New file.

View File

@ -94,144 +94,18 @@ print_mem_expr (FILE *outfile, const_tree expr)
}
#endif
/* Print IN_RTX onto OUTFILE. This is the recursive part of printing. */
/* Subroutine of print_rtx_operand for handling code '0'.
0 indicates a field for internal use that should not be printed.
However there are various special cases, such as the third field
of a NOTE, where it indicates that the field has several different
valid contents. */
static void
print_rtx (const_rtx in_rtx)
print_rtx_operand_code_0 (const_rtx in_rtx ATTRIBUTE_UNUSED,
int idx ATTRIBUTE_UNUSED)
{
int i = 0;
int j;
const char *format_ptr;
int is_insn;
if (sawclose)
{
if (flag_simple)
fputc (' ', outfile);
else
fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, "");
sawclose = 0;
}
if (in_rtx == 0)
{
fputs ("(nil)", outfile);
sawclose = 1;
return;
}
else if (GET_CODE (in_rtx) > NUM_RTX_CODE)
{
fprintf (outfile, "(??? bad code %d\n%s%*s)", GET_CODE (in_rtx),
print_rtx_head, indent * 2, "");
sawclose = 1;
return;
}
is_insn = INSN_P (in_rtx);
/* Print name of expression code. */
if (flag_simple && CONST_INT_P (in_rtx))
fputc ('(', outfile);
else
fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx)));
if (! flag_simple)
{
if (RTX_FLAG (in_rtx, in_struct))
fputs ("/s", outfile);
if (RTX_FLAG (in_rtx, volatil))
fputs ("/v", outfile);
if (RTX_FLAG (in_rtx, unchanging))
fputs ("/u", outfile);
if (RTX_FLAG (in_rtx, frame_related))
fputs ("/f", outfile);
if (RTX_FLAG (in_rtx, jump))
fputs ("/j", outfile);
if (RTX_FLAG (in_rtx, call))
fputs ("/c", outfile);
if (RTX_FLAG (in_rtx, return_val))
fputs ("/i", outfile);
/* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */
if ((GET_CODE (in_rtx) == EXPR_LIST
|| GET_CODE (in_rtx) == INSN_LIST
|| GET_CODE (in_rtx) == INT_LIST)
&& (int)GET_MODE (in_rtx) < REG_NOTE_MAX
&& !in_call_function_usage)
fprintf (outfile, ":%s",
GET_REG_NOTE_NAME (GET_MODE (in_rtx)));
/* For other rtl, print the mode if it's not VOID. */
else if (GET_MODE (in_rtx) != VOIDmode)
fprintf (outfile, ":%s", GET_MODE_NAME (GET_MODE (in_rtx)));
#ifndef GENERATOR_FILE
if (GET_CODE (in_rtx) == VAR_LOCATION)
{
if (TREE_CODE (PAT_VAR_LOCATION_DECL (in_rtx)) == STRING_CST)
fputs (" <debug string placeholder>", outfile);
else
print_mem_expr (outfile, PAT_VAR_LOCATION_DECL (in_rtx));
fputc (' ', outfile);
print_rtx (PAT_VAR_LOCATION_LOC (in_rtx));
if (PAT_VAR_LOCATION_STATUS (in_rtx)
== VAR_INIT_STATUS_UNINITIALIZED)
fprintf (outfile, " [uninit]");
sawclose = 1;
i = GET_RTX_LENGTH (VAR_LOCATION);
}
#endif
}
#ifndef GENERATOR_FILE
if (CONST_DOUBLE_AS_FLOAT_P (in_rtx))
i = 5;
#endif
if (INSN_CHAIN_CODE_P (GET_CODE (in_rtx)))
{
if (flag_dump_unnumbered)
fprintf (outfile, " #");
else
fprintf (outfile, " %d", INSN_UID (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 < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++)
switch (*format_ptr++)
{
const char *str;
case 'T':
str = XTMPL (in_rtx, i);
goto string;
case 'S':
case 's':
str = XSTR (in_rtx, i);
string:
if (str == 0)
fputs (" \"\"", outfile);
else
fprintf (outfile, " (\"%s\")", str);
sawclose = 1;
break;
/* 0 indicates a field for internal use that should not be printed.
An exception is the third field of a NOTE, where it indicates
that the field has several different valid contents. */
case '0':
#ifndef GENERATOR_FILE
if (i == 1 && GET_CODE (in_rtx) == SYMBOL_REF)
if (idx == 1 && GET_CODE (in_rtx) == SYMBOL_REF)
{
int flags = SYMBOL_REF_FLAGS (in_rtx);
if (flags)
@ -240,7 +114,7 @@ print_rtx (const_rtx in_rtx)
if (decl)
print_node_brief (outfile, "", decl, dump_flags);
}
else if (i == 3 && NOTE_P (in_rtx))
else if (idx == 3 && NOTE_P (in_rtx))
{
switch (NOTE_KIND (in_rtx))
{
@ -302,7 +176,7 @@ print_rtx (const_rtx in_rtx)
break;
}
}
else if (i == 7 && JUMP_P (in_rtx) && JUMP_LABEL (in_rtx) != NULL)
else if (idx == 7 && JUMP_P (in_rtx) && JUMP_LABEL (in_rtx) != NULL)
{
/* Output the JUMP_LABEL reference. */
fprintf (outfile, "\n%s%*s -> ", print_rtx_head, indent * 2, "");
@ -313,7 +187,7 @@ print_rtx (const_rtx in_rtx)
else
fprintf (outfile, "%d", INSN_UID (JUMP_LABEL (in_rtx)));
}
else if (i == 0 && GET_CODE (in_rtx) == VALUE)
else if (idx == 0 && GET_CODE (in_rtx) == VALUE)
{
cselib_val *val = CSELIB_VAL_PTR (in_rtx);
@ -321,12 +195,12 @@ print_rtx (const_rtx in_rtx)
dump_addr (outfile, " @", in_rtx);
dump_addr (outfile, "/", (void*)val);
}
else if (i == 0 && GET_CODE (in_rtx) == DEBUG_EXPR)
else if (idx == 0 && GET_CODE (in_rtx) == DEBUG_EXPR)
{
fprintf (outfile, " D#%i",
DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx)));
}
else if (i == 0 && GET_CODE (in_rtx) == ENTRY_VALUE)
else if (idx == 0 && GET_CODE (in_rtx) == ENTRY_VALUE)
{
indent += 2;
if (!sawclose)
@ -335,30 +209,38 @@ print_rtx (const_rtx in_rtx)
indent -= 2;
}
#endif
break;
}
case 'e':
do_e:
/* Subroutine of print_rtx_operand for handling code 'e'.
Also called by print_rtx_operand_code_u for handling code 'u'
for LABEL_REFs when they don't reference a CODE_LABEL. */
static void
print_rtx_operand_code_e (const_rtx in_rtx, int idx)
{
indent += 2;
if (i == 6 && INSN_P (in_rtx))
if (idx == 6 && INSN_P (in_rtx))
/* Put REG_NOTES on their own line. */
fprintf (outfile, "\n%s%*s",
print_rtx_head, indent * 2, "");
if (!sawclose)
fprintf (outfile, " ");
if (i == 7 && CALL_P (in_rtx))
if (idx == 7 && CALL_P (in_rtx))
{
in_call_function_usage = true;
print_rtx (XEXP (in_rtx, i));
print_rtx (XEXP (in_rtx, idx));
in_call_function_usage = false;
}
else
print_rtx (XEXP (in_rtx, i));
print_rtx (XEXP (in_rtx, idx));
indent -= 2;
break;
}
case 'E':
case 'V':
/* Subroutine of print_rtx_operand for handling codes 'E' and 'V'. */
static void
print_rtx_operand_codes_E_and_V (const_rtx in_rtx, int idx)
{
indent += 2;
if (sawclose)
{
@ -367,14 +249,14 @@ print_rtx (const_rtx in_rtx)
sawclose = 0;
}
fputs (" [", outfile);
if (NULL != XVEC (in_rtx, i))
if (NULL != XVEC (in_rtx, idx))
{
indent += 2;
if (XVECLEN (in_rtx, i))
if (XVECLEN (in_rtx, idx))
sawclose = 1;
for (j = 0; j < XVECLEN (in_rtx, i); j++)
print_rtx (XVECEXP (in_rtx, i, j));
for (int j = 0; j < XVECLEN (in_rtx, idx); j++)
print_rtx (XVECEXP (in_rtx, idx, j));
indent -= 2;
}
@ -384,19 +266,14 @@ print_rtx (const_rtx in_rtx)
fputs ("]", outfile);
sawclose = 1;
indent -= 2;
break;
}
case 'w':
if (! flag_simple)
fprintf (outfile, " ");
fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, i));
if (! flag_simple)
fprintf (outfile, " [" HOST_WIDE_INT_PRINT_HEX "]",
(unsigned HOST_WIDE_INT) XWINT (in_rtx, i));
break;
/* Subroutine of print_rtx_operand for handling code 'i'. */
case 'i':
if (i == 4 && INSN_P (in_rtx))
static void
print_rtx_operand_code_i (const_rtx in_rtx, int idx)
{
if (idx == 4 && INSN_P (in_rtx))
{
#ifndef GENERATOR_FILE
const rtx_insn *in_insn = as_a <const rtx_insn *> (in_rtx);
@ -411,7 +288,7 @@ print_rtx (const_rtx in_rtx)
}
#endif
}
else if (i == 6 && GET_CODE (in_rtx) == ASM_OPERANDS)
else if (idx == 6 && GET_CODE (in_rtx) == ASM_OPERANDS)
{
#ifndef GENERATOR_FILE
if (ASM_OPERANDS_SOURCE_LOCATION (in_rtx) != UNKNOWN_LOCATION)
@ -420,7 +297,7 @@ print_rtx (const_rtx in_rtx)
LOCATION_LINE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx)));
#endif
}
else if (i == 1 && GET_CODE (in_rtx) == ASM_INPUT)
else if (idx == 1 && GET_CODE (in_rtx) == ASM_INPUT)
{
#ifndef GENERATOR_FILE
if (ASM_INPUT_SOURCE_LOCATION (in_rtx) != UNKNOWN_LOCATION)
@ -429,23 +306,23 @@ print_rtx (const_rtx in_rtx)
LOCATION_LINE (ASM_INPUT_SOURCE_LOCATION (in_rtx)));
#endif
}
else if (i == 5 && NOTE_P (in_rtx))
else if (idx == 5 && NOTE_P (in_rtx))
{
/* This field is only used for NOTE_INSN_DELETED_LABEL, and
other times often contains garbage from INSN->NOTE death. */
if (NOTE_KIND (in_rtx) == NOTE_INSN_DELETED_LABEL
|| NOTE_KIND (in_rtx) == NOTE_INSN_DELETED_DEBUG_LABEL)
fprintf (outfile, " %d", XINT (in_rtx, i));
fprintf (outfile, " %d", XINT (in_rtx, idx));
}
#if !defined(GENERATOR_FILE) && NUM_UNSPECV_VALUES > 0
else if (i == 1
else if (idx == 1
&& GET_CODE (in_rtx) == UNSPEC_VOLATILE
&& XINT (in_rtx, 1) >= 0
&& XINT (in_rtx, 1) < NUM_UNSPECV_VALUES)
fprintf (outfile, " %s", unspecv_strings[XINT (in_rtx, 1)]);
#endif
#if !defined(GENERATOR_FILE) && NUM_UNSPEC_VALUES > 0
else if (i == 1
else if (idx == 1
&& (GET_CODE (in_rtx) == UNSPEC
|| GET_CODE (in_rtx) == UNSPEC_VOLATILE)
&& XINT (in_rtx, 1) >= 0
@ -454,8 +331,9 @@ print_rtx (const_rtx in_rtx)
#endif
else
{
int value = XINT (in_rtx, i);
int value = XINT (in_rtx, idx);
const char *name;
int is_insn = INSN_P (in_rtx);
if (flag_dump_unnumbered
&& (is_insn || NOTE_P (in_rtx)))
@ -463,17 +341,22 @@ print_rtx (const_rtx in_rtx)
else
fprintf (outfile, " %d", value);
if (is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, i)
&& XINT (in_rtx, i) >= 0
&& (name = get_insn_name (XINT (in_rtx, i))) != NULL)
if (is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, idx)
&& XINT (in_rtx, idx) >= 0
&& (name = get_insn_name (XINT (in_rtx, idx))) != NULL)
fprintf (outfile, " {%s}", name);
sawclose = 0;
}
break;
}
case 'r':
/* Subroutine of print_rtx_operand for handling code 'r'. */
static void
print_rtx_operand_code_r (const_rtx in_rtx)
{
int is_insn = INSN_P (in_rtx);
unsigned int regno = REGNO (in_rtx);
#ifndef GENERATOR_FILE
if (regno < FIRST_PSEUDO_REGISTER)
fprintf (outfile, " %d %s", regno, reg_names[regno]);
@ -520,20 +403,16 @@ print_rtx (const_rtx in_rtx)
if (regno != ORIGINAL_REGNO (in_rtx))
fprintf (outfile, " [%d]", ORIGINAL_REGNO (in_rtx));
#endif
break;
}
/* Print NOTE_INSN names rather than integer codes. */
/* Subroutine of print_rtx_operand for handling code 'u'. */
case 'n':
fprintf (outfile, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx, i)));
sawclose = 0;
break;
case 'u':
if (XEXP (in_rtx, i) != NULL)
static void
print_rtx_operand_code_u (const_rtx in_rtx, int idx)
{
rtx sub = XEXP (in_rtx, i);
if (XEXP (in_rtx, idx) != NULL)
{
rtx sub = XEXP (in_rtx, idx);
enum rtx_code subc = GET_CODE (sub);
if (GET_CODE (in_rtx) == LABEL_REF)
@ -546,15 +425,18 @@ print_rtx (const_rtx in_rtx)
else
fprintf (outfile, " [%d deleted]", INSN_UID (sub));
sawclose = 0;
break;
return;
}
if (subc != CODE_LABEL)
goto do_e;
{
print_rtx_operand_code_e (in_rtx, idx);
return;
}
}
if (flag_dump_unnumbered
|| (flag_dump_unnumbered_links && i <= 1
|| (flag_dump_unnumbered_links && idx <= 1
&& (INSN_P (in_rtx) || NOTE_P (in_rtx)
|| LABEL_P (in_rtx) || BARRIER_P (in_rtx))))
fputs (" #", outfile);
@ -564,16 +446,84 @@ print_rtx (const_rtx in_rtx)
else
fputs (" 0", outfile);
sawclose = 0;
}
/* Subroutine of print_rtx. Print operand IDX of IN_RTX. */
static void
print_rtx_operand (const_rtx in_rtx, int idx)
{
const char *format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx));
switch (format_ptr[idx])
{
const char *str;
case 'T':
str = XTMPL (in_rtx, idx);
goto string;
case 'S':
case 's':
str = XSTR (in_rtx, idx);
string:
if (str == 0)
fputs (" \"\"", outfile);
else
fprintf (outfile, " (\"%s\")", str);
sawclose = 1;
break;
case '0':
print_rtx_operand_code_0 (in_rtx, idx);
break;
case 'e':
print_rtx_operand_code_e (in_rtx, idx);
break;
case 'E':
case 'V':
print_rtx_operand_codes_E_and_V (in_rtx, idx);
break;
case 'w':
if (! flag_simple)
fprintf (outfile, " ");
fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, idx));
if (! flag_simple)
fprintf (outfile, " [" HOST_WIDE_INT_PRINT_HEX "]",
(unsigned HOST_WIDE_INT) XWINT (in_rtx, idx));
break;
case 'i':
print_rtx_operand_code_i (in_rtx, idx);
break;
case 'r':
print_rtx_operand_code_r (in_rtx);
break;
/* Print NOTE_INSN names rather than integer codes. */
case 'n':
fprintf (outfile, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx, idx)));
sawclose = 0;
break;
case 'u':
print_rtx_operand_code_u (in_rtx, idx);
break;
case 't':
#ifndef GENERATOR_FILE
if (i == 0 && GET_CODE (in_rtx) == DEBUG_IMPLICIT_PTR)
if (idx == 0 && GET_CODE (in_rtx) == DEBUG_IMPLICIT_PTR)
print_mem_expr (outfile, DEBUG_IMPLICIT_PTR_DECL (in_rtx));
else if (i == 0 && GET_CODE (in_rtx) == DEBUG_PARAMETER_REF)
else if (idx == 0 && GET_CODE (in_rtx) == DEBUG_PARAMETER_REF)
print_mem_expr (outfile, DEBUG_PARAMETER_REF_DECL (in_rtx));
else
dump_addr (outfile, " ", XTREE (in_rtx, i));
dump_addr (outfile, " ", XTREE (in_rtx, idx));
#endif
break;
@ -584,14 +534,123 @@ print_rtx (const_rtx in_rtx)
case 'B':
#ifndef GENERATOR_FILE
if (XBBDEF (in_rtx, i))
fprintf (outfile, " %i", XBBDEF (in_rtx, i)->index);
if (XBBDEF (in_rtx, idx))
fprintf (outfile, " %i", XBBDEF (in_rtx, idx)->index);
#endif
break;
default:
gcc_unreachable ();
}
}
/* Print IN_RTX onto OUTFILE. This is the recursive part of printing. */
static void
print_rtx (const_rtx in_rtx)
{
int idx = 0;
if (sawclose)
{
if (flag_simple)
fputc (' ', outfile);
else
fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, "");
sawclose = 0;
}
if (in_rtx == 0)
{
fputs ("(nil)", outfile);
sawclose = 1;
return;
}
else if (GET_CODE (in_rtx) > NUM_RTX_CODE)
{
fprintf (outfile, "(??? bad code %d\n%s%*s)", GET_CODE (in_rtx),
print_rtx_head, indent * 2, "");
sawclose = 1;
return;
}
/* Print name of expression code. */
if (flag_simple && CONST_INT_P (in_rtx))
fputc ('(', outfile);
else
fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx)));
if (! flag_simple)
{
if (RTX_FLAG (in_rtx, in_struct))
fputs ("/s", outfile);
if (RTX_FLAG (in_rtx, volatil))
fputs ("/v", outfile);
if (RTX_FLAG (in_rtx, unchanging))
fputs ("/u", outfile);
if (RTX_FLAG (in_rtx, frame_related))
fputs ("/f", outfile);
if (RTX_FLAG (in_rtx, jump))
fputs ("/j", outfile);
if (RTX_FLAG (in_rtx, call))
fputs ("/c", outfile);
if (RTX_FLAG (in_rtx, return_val))
fputs ("/i", outfile);
/* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */
if ((GET_CODE (in_rtx) == EXPR_LIST
|| GET_CODE (in_rtx) == INSN_LIST
|| GET_CODE (in_rtx) == INT_LIST)
&& (int)GET_MODE (in_rtx) < REG_NOTE_MAX
&& !in_call_function_usage)
fprintf (outfile, ":%s",
GET_REG_NOTE_NAME (GET_MODE (in_rtx)));
/* For other rtl, print the mode if it's not VOID. */
else if (GET_MODE (in_rtx) != VOIDmode)
fprintf (outfile, ":%s", GET_MODE_NAME (GET_MODE (in_rtx)));
#ifndef GENERATOR_FILE
if (GET_CODE (in_rtx) == VAR_LOCATION)
{
if (TREE_CODE (PAT_VAR_LOCATION_DECL (in_rtx)) == STRING_CST)
fputs (" <debug string placeholder>", outfile);
else
print_mem_expr (outfile, PAT_VAR_LOCATION_DECL (in_rtx));
fputc (' ', outfile);
print_rtx (PAT_VAR_LOCATION_LOC (in_rtx));
if (PAT_VAR_LOCATION_STATUS (in_rtx)
== VAR_INIT_STATUS_UNINITIALIZED)
fprintf (outfile, " [uninit]");
sawclose = 1;
idx = GET_RTX_LENGTH (VAR_LOCATION);
}
#endif
}
#ifndef GENERATOR_FILE
if (CONST_DOUBLE_AS_FLOAT_P (in_rtx))
idx = 5;
#endif
if (INSN_CHAIN_CODE_P (GET_CODE (in_rtx)))
{
if (flag_dump_unnumbered)
fprintf (outfile, " #");
else
fprintf (outfile, " %d", INSN_UID (in_rtx));
}
/* Get the format string and skip the first elements if we have handled
them already. */
for (; idx < GET_RTX_LENGTH (GET_CODE (in_rtx)); idx++)
print_rtx_operand (in_rtx, idx);
switch (GET_CODE (in_rtx))
{