Patchwork [mep] hookize FUNCTION_ARG &co.

login
register
mail settings
Submitter Nathan Froyd
Date Oct. 8, 2010, 1:58 p.m.
Message ID <1286546323-17698-1-git-send-email-froydnj@codesourcery.com>
Download mbox | patch
Permalink /patch/67210/
State New
Headers show

Comments

Nathan Froyd - Oct. 8, 2010, 1:58 p.m.
The patch below hookizes FUNCTION_ARG and related macros for the mep
backend.  Nothing special here.

Tested by inspection with cross to mep-elf.  I plan to commit this
under the obvious rule after waiting a week for comments/approval.

	* config/mep/mep-protos.h (mep_function_arg): Delete.
	(mep_function_arg_advance): Delete.
	* config/mep/mep.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete.
	* config/mep/mep.c (mep_function_arg): Make static.  Take a
	const_tree and a bool.
	(mep_function_arg_advance): Likewise.
	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_ARG_ADVANCE): Define.
---
 gcc/config/mep/mep-protos.h |    2 --
 gcc/config/mep/mep.c        |   37 ++++++++++++++++++++++++++-----------
 gcc/config/mep/mep.h        |   11 -----------
 3 files changed, 26 insertions(+), 24 deletions(-)
DJ Delorie - Oct. 8, 2010, 6:14 p.m.
> Tested by inspection with cross to mep-elf.  I plan to commit this
> under the obvious rule after waiting a week for comments/approval.

Go for it.

> 	* config/mep/mep-protos.h (mep_function_arg): Delete.
> 	(mep_function_arg_advance): Delete.
> 	* config/mep/mep.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete.
> 	* config/mep/mep.c (mep_function_arg): Make static.  Take a
> 	const_tree and a bool.
> 	(mep_function_arg_advance): Likewise.
> 	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_ARG_ADVANCE): Define.

Patch

diff --git a/gcc/config/mep/mep-protos.h b/gcc/config/mep/mep-protos.h
index 4ab86b5..c8a0b9b 100644
--- a/gcc/config/mep/mep-protos.h
+++ b/gcc/config/mep/mep-protos.h
@@ -75,8 +75,6 @@  extern void mep_print_operand_address (FILE *, rtx);
 extern void mep_print_operand (FILE *, rtx, int);
 extern void mep_final_prescan_insn (rtx, rtx *, int);
 extern void mep_init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree);
-extern rtx mep_function_arg (CUMULATIVE_ARGS, enum machine_mode, tree, int);
-extern void mep_arg_advance (CUMULATIVE_ARGS *, enum machine_mode, tree, int);
 extern bool mep_return_in_memory (const_tree, const_tree);
 extern rtx mep_function_value (tree, tree);
 extern rtx mep_libcall_value (enum machine_mode);
diff --git a/gcc/config/mep/mep.c b/gcc/config/mep/mep.c
index 712abbe..daa56c8 100644
--- a/gcc/config/mep/mep.c
+++ b/gcc/config/mep/mep.c
@@ -216,6 +216,10 @@  static void mep_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode,
 					tree, int *, int);
 static bool mep_pass_by_reference (CUMULATIVE_ARGS * cum, enum machine_mode,
 				   const_tree, bool);
+static rtx mep_function_arg (CUMULATIVE_ARGS *, enum machine_mode,
+			     const_tree, bool);
+static void mep_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
+				      const_tree, bool);
 static bool mep_vector_mode_supported_p (enum machine_mode);
 static bool mep_handle_option (size_t, const char *, int);
 static rtx  mep_allocate_initial_value (rtx);
@@ -3717,23 +3721,29 @@  mep_init_cumulative_args (CUMULATIVE_ARGS *pcum, tree fntype,
     pcum->vliw = 0;
 }
 
