Patchwork Improve RTL dumps

login
register
mail settings
Submitter Bernd Schmidt
Date July 27, 2010, 3:02 p.m.
Message ID <4C4EF502.2080306@codesourcery.com>
Download mbox | patch
Permalink /patch/60008/
State New
Headers show

Comments

Bernd Schmidt - July 27, 2010, 3:02 p.m.
I've been annoyed for a while about the source file/line information in
RTL dumps; their placement as operand 4 makes "diff -y" practically
useless since you can't see the start of the pattern if the filenames
are long.

This patch switches operands 4 and 5 of INSNs etc., and also tweaks
print_rtx to place REG_NOTES on a new line.

Bootstrapped on i686-linux, testing now.  Ok?


Bernd
* rtl.def (DEBUG_INSN, INSN, JUMP_INSN, CALL_INSN, NOTE): Swap operands
	4 and 5.
	* rtl.h (PATTERN, INSN_LOCATOR, NOTE_DATA, NOTE_DELETED_LABEL_NAME,
	NOTE_BLOCK, NOTE_EH_HANDLER, NOTE_BASIC_BLOCK, NOTE_VAR_LOCATION,
	NOTE_KIND, LABEL_NUSES, LABEL_REFS): Adjust accordingly.
	* gengtype.c (adjust_field_rtx_def): Swap operands 4 and 5 of CODE_LABELs
	and NOTEs.
	* caller-save.c (init_caller_save): Fix up gen_rtx_INSN call.
	* combine.c (try_combine): Likewise.
	* ira.c (setup_prohibited_mode_move_regs): Likewise.
	* print-rtl.c (print_rtx): Start REG_NOTES on a new line.
Jeff Law - July 27, 2010, 3:24 p.m.
On 07/27/10 09:02, Bernd Schmidt wrote:
> I've been annoyed for a while about the source file/line information in
> RTL dumps; their placement as operand 4 makes "diff -y" practically
> useless since you can't see the start of the pattern if the filenames
> are long.
>
> This patch switches operands 4 and 5 of INSNs etc., and also tweaks
> print_rtx to place REG_NOTES on a new line.
>
> Bootstrapped on i686-linux, testing now.  Ok?
OK.
jeff

Patch

