This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Keeping original REGNOs around


This patch adds infrastructure to keep the original pseudo register numbers
available after reload.  It uses the currently unused second field of a REG
rtx.

There'll be more patches to make the alias analysis code aware of this to
improve scheduling after reload.

Bootstrapped (with the followup patches applied) on i686-linux; bootstrap
on ia64-linux is running.


Bernd

	* emit-rtl.c (gen_raw_REG): New function.
	(gen_rtx_REG, gen_reg_rtx, init_emit_once): Use it instead of
	gen_rtx_raw_REG.
	* print-rtl.c (print_rtx): Print ORIGINAL_REGNO.
	* final.c (alter_subreg): Update it.
	* regrename.c (do_replace): Likewise.  Use gen_raw_REG.
	* rtl.def (REG): Update comment.
	* rtl.h (X0UINT, ORIGINAL_REGNO): New macros.
	(gen_raw_REG): Declare.

Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/emit-rtl.c,v
retrieving revision 1.157
diff -u -p -r1.157 emit-rtl.c
--- emit-rtl.c	2000/11/30 06:31:17	1.157
+++ emit-rtl.c	2000/12/29 17:17:35
@@ -228,6 +228,20 @@ rtx_htab_mark (htab)
   htab_traverse (*((htab_t *) htab), rtx_htab_mark_1, NULL);
 }

+/* Generate a new REG rtx.  Make sure ORIGINAL_REGNO is set properly, and
+   don't attempt to share with the various global pieces of rtl (such as
+   frame_pointer_rtx).  */
+
+rtx
+gen_raw_REG (mode, regno)
+     enum machine_mode mode;
+     int regno;
+{
+  rtx x = gen_rtx_raw_REG (mode, regno);
+  ORIGINAL_REGNO (x) = regno;
+  return x;
+}
+
 /* There are some RTL codes that require special attention; the generation
    functions do the raw handling.  If you add to this list, modify
    special_rtx in gengenrtl.c as well.  */
@@ -319,7 +333,7 @@ gen_rtx_REG (mode, regno)
 	return stack_pointer_rtx;
     }

-  return gen_rtx_raw_REG (mode, regno);
+  return gen_raw_REG (mode, regno);
 }

 rtx
@@ -569,7 +583,7 @@ gen_reg_rtx (mode)
       f->emit->regno_pointer_align_length = old_size * 2;
     }

-  val = gen_rtx_raw_REG (mode, reg_rtx_no);
+  val = gen_raw_REG (mode, reg_rtx_no);
   regno_reg_rtx[reg_rtx_no++] = val;
   return val;
 }
@@ -4053,22 +4067,22 @@ init_emit_once (line_numbers)

   pc_rtx = gen_rtx (PC, VOIDmode);
   cc0_rtx = gen_rtx (CC0, VOIDmode);
-  stack_pointer_rtx = gen_rtx_raw_REG (Pmode, STACK_POINTER_REGNUM);
-  frame_pointer_rtx = gen_rtx_raw_REG (Pmode, FRAME_POINTER_REGNUM);
+  stack_pointer_rtx = gen_raw_REG (Pmode, STACK_POINTER_REGNUM);
+  frame_pointer_rtx = gen_raw_REG (Pmode, FRAME_POINTER_REGNUM);
   if (hard_frame_pointer_rtx == 0)
-    hard_frame_pointer_rtx = gen_rtx_raw_REG (Pmode,
-					      HARD_FRAME_POINTER_REGNUM);
+    hard_frame_pointer_rtx = gen_raw_REG (Pmode,
+					  HARD_FRAME_POINTER_REGNUM);
   if (arg_pointer_rtx == 0)
-    arg_pointer_rtx = gen_rtx_raw_REG (Pmode, ARG_POINTER_REGNUM);
+    arg_pointer_rtx = gen_raw_REG (Pmode, ARG_POINTER_REGNUM);
   virtual_incoming_args_rtx =
-    gen_rtx_raw_REG (Pmode, VIRTUAL_INCOMING_ARGS_REGNUM);
+    gen_raw_REG (Pmode, VIRTUAL_INCOMING_ARGS_REGNUM);
   virtual_stack_vars_rtx =
-    gen_rtx_raw_REG (Pmode, VIRTUAL_STACK_VARS_REGNUM);
+    gen_raw_REG (Pmode, VIRTUAL_STACK_VARS_REGNUM);
   virtual_stack_dynamic_rtx =
-    gen_rtx_raw_REG (Pmode, VIRTUAL_STACK_DYNAMIC_REGNUM);
+    gen_raw_REG (Pmode, VIRTUAL_STACK_DYNAMIC_REGNUM);
   virtual_outgoing_args_rtx =
-    gen_rtx_raw_REG (Pmode, VIRTUAL_OUTGOING_ARGS_REGNUM);
-  virtual_cfa_rtx = gen_rtx_raw_REG (Pmode, VIRTUAL_CFA_REGNUM);
+    gen_raw_REG (Pmode, VIRTUAL_OUTGOING_ARGS_REGNUM);
+  virtual_cfa_rtx = gen_raw_REG (Pmode, VIRTUAL_CFA_REGNUM);

   /* These rtx must be roots if GC is enabled.  */
   ggc_add_rtx_root (global_rtl, GR_MAX);
@@ -4148,7 +4162,7 @@ init_emit_once (line_numbers)

 #ifdef RETURN_ADDRESS_POINTER_REGNUM
   return_address_pointer_rtx
-    = gen_rtx_raw_REG (Pmode, RETURN_ADDRESS_POINTER_REGNUM);
+    = gen_raw_REG (Pmode, RETURN_ADDRESS_POINTER_REGNUM);
 #endif

 #ifdef STRUCT_VALUE
