/* Print RTL for GNU C Compiler.
- Copyright (C) 1987-1991 Free Software Foundation, Inc.
+ Copyright (C) 1987, 1988, 1992, 1997 Free Software Foundation, Inc.
This file is part of GNU CC.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
#include "config.h"
-#include <ctype.h>
-#include <stdio.h>
+#include "system.h"
#include "rtl.h"
+#include "bitmap.h"
+/* How to print out a register name.
+ We don't use PRINT_REG because some definitions of PRINT_REG
+ don't work here. */
+#ifndef DEBUG_PRINT_REG
+#define DEBUG_PRINT_REG(RTX, CODE, FILE) \
+ fprintf ((FILE), "%d %s", REGNO (RTX), reg_names[REGNO (RTX)])
+#endif
+
+/* Array containing all of the register names */
+
+#ifdef DEBUG_REGISTER_NAMES
+static char *reg_names[] = DEBUG_REGISTER_NAMES;
+#else
+static char *reg_names[] = REGISTER_NAMES;
+#endif
+
static FILE *outfile;
char spaces[] = " ";
static int sawclose = 0;
+static int indent;
+
/* Names for patterns. Non-zero only when linked with insn-output.c. */
extern char **insn_name_ptr;
print_rtx (in_rtx)
register rtx in_rtx;
{
- static int indent;
register int i, j;
register char *format_ptr;
register int is_insn;
if (sawclose)
{
fprintf (outfile, "\n%s",
- (spaces + (sizeof spaces - indent * 2)));
+ (spaces + (sizeof spaces - 1 - indent * 2)));
sawclose = 0;
}
{
case 'S':
case 's':
+ if (i == 3 && GET_CODE (in_rtx) == NOTE
+ && (NOTE_LINE_NUMBER (in_rtx) == NOTE_INSN_EH_REGION_BEG
+ || NOTE_LINE_NUMBER (in_rtx) == NOTE_INSN_EH_REGION_END
+ || NOTE_LINE_NUMBER (in_rtx) == NOTE_INSN_BLOCK_BEG
+ || NOTE_LINE_NUMBER (in_rtx) == NOTE_INSN_BLOCK_END))
+ {
+ fprintf (outfile, " %d", NOTE_BLOCK_NUMBER (in_rtx));
+ sawclose = 1;
+ break;
+ }
+
+ if (i == 3 && GET_CODE (in_rtx) == NOTE
+ && (NOTE_LINE_NUMBER (in_rtx) == NOTE_INSN_RANGE_START
+ || NOTE_LINE_NUMBER (in_rtx) == NOTE_INSN_RANGE_END))
+ {
+ indent += 2;
+ if (!sawclose)
+ fprintf (outfile, " ");
+ print_rtx (NOTE_RANGE_INFO (in_rtx));
+ indent -= 2;
+ break;
+ }
+
+ if (i == 3 && GET_CODE (in_rtx) == NOTE
+ && NOTE_LINE_NUMBER (in_rtx) == NOTE_INSN_LIVE)
+ {
+ if (XBITMAP (in_rtx, i) == NULL)
+ fprintf (outfile, " {null}");
+ else
+ bitmap_print (outfile, XBITMAP (in_rtx, i), " {", "}");
+ sawclose = 0;
+ }
+
if (XSTR (in_rtx, i) == 0)
fprintf (outfile, " \"\"");
else
if (sawclose)
{
fprintf (outfile, "\n%s",
- (spaces + (sizeof spaces - indent * 2)));
+ (spaces + (sizeof spaces - 1 - indent * 2)));
sawclose = 0;
}
fprintf (outfile, "[ ");
}
if (sawclose)
fprintf (outfile, "\n%s",
- (spaces + (sizeof spaces - indent * 2)));
+ (spaces + (sizeof spaces - 1 - indent * 2)));
fprintf (outfile, "] ");
sawclose = 1;
break;
case 'w':
- fprintf (outfile,
-#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
- " %d",
-#else
- " %ld",
-#endif
- XWINT (in_rtx, i));
+ fprintf (outfile, " ");
+ fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, i));
break;
case 'i':
- fprintf (outfile, " %d", XINT (in_rtx, i));
+ {
+ register int value = XINT (in_rtx, i);
+
+ if (GET_CODE (in_rtx) == REG && value < FIRST_PSEUDO_REGISTER)
+ {
+ fputc (' ', outfile);
+ DEBUG_PRINT_REG (in_rtx, 0, outfile);
+ }
+ else
+ fprintf (outfile, " %d", value);
+ }
if (is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, i)
&& insn_name_ptr
&& XINT (in_rtx, i) >= 0)
- fprintf (outfile, " {%s}", insn_name_ptr[XINT (in_rtx, i)]);
+ fprintf (outfile, " {%s}", insn_name_ptr[XINT (in_rtx, i)]);
sawclose = 0;
break;
sawclose = 0;
break;
+ case 'b':
+ if (XBITMAP (in_rtx, i) == NULL)
+ fprintf (outfile, " {null}");
+ else
+ bitmap_print (outfile, XBITMAP (in_rtx, i), " {", "}");
+ sawclose = 0;
+ break;
+
+ case 't':
+ putc (' ', outfile);
+ fprintf (outfile, HOST_WIDE_INT_PRINT_HEX,
+ (HOST_WIDE_INT) XTREE (in_rtx, i));
+ break;
+
case '*':
fprintf (outfile, " Unknown");
sawclose = 0;
sawclose = 1;
}
+/* Print an rtx on the current line of FILE. Initially indent IND
+ characters. */
+
+void
+print_inline_rtx (outf, x, ind)
+ FILE *outf;
+ rtx x;
+ int ind;
+{
+ int oldsaw = sawclose;
+ int oldindent = indent;
+
+ sawclose = 0;
+ indent = ind;
+ outfile = outf;
+ print_rtx (x);
+ sawclose = oldsaw;
+ indent = oldindent;
+}
+
/* Call this function from the debugger to see what X looks like. */
void
fprintf (stderr, "\n");
}
+/* Count of rtx's to print with debug_rtx_list.
+ This global exists because gdb user defined commands have no arguments. */
+
+int debug_rtx_count = 0; /* 0 is treated as equivalent to 1 */
+
+/* Call this function to print list from X on.
+
+ N is a count of the rtx's to print. Positive values print from the specified
+ rtx on. Negative values print a window around the rtx.
+ EG: -5 prints 2 rtx's on either side (in addition to the specified rtx). */
+
+void
+debug_rtx_list (x, n)
+ rtx x;
+ int n;
+{
+ int i,count;
+ rtx insn;
+
+ count = n == 0 ? 1 : n < 0 ? -n : n;
+
+ /* If we are printing a window, back up to the start. */
+
+ if (n < 0)
+ for (i = count / 2; i > 0; i--)
+ {
+ if (PREV_INSN (x) == 0)
+ break;
+ x = PREV_INSN (x);
+ }
+
+ for (i = count, insn = x; i > 0 && insn != 0; i--, insn = NEXT_INSN (insn))
+ debug_rtx (insn);
+}
+
+/* Call this function to search an rtx list to find one with insn uid UID,
+ and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT.
+ The found insn is returned to enable further debugging analysis. */
+
+rtx
+debug_rtx_find (x, uid)
+ rtx x;
+ int uid;
+{
+ while (x != 0 && INSN_UID (x) != uid)
+ x = NEXT_INSN (x);
+ if (x != 0)
+ {
+ debug_rtx_list (x, debug_rtx_count);
+ return x;
+ }
+ else
+ {
+ fprintf (stderr, "insn uid %d not found\n", uid);
+ return 0;
+ }
+}
+
/* External entry point for printing a chain of insns
starting with RTX_FIRST onto file OUTF.
A blank line separates insns.
print_rtx (rtx_first);
}
}
+
+/* Like print_rtx, except specify a file. */
+
+void
+print_rtl_single (outf, x)
+ FILE *outf;
+ rtx x;
+{
+ outfile = outf;
+ sawclose = 0;
+ print_rtx (x);
+ putc ('\n', outf);
+}