Index: gengtype.c
===================================================================
--- gengtype.c	(revision 162569)
+++ gengtype.c	(working copy)
@@ -1105,16 +1105,16 @@  adjust_field_rtx_def (type_p t, options_
 		t = mem_attrs_tp, subname = "rt_mem";
 	      else if (i == JUMP_INSN && aindex == 8)
 		t = rtx_tp, subname = "rt_rtx";
-	      else if (i == CODE_LABEL && aindex == 4)
-		t = scalar_tp, subname = "rt_int";
 	      else if (i == CODE_LABEL && aindex == 5)
+		t = scalar_tp, subname = "rt_int";
+	      else if (i == CODE_LABEL && aindex == 4)
 		t = rtx_tp, subname = "rt_rtx";
 	      else if (i == LABEL_REF
 		       && (aindex == 1 || aindex == 2))
 		t = rtx_tp, subname = "rt_rtx";
-	      else if (i == NOTE && aindex == 4)
-		t = note_union_tp, subname = "";
 	      else if (i == NOTE && aindex == 5)
+		t = note_union_tp, subname = "";
+	      else if (i == NOTE && aindex == 4)
 		t = scalar_tp, subname = "rt_int";
 	      else if (i == NOTE && aindex >= 7)
 		t = scalar_tp, subname = "rt_int";
Index: caller-save.c
===================================================================
--- caller-save.c	(revision 162569)
+++ caller-save.c	(working copy)
@@ -263,8 +263,8 @@  init_caller_save (void)
   savepat = gen_rtx_SET (VOIDmode, test_mem, test_reg);
   restpat = gen_rtx_SET (VOIDmode, test_reg, test_mem);
 
-  saveinsn = gen_rtx_INSN (VOIDmode, 0, 0, 0, 0, 0, savepat, -1, 0);
-  restinsn = gen_rtx_INSN (VOIDmode, 0, 0, 0, 0, 0, restpat, -1, 0);
+  saveinsn = gen_rtx_INSN (VOIDmode, 0, 0, 0, 0, savepat, 0, -1, 0);
+  restinsn = gen_rtx_INSN (VOIDmode, 0, 0, 0, 0, restpat, 0, -1, 0);
 
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
     for (j = 1; j <= MOVE_MAX_WORDS; j++)
Index: rtl.def
===================================================================
--- rtl.def	(revision 162569)
+++ rtl.def	(working copy)
@@ -123,21 +123,21 @@  DEF_RTL_EXPR(ADDRESS, "address", "e", RT
    ---------------------------------------------------------------------- */
 
 /* An annotation for variable assignment tracking.  */
-DEF_RTL_EXPR(DEBUG_INSN, "debug_insn", "iuuBieie", RTX_INSN)
+DEF_RTL_EXPR(DEBUG_INSN, "debug_insn", "iuuBeiie", RTX_INSN)
 
 /* An instruction that cannot jump.  */
-DEF_RTL_EXPR(INSN, "insn", "iuuBieie", RTX_INSN)
+DEF_RTL_EXPR(INSN, "insn", "iuuBeiie", RTX_INSN)
 
 /* An instruction that can possibly jump.
    Fields ( rtx->u.fld[] ) have exact same meaning as INSN's.  */
-DEF_RTL_EXPR(JUMP_INSN, "jump_insn", "iuuBieie0", RTX_INSN)
+DEF_RTL_EXPR(JUMP_INSN, "jump_insn", "iuuBeiie0", RTX_INSN)
 
 /* An instruction that can possibly call a subroutine
    but which will not change which instruction comes next
    in the current function.
    Field ( rtx->u.fld[8] ) is CALL_INSN_FUNCTION_USAGE.
    All other fields ( rtx->u.fld[] ) have exact same meaning as INSN's.  */
-DEF_RTL_EXPR(CALL_INSN, "call_insn", "iuuBieiee", RTX_INSN)
+DEF_RTL_EXPR(CALL_INSN, "call_insn", "iuuBeiiee", RTX_INSN)
 
 /* A marker that indicates that control will not flow through.  */
 DEF_RTL_EXPR(BARRIER, "barrier", "iuu00000", RTX_EXTRA)
@@ -155,7 +155,7 @@  DEF_RTL_EXPR(CODE_LABEL, "code_label", "
    4: note-specific data
    5: enum insn_note
    6: unique number if insn_note == note_insn_deleted_label.  */
-DEF_RTL_EXPR(NOTE, "note", "iuuB0ni", RTX_EXTRA)
+DEF_RTL_EXPR(NOTE, "note", "iuuBn0i", RTX_EXTRA)
 
 /* ----------------------------------------------------------------------
    Top level constituents of INSN, JUMP_INSN and CALL_INSN.
Index: print-rtl.c
===================================================================
--- print-rtl.c	(revision 162569)
+++ print-rtl.c	(working copy)
@@ -333,6 +333,10 @@  print_rtx (const_rtx in_rtx)
       case 'e':
       do_e:
 	indent += 2;
+	if (i == 7 && 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, " ");
 	print_rtx (XEXP (in_rtx, i));
@@ -378,7 +382,7 @@  print_rtx (const_rtx in_rtx)
 	break;
 
       case 'i':
-	if (i == 4 && INSN_P (in_rtx))
+	if (i == 5 && INSN_P (in_rtx))
 	  {
 #ifndef GENERATOR_FILE
 	    /*  Pretty-print insn locators.  Ignore scoping as it is mostly
Index: ira.c
===================================================================
--- ira.c	(revision 162569)
+++ ira.c	(working copy)
@@ -1211,7 +1211,7 @@  setup_prohibited_mode_move_regs (void)
   test_reg1 = gen_rtx_REG (VOIDmode, 0);
   test_reg2 = gen_rtx_REG (VOIDmode, 0);
   move_pat = gen_rtx_SET (VOIDmode, test_reg1, test_reg2);
-  move_insn = gen_rtx_INSN (VOIDmode, 0, 0, 0, 0, 0, move_pat, -1, 0);
+  move_insn = gen_rtx_INSN (VOIDmode, 0, 0, 0, 0, move_pat, 0, -1, 0);
   for (i = 0; i < NUM_MACHINE_MODES; i++)
     {
       SET_HARD_REG_SET (ira_prohibited_mode_move_regs[i]);
Index: rtl.h
===================================================================
--- rtl.h	(revision 162569)
+++ rtl.h	(working copy)
@@ -757,15 +757,17 @@  extern void rtl_check_failed_flag (const
 #define NEXT_INSN(INSN)	XEXP (INSN, 2)
 
 #define BLOCK_FOR_INSN(INSN) XBBDEF (INSN, 3)
-#define INSN_LOCATOR(INSN) XINT (INSN, 4)
+
+/* The body of an insn.  */
+#define PATTERN(INSN)	XEXP (INSN, 4)
+
+#define INSN_LOCATOR(INSN) XINT (INSN, 5)
 /* LOCATION of an RTX if relevant.  */
 #define RTL_LOCATION(X) (INSN_P (X) ? \
 			 locator_location (INSN_LOCATOR (X)) \
 			 : UNKNOWN_LOCATION)
 /* LOCATION of current INSN.  */
 #define CURR_INSN_LOCATION (locator_location (curr_insn_locator ()))
-/* The body of an insn.  */
-#define PATTERN(INSN)	XEXP (INSN, 5)
 
 /* Code number of instruction, from when it was recognized.
    -1 means this instruction has not been recognized yet.  */
@@ -869,17 +871,17 @@  extern const char * const reg_note_name[
    */
 
 /* Opaque data.  */
-#define NOTE_DATA(INSN)	        RTL_CHECKC1 (INSN, 4, NOTE)
-#define NOTE_DELETED_LABEL_NAME(INSN) XCSTR (INSN, 4, NOTE)
+#define NOTE_DATA(INSN)	        RTL_CHECKC1 (INSN, 5, NOTE)
+#define NOTE_DELETED_LABEL_NAME(INSN) XCSTR (INSN, 5, NOTE)
 #define SET_INSN_DELETED(INSN) set_insn_deleted (INSN);
-#define NOTE_BLOCK(INSN)	XCTREE (INSN, 4, NOTE)
-#define NOTE_EH_HANDLER(INSN)	XCINT (INSN, 4, NOTE)
-#define NOTE_BASIC_BLOCK(INSN)	XCBBDEF (INSN, 4, NOTE)
-#define NOTE_VAR_LOCATION(INSN)	XCEXP (INSN, 4, NOTE)
+#define NOTE_BLOCK(INSN)	XCTREE (INSN, 5, NOTE)
+#define NOTE_EH_HANDLER(INSN)	XCINT (INSN, 5, NOTE)
+#define NOTE_BASIC_BLOCK(INSN)	XCBBDEF (INSN, 5, NOTE)
+#define NOTE_VAR_LOCATION(INSN)	XCEXP (INSN, 5, NOTE)
 
 /* In a NOTE that is a line number, this is the line number.
    Other kinds of NOTEs are identified by negative numbers here.  */
-#define NOTE_KIND(INSN) XCINT (INSN, 5, NOTE)
+#define NOTE_KIND(INSN) XCINT (INSN, 4, NOTE)
 
 /* Nonzero if INSN is a note marking the beginning of a basic block.  */
 #define NOTE_INSN_BASIC_BLOCK_P(INSN)			\
@@ -971,7 +973,7 @@  extern const char * const note_insn_name
 
 /* In jump.c, each label contains a count of the number
    of LABEL_REFs that point at it, so unused labels can be deleted.  */
-#define LABEL_NUSES(RTX) XCINT (RTX, 4, CODE_LABEL)
+#define LABEL_NUSES(RTX) XCINT (RTX, 5, CODE_LABEL)
 
 /* Labels carry a two-bit field composed of the ->jump and ->call
    bits.  This field indicates whether the label is an alternate
@@ -1031,7 +1033,7 @@  enum label_kind
 /* Once basic blocks are found, each CODE_LABEL starts a chain that
    goes through all the LABEL_REFs that jump to that label.  The chain
    eventually winds up at the CODE_LABEL: it is circular.  */
-#define LABEL_REFS(LABEL) XCEXP (LABEL, 5, CODE_LABEL)
+#define LABEL_REFS(LABEL) XCEXP (LABEL, 4, CODE_LABEL)
 
 /* For a REG rtx, REGNO extracts the register number.  REGNO can only
    be used on RHS.  Use SET_REGNO to change the value.  */
Index: combine.c
===================================================================
--- combine.c	(revision 162569)
+++ combine.c	(working copy)
@@ -2662,8 +2662,8 @@  try_combine (rtx i3, rtx i2, rtx i1, int
 	     as I2 will not cause a problem.  */
 
 	  i1 = gen_rtx_INSN (VOIDmode, INSN_UID (i2), NULL_RTX, i2,
-			     BLOCK_FOR_INSN (i2), INSN_LOCATOR (i2),
-			     XVECEXP (PATTERN (i2), 0, 1), -1, NULL_RTX);
+			     BLOCK_FOR_INSN (i2), XVECEXP (PATTERN (i2), 0, 1),
+			     INSN_LOCATOR (i2), -1, NULL_RTX);
 
 	  SUBST (PATTERN (i2), XVECEXP (PATTERN (i2), 0, 0));
 	  SUBST (XEXP (SET_SRC (PATTERN (i2)), 0),