Index: final.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/final.c,v
retrieving revision 1.152
diff -u -p -r1.152 final.c
--- final.c	2000/12/20 09:03:23	1.152
+++ final.c	2000/12/29 17:17:36
@@ -3169,6 +3169,7 @@ alter_subreg (x)
 #endif
       PUT_CODE (x, REG);
       REGNO (x) = regno;
+      ORIGINAL_REGNO (x) = ORIGINAL_REGNO (y);
       /* This field has a different meaning for REGs and SUBREGs.  Make sure
 	 to clear it!  */
       x->used = 0;
Index: print-rtl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/print-rtl.c,v
retrieving revision 1.61
diff -u -p -r1.61 print-rtl.c
--- print-rtl.c	2000/10/16 16:24:54	1.61
+++ print-rtl.c	2000/12/29 17:17:38
@@ -170,6 +170,12 @@ print_rtx (in_rtx)
 	   An exception is the third field of a NOTE, where it indicates
 	   that the field has several different valid contents.  */
       case '0':
+	if (i == 1 && GET_CODE (in_rtx) == REG)
+	  {
+	    if (REGNO (in_rtx) != ORIGINAL_REGNO (in_rtx))
+	      fprintf (outfile, " [%d]", ORIGINAL_REGNO (in_rtx));
+	    break;
+	  }
 	if (i == 3 && GET_CODE (in_rtx) == NOTE)
 	  {
 	    switch (NOTE_LINE_NUMBER (in_rtx))
Index: regrename.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/regrename.c,v
retrieving revision 1.18
diff -u -p -r1.18 regrename.c
--- regrename.c	2000/12/22 15:44:42	1.18
+++ regrename.c	2000/12/29 17:17:38
@@ -349,7 +349,9 @@ do_replace (chain, reg)
 {
   while (chain)
     {
-      *chain->loc = gen_rtx_REG (GET_MODE (*chain->loc), reg);
+      unsigned int regno = ORIGINAL_REGNO (*chain->loc);
+      *chain->loc = gen_raw_REG (GET_MODE (*chain->loc), reg);
+      ORIGINAL_REGNO (*chain->loc) = regno;
       chain = chain->next_use;
     }
 }
Index: rtl.def
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtl.def,v
retrieving revision 1.42
diff -u -p -r1.42 rtl.def
--- rtl.def	2000/07/28 17:46:17	1.42
+++ rtl.def	2000/12/29 17:17:39
@@ -583,12 +583,10 @@ DEF_RTL_EXPR(VALUE, "value", "0", 'o')
 /* A register.  The "operand" is the register number, accessed with
    the REGNO macro.  If this number is less than FIRST_PSEUDO_REGISTER
    than a hardware register is being referred to.  The second operand
-   doesn't really exist.  Unfortunately, however, the compiler
-   implicitly assumes that a REG can be transformed in place into a
-   MEM, and therefore that a REG is at least as big as a MEM.  To
-   avoid this memory overhead, which is likely to be substantial,
-   search for uses of PUT_CODE that turn REGs into MEMs, and fix them
-   somehow.  Then, the trailing `0' can be removed here.  */
+   holds the original register number - this will be different for a
+   pseudo register that got turned into a hard register.
+   This rtx needs to have as many (or more) fields as a MEM, since we
+   can change REG rtx's into MEMs during reload.  */
 DEF_RTL_EXPR(REG, "reg", "i0", 'o')

 /* A scratch register.  This represents a register used only within a
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtl.h,v
retrieving revision 1.234
diff -u -p -r1.234 rtl.h
--- rtl.h	2000/12/21 18:26:06	1.234
+++ rtl.h	2000/12/29 17:17:39
@@ -328,6 +328,7 @@ extern void rtvec_check_failed_bounds PA

 #define X0WINT(RTX, N)	   (RTL_CHECK1(RTX, N, '0').rtwint)
 #define X0INT(RTX, N)	   (RTL_CHECK1(RTX, N, '0').rtint)
+#define X0UINT(RTX, N)	   (RTL_CHECK1(RTX, N, '0').rtuint)
 #define X0STR(RTX, N)	   (RTL_CHECK1(RTX, N, '0').rtstr)
 #define X0EXP(RTX, N)	   (RTL_CHECK1(RTX, N, '0').rtx)
 #define X0VEC(RTX, N)	   (RTL_CHECK1(RTX, N, '0').rtvec)
@@ -742,9 +743,12 @@ extern const char * const note_insn_name

 #define CONTAINING_INSN(RTX) XCEXP(RTX, 2, LABEL_REF)

-/* For a REG rtx, REGNO extracts the register number.  */
+/* For a REG rtx, REGNO extracts the register number.  ORIGINAL_REGNO holds
+   the number the register originally had; for a pseudo register turned into
+   a hard reg this will hold the old pseudo register number.  */

 #define REGNO(RTX) XCUINT(RTX, 0, REG)
+#define ORIGINAL_REGNO(RTX) X0UINT(RTX, 1)

 /* For a REG rtx, REG_FUNCTION_VALUE_P is nonzero if the reg
    is the current function's return value.  */
@@ -1539,6 +1544,7 @@ extern rtx return_address_pointer_rtx;
 extern rtx gen_rtx_CONST_DOUBLE PARAMS ((enum machine_mode, rtx,
 				       HOST_WIDE_INT, HOST_WIDE_INT));
 extern rtx gen_rtx_CONST_INT PARAMS ((enum machine_mode, HOST_WIDE_INT));
+extern rtx gen_raw_REG PARAMS ((enum machine_mode, int));
 extern rtx gen_rtx_REG PARAMS ((enum machine_mode, int));
 extern rtx gen_rtx_MEM PARAMS ((enum machine_mode, rtx));



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]