[patch] Add moxie-uclinux configuration support. Tweak ABI.

Anthony Green green@moxielogic.com
Fri Jul 31 10:14:00 GMT 2009


I am going to commit the following patch, which does two things for the
moxie port:

1. It adds moxie-uclinux configuration support.

2. It changes the number of function arguments that can be passed in
registers from 2 to 5 (to mach the max # of arguments in Linux kernel
system calls).


AG
-------------- next part --------------
2009-07-31  Anthony Green  <green@moxielogic.com>

	* config/moxie/moxie.c (moxie_expand_prologue): Use $r5 instead of
	$r12 in prologue.
	(moxie_expand_epilogue): Ditto for epilogue.
	(moxie_setup_incoming_varargs): ABI change.  Use 5 registers for
	incoming arguments.
	(moxie_function_arg): Ditto.
	(moxie_pass_by_reference): Ditto.
	(moxie_arg_partial_bytes): Ditto.
	* config/moxie/moxie.h (CALL_USED_REGISTERS): Ditto.
	(FUNCTION_ARG_ADVANCE) Ditto.
	(REG_PARM_STACK_SPACE) Ditto.
	(FUNCTION_ARG_REGNO_P) Dito.

	* config.gcc: Add moxie linux config support.
	* gcc/config/moxie/uclinux.h: New file.

Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 149693)
+++ gcc/config.gcc	(working copy)
@@ -894,6 +894,15 @@
 	extra_parts="crti.o crtn.o crtbegin.o crtend.o"
 	tmake_file="${tmake_file} moxie/t-moxie moxie/t-moxie-softfp soft-fp/t-softfp"
 	;;
+moxie-*-uclinux*)
+	gas=yes
+	gnu_ld=yes
+	tm_file="dbxelf.h elfos.h svr4.h ${tm_file} linux.h glibc-stdint.h moxie/uclinux.h"
+	extra_parts="crti.o crtn.o crtbegin.o crtend.o"
+	tmake_file="${tmake_file} moxie/t-moxie moxie/t-moxie-softfp soft-fp/t-softfp"
+	tm_defines="${tm_defines} UCLIBC_DEFAULT=1"
+	extra_options="${extra_options} linux.opt"
+	;;
 h8300-*-rtems*)
 	tmake_file="h8300/t-h8300 h8300/t-elf t-rtems h8300/t-rtems"
 	tm_file="h8300/h8300.h dbxelf.h elfos.h h8300/elf.h h8300/rtems.h rtems.h newlib-stdint.h"
Index: gcc/config/moxie/moxie.c
===================================================================
--- gcc/config/moxie/moxie.c	(revision 149693)
+++ gcc/config/moxie/moxie.c	(working copy)
@@ -284,12 +284,12 @@
 	{
 	  insn = 
 	    emit_insn (gen_movsi 
-		       (gen_rtx_REG (Pmode, MOXIE_R12), 
+		       (gen_rtx_REG (Pmode, MOXIE_R5), 
 			GEN_INT (-cfun->machine->size_for_adjusting_sp)));
 	  RTX_FRAME_RELATED_P (insn) = 1;
 	  insn = emit_insn (gen_addsi3 (stack_pointer_rtx, 
 					stack_pointer_rtx, 
-					gen_rtx_REG (Pmode, MOXIE_R12)));
+					gen_rtx_REG (Pmode, MOXIE_R5)));
 	  RTX_FRAME_RELATED_P (insn) = 1;
 	}	
     }
