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]

Re: AM33: Use macros instead of register number constants


On Apr 27, 2000, Jeffrey A Law <law@cygnus.com> wrote:

> You should probably move the definitions of those macros before their
> first uses.

Ok.  Is this necessary from a point-of-view of portability, or is it
just a matter of making the code clearer?

I've realized that I had missed the _REGNUM macros, so I've addressed
this issue, renamed the new (FIRST|LAST)_*_REG macros to *_REGNUM and
I'm now checking in the following patch.

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@cygnus.com>

	* config/mn10300/mn10300.h (FIRST_DATA_REGNUM,
	LAST_DATA_REGNUM, FIRST_ADDRESS_REGNUM, LAST_ADDRESS_REGNUM,
	FIRST_EXTENDED_REGNUM, LAST_EXTENDED_REGNUM): New macros.
	(REGNO_SP_P): Redefine in terms of STACK_POINTER_REGNUM.
	(REGNO_DATA_P, REGNO_ADDRESS_P, REGNO_EXTENDED_P,
	REGNO_AM33_P): Redefine in terms of the new macros.
	(CONDITIONAL_REGISTER_USAGE, REGNO_REG_CLASS): Likewise.
	(FUNCTION_VALUE, LIBCALL_VALUE, FUNCTION_VALUE_REGNO_P,
	STRUCT_VALUE): Likewise.
	(STACK_POINTER_REGNUM, FRAME_POINTER_REGNUM,
	ARG_POINTER_REGNUM, STATIC_CHAIN_REGNUM): Likewise.  Moved.

Index: gcc/config/mn10300/mn10300.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/mn10300/mn10300.h,v
retrieving revision 1.32
diff -u -r1.32 mn10300.h
--- gcc/config/mn10300/mn10300.h	2000/04/26 00:09:52	1.32
+++ gcc/config/mn10300/mn10300.h	2000/04/29 15:16:57
@@ -145,6 +145,31 @@
 
 #define FIRST_PSEUDO_REGISTER 18
 
+/* Specify machine-specific register numbers.  */
+#define FIRST_DATA_REGNUM 0
+#define LAST_DATA_REGNUM 3
+#define FIRST_ADDRESS_REGNUM 4
+#define LAST_ADDRESS_REGNUM 8
+#define FIRST_EXTENDED_REGNUM 10
+#define LAST_EXTENDED_REGNUM 17
+
+/* Specify the registers used for certain standard purposes.
+   The values of these macros are register numbers.  */
+
+/* Register to use for pushing function arguments.  */
+#define STACK_POINTER_REGNUM (LAST_ADDRESS_REGNUM+1)
+
+/* Base register for access to local variables of the function.  */
+#define FRAME_POINTER_REGNUM (LAST_ADDRESS_REGNUM-1)
+
+/* Base register for access to arguments of the function.  This
+   is a fake register and will be eliminated into either the frame
+   pointer or stack pointer.  */
+#define ARG_POINTER_REGNUM LAST_ADDRESS_REGNUM
+
+/* Register in which static-chain is passed to a function.  */
+#define STATIC_CHAIN_REGNUM (FIRST_ADDRESS_REGNUM+1)
+
 /* 1 for registers that have pervasive standard uses
    and are not available for the register allocator.  */
 
@@ -169,7 +194,8 @@
 {						\
   if (!TARGET_AM33)				\
     {						\
-      for (i = 10; i < 18; i++) 		\
+      for (i = FIRST_EXTENDED_REGNUM; 		\
+	   i <= LAST_EXTENDED_REGNUM; i++) 	\
 	fixed_regs[i] = call_used_regs[i] = 1; 	\
     }						\
 }
@@ -272,10 +298,10 @@
    or could index an array.  */
 
 #define REGNO_REG_CLASS(REGNO) \
-  ((REGNO) < 4 ? DATA_REGS : \
-   (REGNO) < 9 ? ADDRESS_REGS : \
-   (REGNO) == 9 ? SP_REGS : \
-   (REGNO) < 18 ? EXTENDED_REGS : \
+  ((REGNO) <= LAST_DATA_REGNUM ? DATA_REGS : \
+   (REGNO) <= LAST_ADDRESS_REGNUM ? ADDRESS_REGS : \
+   (REGNO) == STACK_POINTER_REGNUM ? SP_REGS : \
+   (REGNO) <= LAST_EXTENDED_REGNUM ? EXTENDED_REGS : \
    NO_REGS)
 
 /* The class value for index registers, and the one for base regs.  */
@@ -323,10 +349,14 @@
        && reg_renumber[(regno)] >= (min) && reg_renumber[(regno)] <= (max)))
 #endif
 