-rtx
-mep_function_arg (CUMULATIVE_ARGS cum, enum machine_mode mode,
-		  tree type ATTRIBUTE_UNUSED, int named ATTRIBUTE_UNUSED)
+/* The ABI is thus: Arguments are in $1, $2, $3, $4, stack.  Arguments
+   larger than 4 bytes are passed indirectly.  Return value in 0,
+   unless bigger than 4 bytes, then the caller passes a pointer as the
+   first arg.  For varargs, we copy $1..$4 to the stack.  */
+
+static rtx
+mep_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+		  const_tree type ATTRIBUTE_UNUSED,
+		  bool named ATTRIBUTE_UNUSED)
 {
   /* VOIDmode is a signal for the backend to pass data to the call
      expander via the second operand to the call pattern.  We use
      this to determine whether to use "jsr" or "jsrv".  */
   if (mode == VOIDmode)
-    return GEN_INT (cum.vliw);
+    return GEN_INT (cum->vliw);
 
   /* If we havn't run out of argument registers, return the next.  */
-  if (cum.nregs < 4)
+  if (cum->nregs < 4)
     {
       if (type && TARGET_IVC2 && VECTOR_TYPE_P (type))
-	return gen_rtx_REG (mode, cum.nregs + 49);
+	return gen_rtx_REG (mode, cum->nregs + 49);
       else
-	return gen_rtx_REG (mode, cum.nregs + 1);
+	return gen_rtx_REG (mode, cum->nregs + 1);
     }
 
   /* Otherwise the argument goes on the stack.  */
@@ -3762,10 +3772,11 @@  mep_pass_by_reference (CUMULATIVE_ARGS * cum ATTRIBUTE_UNUSED,
   return true;
 }
 
-void
-mep_arg_advance (CUMULATIVE_ARGS *pcum,
-		 enum machine_mode mode ATTRIBUTE_UNUSED,
-		 tree type ATTRIBUTE_UNUSED, int named ATTRIBUTE_UNUSED)
+static void
+mep_function_arg_advance (CUMULATIVE_ARGS *pcum,
+			  enum machine_mode mode ATTRIBUTE_UNUSED,
+			  const_tree type ATTRIBUTE_UNUSED,
+			  bool named ATTRIBUTE_UNUSED)
 {
   pcum->nregs += 1;
 }
@@ -7405,6 +7416,10 @@  mep_asm_init_sections (void)
 #define TARGET_SETUP_INCOMING_VARARGS	mep_setup_incoming_varargs
 #undef  TARGET_PASS_BY_REFERENCE
 #define TARGET_PASS_BY_REFERENCE        mep_pass_by_reference
+#undef  TARGET_FUNCTION_ARG
+#define TARGET_FUNCTION_ARG             mep_function_arg
+#undef  TARGET_FUNCTION_ARG_ADVANCE
+#define TARGET_FUNCTION_ARG_ADVANCE     mep_function_arg_advance
 #undef  TARGET_VECTOR_MODE_SUPPORTED_P
 #define TARGET_VECTOR_MODE_SUPPORTED_P	mep_vector_mode_supported_p
 #undef  TARGET_HANDLE_OPTION
diff --git a/gcc/config/mep/mep.h b/gcc/config/mep/mep.h
index ad2cf30..07f0c85 100644
--- a/gcc/config/mep/mep.h
+++ b/gcc/config/mep/mep.h
@@ -499,14 +499,6 @@  extern unsigned int mep_selected_isa;
 
 
 
-/* The ABI is thus: Arguments are in $1, $2, $3, $4, stack.  Arguments
-   larger than 4 bytes are passed indirectly.  Return value in 0,
-   unless bigger than 4 bytes, then the caller passes a pointer as the
-   first arg.  For varargs, we copy $1..$4 to the stack.  */
-
-#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
-	mep_function_arg (CUM, MODE, TYPE, NAMED)
-
 #define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) 1
 
 typedef struct
@@ -518,9 +510,6 @@  typedef struct
 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
 	mep_init_cumulative_args (& (CUM), FNTYPE, LIBNAME, FNDECL)
 
-#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)		\
-	mep_arg_advance (& (CUM), MODE, TYPE, NAMED)
-
 #define FUNCTION_ARG_REGNO_P(REGNO) \
 	(((REGNO) >= 1 && (REGNO) <= 4) \
 	 || ((REGNO) >= FIRST_CR_REGNO + 1 \