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]
Other format: [Raw text]

[committed] Allocation order for caller-saves registers on PA


This is something that has been bothering me for sometime.  There didn't
seem to be any logic to the order in which caller-saves registers were
allocated.  The enclosed patch changes that.

For general registers, we now allocate in the following order of preference:

1)	the return register %r28
2)	registers unused as regular or special arguments
3)	special arguments (e.g., static chain register)
4)	the argument registers in reverse order to their allocation
	order as arguments
5)	argument pointer (hppa64)

We do the same with the caller-saved floating point registers except
that the return register (%fr4) is also used as an argument register,
so I arbitrarily allocated it last.  With the general register, the
thought in allocating %r28 first is that there is often an unnecessary
copy into the return register in many functions.

The patch also contains wome minor cleanups.  I moved the definitions
for ARG_POINTER_REGNUM and STATIC_CHAIN_REGNUM to pa.h to complete the
consolidation of all REGNUM defines in that location.

There may be a small performance boost.  Bootstrap took 45 seconds
less with the patch installed.  I think the main benefit is likely
quicker register allocation when only a small number need allocating.

Tested on hppa2.0w-hp-hpux11.11, hppa64-hp-hpux11.11 and hppa-unknown-linux-gnu.
Committed to trunk.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2004-07-13  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	* pa-64.h (ARG_POINTER_REGNUM, STATIC_CHAIN_REGNUM): Delete.
	* pa.h (ARG_POINTER_REGNUM, STATIC_CHAIN_REGNUM): Modify for hppa64.
	* pa32-regs.h (REG_ALLOC_ORDER): Reorder caller-saved registers.
	* pa64-regs.h (REG_ALLOC_ORDER): Likewise.

Index: config/pa/pa-64.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa-64.h,v
retrieving revision 1.16
diff -u -3 -p -r1.16 pa-64.h
--- config/pa/pa-64.h	18 Feb 2004 15:05:11 -0000	1.16
+++ config/pa/pa-64.h	13 Jul 2004 17:32:41 -0000
@@ -74,17 +74,12 @@ Boston, MA 02111-1307, USA.  */
    ?!? This may not work reliably.  Keep an eye out for problems.  */
 #undef SECONDARY_MEMORY_NEEDED_RTX
 
-
 /* ?!? This needs to be made compile-time selectable.
 
    The PA64 runtime model has arguments that grow to higher addresses
    (like most other targets).  The older runtime model has arguments
    that grow to lower addresses.  What fun.  */
 #undef ARGS_GROW_DOWNWARD
-#undef ARG_POINTER_REGNUM
-#define ARG_POINTER_REGNUM 29
-#undef STATIC_CHAIN_REGNUM
-#define STATIC_CHAIN_REGNUM 31
 
 /* If defined, a C expression which determines whether the default
    implementation of va_arg will attempt to pad down before reading the
Index: config/pa/pa.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa.h,v
retrieving revision 1.223
diff -u -3 -p -r1.223 pa.h
--- config/pa/pa.h	13 Jul 2004 01:35:43 -0000	1.223
+++ config/pa/pa.h	13 Jul 2004 17:32:42 -0000
@@ -533,10 +539,10 @@ do {								\
   do {(VAR) = - compute_frame_size (get_frame_size (), 0);} while (0)
 
 /* Base register for access to arguments of the function.  */
-#define ARG_POINTER_REGNUM 3
+#define ARG_POINTER_REGNUM (TARGET_64BIT ? 29 : 3)
 
 /* Register in which static-chain is passed to a function.  */
-#define STATIC_CHAIN_REGNUM 29
+#define STATIC_CHAIN_REGNUM (TARGET_64BIT ? 31 : 29)
 
 /* Register used to address the offset table for position-independent
    data references.  */
Index: config/pa/pa32-regs.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa32-regs.h,v
retrieving revision 1.13
diff -u -3 -p -r1.13 pa32-regs.h
--- config/pa/pa32-regs.h	11 Mar 2004 05:54:33 -0000	1.13
+++ config/pa/pa32-regs.h	13 Jul 2004 17:32:42 -0000
@@ -119,7 +119,8 @@
    registers will generally not be allocated across a call).
 
    Experimentation has shown slightly better results by allocating
-   FP registers first.  
+   FP registers first.  We allocate the caller-saved registers more
+   or less in reverse order to their allocation as arguments.
 
    FP registers are ordered so that all L registers are selected before
    R registers.  This works around a false dependency interlock on the
@@ -130,14 +131,14 @@
  {					\
   /* caller-saved fp regs.  */		\
   68, 70, 72, 74, 76, 78, 80, 82,	\
-  84, 86, 40, 42, 44, 46, 32, 34,	\
-  36, 38,				\
+  84, 86, 40, 42, 44, 46, 38, 36,	\
+  34, 32,				\
   69, 71, 73, 75, 77, 79, 81, 83,	\
-  85, 87, 41, 43, 45, 47, 33, 35,	\
-  37, 39,				\
+  85, 87, 41, 43, 45, 47, 39, 37,	\
+  35, 33,				\
   /* caller-saved general regs.  */	\
-  19, 20, 21, 22, 23, 24, 25, 26,	\
-  27, 28, 29, 31,  2,			\
+  28, 19, 20, 21, 22, 31, 27, 29,	\
+  23, 24, 25, 26,  2,			\
   /* callee-saved fp regs.  */		\
   48, 50, 52, 54, 56, 58, 60, 62,	\
   64, 66,				\
Index: config/pa/pa64-regs.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa64-regs.h,v
retrieving revision 1.16
diff -u -3 -p -r1.16 pa64-regs.h
--- config/pa/pa64-regs.h	16 Apr 2004 17:03:00 -0000	1.16
+++ config/pa/pa64-regs.h	13 Jul 2004 17:32:42 -0000
@@ -118,22 +118,18 @@ Boston, MA 02111-1307, USA.  */
    registers will generally not be allocated across a call).
 
    Experimentation has shown slightly better results by allocating
-   FP registers first.  
-
-   FP registers are ordered so that all L registers are selected before
-   R registers.  This works around a false dependency interlock on the
-   PA8000 when accessing the high and low parts of an FP register
-   independently.  */
+   FP registers first.  We allocate the caller-saved registers more
+   or less in reverse order to their allocation as arguments.  */
 
 #define REG_ALLOC_ORDER \
  {					\
   /* caller-saved fp regs.  */		\
   50, 51, 52, 53, 54, 55, 56, 57,	\
-  58, 59, 36, 37, 38, 39, 32, 33,	\
-  34, 35,				\
+  58, 59, 39, 38, 37, 36, 35, 34,	\
+  33, 32,				\
   /* caller-saved general regs.  */	\
-  19, 20, 21, 22, 23, 24, 25, 26,	\
-  27, 28, 29, 31,  2,			\
+  28, 31, 19, 20, 21, 22, 23, 24,	\
+  25, 26, 29,  2,			\
   /* callee-saved fp regs.  */		\
   40, 41, 42, 43, 44, 45, 46, 47,	\
   48, 49,				\
@@ -141,7 +137,7 @@ Boston, MA 02111-1307, USA.  */
    3,  4,  5,  6,  7,  8,  9, 10, 	\
   11, 12, 13, 14, 15, 16, 17, 18,	\
   /* special registers.  */		\
-   1, 30,  0, 60}
+   1, 27, 30,  0, 60}
 
 
 /* Return number of consecutive hard regs needed starting at reg REGNO


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