@@ -303,7 +303,7 @@
 
   if (cfun->machine->callee_saved_reg_size != 0)
     {
-      reg = gen_rtx_REG (Pmode, MOXIE_R12);
+      reg = gen_rtx_REG (Pmode, MOXIE_R5);
       if (cfun->machine->callee_saved_reg_size <= 255)
 	{
 	  emit_move_insn (reg, hard_frame_pointer_rtx);
@@ -359,14 +359,14 @@
 			      int *pretend_size, int no_rtl)
 {
   int regno;
-  int regs = 4 - *cum;
+  int regs = 7 - *cum;
   
   *pretend_size = regs < 0 ? 0 : GET_MODE_SIZE (SImode) * regs;
   
   if (no_rtl)
     return;
   
-  for (regno = *cum; regno < 4; regno++)
+  for (regno = *cum; regno < 7; regno++)
     {
       rtx reg = gen_rtx_REG (SImode, regno);
       rtx slot = gen_rtx_PLUS (Pmode,
@@ -395,7 +395,7 @@
 moxie_function_arg (CUMULATIVE_ARGS cum, enum machine_mode mode,
 		    tree type ATTRIBUTE_UNUSED, int named ATTRIBUTE_UNUSED)
 {
-  if (cum < 4)
+  if (cum < 7)
     return gen_rtx_REG (mode, cum);
   else 
     return NULL_RTX;
@@ -420,7 +420,7 @@
   else
     size = GET_MODE_SIZE (mode);
 
-  return size > 8;
+  return size > 4*5;
 }
 
 /* Some function arguments will only partially fit in the registers
@@ -434,7 +434,7 @@
 {
   int bytes_left, size;
 
-  if (*cum >= 4)
+  if (*cum >= 7)
     return 0;
 
   if (moxie_pass_by_reference (cum, mode, type, named))
@@ -448,7 +448,7 @@
   else
     size = GET_MODE_SIZE (mode);
 
-  bytes_left = 8 - ((*cum - 2) * 4);
+  bytes_left = (4 * 5) - ((*cum - 2) * 4);
 
   if (size > bytes_left)
     return bytes_left;
Index: gcc/config/moxie/moxie.h
===================================================================
--- gcc/config/moxie/moxie.h	(revision 149693)
+++ gcc/config/moxie/moxie.h	(working copy)
@@ -144,7 +144,7 @@
 
 #define REG_CLASS_CONTENTS \
 { { 0x00000000 }, /* Empty */			   \
-  { 0x0003FFFF }, /* $fp, $sp, $r0 to $r5, ?fp */  \
+  { 0x0003FFFF }, /* $fp, $sp, $r0 to $r13, ?fp */ \
   { 0x00040000 }, /* $pc */	                   \
   { 0x00080000 }, /* ?cc */                        \
   { 0x000FFFFF }  /* All registers */              \
@@ -166,8 +166,8 @@
                               1, 1, 1, 1 }
 
 #define CALL_USED_REGISTERS { 1, 1, 1, 1, \
+			      1, 1, 1, 1, \
 			      0, 0, 0, 0, \
-			      0, 0, 0, 0, \
 			      0, 0, 1, 1, \
                               1, 1, 1, 1 }
 
@@ -263,7 +263,7 @@
    : (unsigned) int_size_in_bytes (TYPE))
 
 #define FUNCTION_ARG_ADVANCE(CUM,MODE,TYPE,NAMED) \
-  (CUM = (CUM < MOXIE_R2 ?                        \
+  (CUM = (CUM < MOXIE_R5 ?                        \
           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) (2 * UNITS_PER_WORD)
+#define REG_PARM_STACK_SPACE(FNDECL) (5 * 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
@@ -425,7 +425,7 @@
 
 /* The register number of the stack pointer register, which must also
    be a fixed register according to `FIXED_REGISTERS'.  */
-#define STACK_POINTER_REGNUM 1
+#define STACK_POINTER_REGNUM MOXIE_SP
 
 /* The register number of the frame pointer register, which is used to
    access automatic variables in the stack frame.  */
@@ -448,17 +448,9 @@
 
 #define HARD_FRAME_POINTER_REGNUM MOXIE_FP
 
-#if 0
 #define ELIMINABLE_REGS							\
-{{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM },			\
- { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM },			\
- { ARG_POINTER_REGNUM,	 STACK_POINTER_REGNUM },			\
- { ARG_POINTER_REGNUM,   HARD_FRAME_POINTER_REGNUM }}			
-#else
-#define ELIMINABLE_REGS							\
 {{ FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM },			\
  { ARG_POINTER_REGNUM,   HARD_FRAME_POINTER_REGNUM }}			
-#endif
 
 /* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'.  It
    specifies the initial difference between the specified pair of
@@ -471,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_R1)
+#define FUNCTION_ARG_REGNO_P(r) (r >= MOXIE_R0 && r <= MOXIE_R4)
 
 /* 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.  */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: uclinux.h
Type: text/x-chdr
Size: 1474 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090731/ff8e8c76/attachment.bin>


More information about the Gcc-patches mailing list