[Patch, moxie] ABI improvement

Anthony Green green@moxielogic.com
Wed Sep 9 22:11:00 GMT 2009


I am committing this patch which tweaks the ABI used by the moxie port.

The moxie port currently uses up to 5 32-bit registers to pass function
arguments.  This patch increases that to 6, which matches the number of
arguments Linux kernel system calls can take, greatly simplifying the
kernel/C library port.   

AG


2009-09-09  Anthony Green  <green@moxielogic.com>

	* config/moxie/moxie.c (moxie_setup_incoming_varargs): Adjust
	to pass up to 6 32-bit argument values in registers.
	(moxie_function_arg): Ditto.
	(moxie_arg_partial_bytes): Ditto.
	* config/moxie/moxie.h (FUNCTION_ARG_ADVANCE): Ditto.
	(REG_PARM_STACK_SPACE): Ditto.
	(FUNCTION_ARG_REGNO_P): Ditto.


Index: gcc/config/moxie/moxie.c
===================================================================
--- gcc/config/moxie/moxie.c	(revision 151510)
+++ gcc/config/moxie/moxie.c	(working copy)
@@ -359,14 +356,14 @@
 			      int *pretend_size, int no_rtl)
 {
   int regno;
-  int regs = 7 - *cum;
+  int regs = 8 - *cum;
   
   *pretend_size = regs < 0 ? 0 : GET_MODE_SIZE (SImode) * regs;
   
   if (no_rtl)
     return;
   
-  for (regno = *cum; regno < 7; regno++)
+  for (regno = *cum; regno < 8; regno++)
     {
       rtx reg = gen_rtx_REG (SImode, regno);
       rtx slot = gen_rtx_PLUS (Pmode,
@@ -395,7 +392,7 @@
 moxie_function_arg (CUMULATIVE_ARGS cum, enum machine_mode mode,
 		    tree type ATTRIBUTE_UNUSED, int named ATTRIBUTE_UNUSED)
 {
-  if (cum < 7)
+  if (cum < 8)
     return gen_rtx_REG (mode, cum);
   else 
     return NULL_RTX;
@@ -420,7 +417,7 @@
   else
     size = GET_MODE_SIZE (mode);
 
-  return size > 4*5;
+  return size > 4*6;
 }
 
 /* Some function arguments will only partially fit in the registers
@@ -434,7 +431,7 @@
 {
   int bytes_left, size;
 
-  if (*cum >= 7)
+  if (*cum >= 8)
     return 0;
 
   if (moxie_pass_by_reference (cum, mode, type, named))
@@ -448,7 +445,7 @@
   else
     size = GET_MODE_SIZE (mode);
 
-  bytes_left = (4 * 5) - ((*cum - 2) * 4);
+  bytes_left = (4 * 6) - ((*cum - 2) * 4);
 
   if (size > bytes_left)
     return bytes_left;
Index: gcc/config/moxie/moxie.h
===================================================================
--- gcc/config/moxie/moxie.h	(revision 151510)
+++ gcc/config/moxie/moxie.h	(working copy)
@@ -182,7 +182,7 @@
 
 /* A C expression whose value is a register class containing hard
    register REGNO.  */
-#define REGNO_REG_CLASS(R) ((R < MOXIE_PC) ? GENERAL_REGS : \
+#define REGNO_REG_CLASS(R) ((R < MOXIE_PC) ? GENERAL_REGS :		\
                             (R == MOXIE_CC ? CC_REGS : SPECIAL_REGS))
 
 /* A C expression for the number of consecutive hard registers,
@@ -263,7 +263,7 @@
    : (unsigned) int_size_in_bytes (TYPE))
 
 #define FUNCTION_ARG_ADVANCE(CUM,MODE,TYPE,NAMED) \
-  (CUM = (CUM < MOXIE_R5 ?                        \
+  (CUM = (CUM < MOXIE_R6 ?                        \
           CUM + ((3 + MOXIE_FUNCTION_ARG_SIZE(MODE,TYPE))/4) : CUM ))
 
 /* How Scalar Function Values Are Returned */
@@ -299,7 +299,7 @@
 
 /* Define this if it is the responsibility of the caller to allocate
    the area reserved for arguments passed in registers.  */
-#define REG_PARM_STACK_SPACE(FNDECL) (5 * UNITS_PER_WORD)
+#define REG_PARM_STACK_SPACE(FNDECL) (6 * UNITS_PER_WORD)
 
 /* Offset from the argument pointer register to the first argument's
    address.  On some machines it may depend on the data type of the
@@ -463,7 +463,7 @@
 
 /* A C expression that is nonzero if REGNO is the number of a hard
    register in which function arguments are sometimes passed.  */
-#define FUNCTION_ARG_REGNO_P(r) (r >= MOXIE_R0 && r <= MOXIE_R4)
+#define FUNCTION_ARG_REGNO_P(r) (r >= MOXIE_R0 && r <= MOXIE_R5)
 
 /* A C expression that is nonzero if REGNO is the number of a hard
    register in which the values of called function may come back.  */




More information about the Gcc-patches mailing list