-#define REGNO_DATA_P(regno) REGNO_IN_RANGE_P ((regno), 0, 3)
-#define REGNO_ADDRESS_P(regno) REGNO_IN_RANGE_P ((regno), 4, 8)
-#define REGNO_SP_P(regno) REGNO_IN_RANGE_P ((regno), 9, 9)
-#define REGNO_EXTENDED_P(regno) REGNO_IN_RANGE_P ((regno), 10, 17)
+#define REGNO_DATA_P(regno) \
+  REGNO_IN_RANGE_P ((regno), FIRST_DATA_REGNUM, LAST_DATA_REGNUM)
+#define REGNO_ADDRESS_P(regno) \
+  REGNO_IN_RANGE_P ((regno), FIRST_ADDRESS_REGNUM, LAST_ADDRESS_REGNUM)
+#define REGNO_SP_P(regno) \
+  REGNO_IN_RANGE_P ((regno), STACK_POINTER_REGNUM, STACK_POINTER_REGNUM)
+#define REGNO_EXTENDED_P(regno) \
+  REGNO_IN_RANGE_P ((regno), FIRST_EXTENDED_REGNUM, LAST_EXTENDED_REGNUM)
 #define REGNO_AM33_P(regno) \
   (REGNO_DATA_P ((regno)) || REGNO_ADDRESS_P ((regno)) \
    || REGNO_EXTENDED_P ((regno)))
@@ -431,23 +461,6 @@
 
 #define FIRST_PARM_OFFSET(FNDECL) 4
 
-/* Specify the registers used for certain standard purposes.
-   The values of these macros are register numbers.  */
-
-/* Register to use for pushing function arguments.  */
-#define STACK_POINTER_REGNUM 9
-
-/* Base register for access to local variables of the function.  */
-#define FRAME_POINTER_REGNUM 7
-
-/* Base register for access to arguments of the function.  This
-   is a fake register and will be eliminated into either the frame
-   pointer or stack pointer.  */
-#define ARG_POINTER_REGNUM 8
-
-/* Register in which static-chain is passed to a function.  */
-#define STATIC_CHAIN_REGNUM 5
-
 #define ELIMINABLE_REGS				\
 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM},	\
  { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},	\
@@ -554,16 +567,18 @@
    otherwise, FUNC is 0.   */
 
 #define FUNCTION_VALUE(VALTYPE, FUNC) \
-  gen_rtx_REG (TYPE_MODE (VALTYPE), POINTER_TYPE_P (VALTYPE) ? 4 : 0)
+  gen_rtx_REG (TYPE_MODE (VALTYPE), POINTER_TYPE_P (VALTYPE) \
+	       ? FIRST_ADDRESS_REGNUM : FIRST_DATA_REGNUM)
 
 /* Define how to find the value returned by a library function
    assuming the value has mode MODE.  */
 
-#define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, 0)
+#define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, FIRST_DATA_REGNUM)
 
 /* 1 if N is a possible register number for a function value.  */
 
-#define FUNCTION_VALUE_REGNO_P(N) ((N) == 0 || (N) == 4)
+#define FUNCTION_VALUE_REGNO_P(N) \
+  ((N) == FIRST_DATA_REGNUM || (N) == FIRST_ADDRESS_REGNUM)
 
 /* Return values > 8 bytes in length in memory.  */
 #define DEFAULT_PCC_STRUCT_RETURN 0
@@ -574,7 +589,7 @@
    is passed to a function.  On the MN10300 it's passed as
    the first parameter.  */
 
-#define STRUCT_VALUE 0
+#define STRUCT_VALUE FIRST_DATA_REGNUM
 
 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
    the stack pointer does not matter.  The value is tested only in

-- 
Alexandre Oliva    Enjoy Guaranį, see http://www.ic.unicamp.br/~oliva/
Cygnus Solutions, a Red Hat company        aoliva@{redhat, cygnus}.com
Free Software Developer and Evangelist    CS PhD student at IC-Unicamp
oliva@{lsd.ic.unicamp.br, gnu.org}   Write to mailing lists, not to me

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