diff mbox

[v850] hookize FUNCTION_ARG &co.

Message ID 20100831141045.GV16898@codesourcery.com
State New
Headers show

Commit Message

Nathan Froyd Aug. 31, 2010, 2:10 p.m. UTC
This patch hookizes FUNCTION_ARG and related macros for the v850 backend.

Tested on v850-elf.  I plan to commit this under the obvious rule after
waiting a week for comments.

-Nathan

	* config/v850/v850-protos.h (function_arg): Delete.
	* config/v850/v850.h (FUNCTION_ARG): Delete.
	(FUNCTION_ARG_ADVANCE): Move code to...
	* config/v850/v850.c (v850_function_arg_advance): ...here.
	(v850_function_arg): Make static.  Take a const_tree and a bool.
	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_ARG_ADVANCE): Define.

Comments

Nick Clifton Aug. 31, 2010, 2:12 p.m. UTC | #1
Hi Nathan,

> Tested on v850-elf.  I plan to commit this under the obvious rule after
> waiting a week for comments.

You can commit it now if you like.

> 	* config/v850/v850-protos.h (function_arg): Delete.
> 	* config/v850/v850.h (FUNCTION_ARG): Delete.
> 	(FUNCTION_ARG_ADVANCE): Move code to...
> 	* config/v850/v850.c (v850_function_arg_advance): ...here.
> 	(v850_function_arg): Make static.  Take a const_tree and a bool.
> 	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_ARG_ADVANCE): Define.

Cheers
   Nick
diff mbox

Patch

diff --git a/gcc/config/v850/v850-protos.h b/gcc/config/v850/v850-protos.h
index 3fe0879..7d26e05 100644
--- a/gcc/config/v850/v850-protos.h
+++ b/gcc/config/v850/v850-protos.h
@@ -48,11 +48,8 @@  extern int    v850_float_nz_comparison_operator (rtx, Mmode);
 extern rtx    v850_gen_compare              (enum rtx_code, Mmode, rtx, rtx);
 extern Mmode  v850_gen_float_compare (enum rtx_code, Mmode, rtx, rtx);
 extern Mmode  v850_select_cc_mode (RTX_CODE, rtx, rtx);
-#ifdef TREE_CODE
-extern rtx    function_arg                  (CUMULATIVE_ARGS *, Mmode, tree, int);
-#endif
 #endif
-#endif /* TREE_CODE */
+#endif /* RTX_CODE */
 
 #ifdef TREE_CODE
 extern int    v850_interrupt_function_p     (tree);
diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c
index 0879726..8f8cd14 100644
--- a/gcc/config/v850/v850.c
+++ b/gcc/config/v850/v850.c
@@ -75,6 +75,10 @@  static bool v850_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
 static int v850_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
 				   tree, bool);
 static bool v850_strict_argument_naming (CUMULATIVE_ARGS *);
+static rtx v850_function_arg (CUMULATIVE_ARGS *, enum machine_mode,
+			      const_tree, bool);
+static void v850_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
+				       const_tree, bool);
 static bool v850_can_eliminate       (const int, const int);
 static void v850_asm_trampoline_template (FILE *);
 static void v850_trampoline_init (rtx, tree, rtx);
@@ -197,6 +201,12 @@  static const struct attribute_spec v850_attribute_table[] =
 #undef TARGET_ARG_PARTIAL_BYTES
 #define TARGET_ARG_PARTIAL_BYTES v850_arg_partial_bytes
 
+#undef TARGET_FUNCTION_ARG
+#define TARGET_FUNCTION_ARG v850_function_arg
+
+#undef TARGET_FUNCTION_ARG_ADVANCE
+#define TARGET_FUNCTION_ARG_ADVANCE v850_function_arg_advance
+
 #undef TARGET_CAN_ELIMINATE
 #define TARGET_CAN_ELIMINATE v850_can_eliminate
 
@@ -299,11 +309,9 @@  v850_strict_argument_naming (CUMULATIVE_ARGS * ca ATTRIBUTE_UNUSED)
    and type TYPE will be passed to a function.  If the result
    is NULL_RTX, the argument will be pushed.  */
 
-rtx
-function_arg (CUMULATIVE_ARGS * cum,
-              enum machine_mode mode,
-              tree type,
-              int named)
+static rtx
+v850_function_arg (CUMULATIVE_ARGS * cum, enum machine_mode mode,
+		   const_tree type, bool named)
 {
   rtx result = NULL_RTX;
   int size, align;
@@ -399,6 +407,22 @@  v850_arg_partial_bytes (CUMULATIVE_ARGS * cum, enum machine_mode mode,
   return 4 * UNITS_PER_WORD - cum->nbytes;
 }
 
+/* Update the data in CUM to advance over an argument
+   of mode MODE and data type TYPE.
+   (TYPE is null for libcalls where that information may not be available.)  */
+
+static void
+v850_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+			   const_tree type, bool named ATTRIBUTE_UNUSED)
+{
+  cum->nbytes += (((type && int_size_in_bytes (type) > 8
+		    ? GET_MODE_SIZE (Pmode)
+		    : (mode != BLKmode
+		       ? GET_MODE_SIZE (mode)
+		       : int_size_in_bytes (type))) + UNITS_PER_WORD - 1)
+		  & -UNITS_PER_WORD);
+}
+
 /* Return the high and low words of a CONST_DOUBLE */
 
 static void
diff --git a/gcc/config/v850/v850.h b/gcc/config/v850/v850.h
index 1a3905f..1fb87f3 100644
--- a/gcc/config/v850/v850.h
+++ b/gcc/config/v850/v850.h
@@ -608,22 +608,6 @@  enum reg_class
 #define CUMULATIVE_ARGS struct cum_arg
 struct cum_arg { int nbytes; int anonymous_args; };
 
-/* Define where to put the arguments to a function.
-   Value is zero to push the argument on the stack,
-   or a hard register in which to store the argument.
-
-   MODE is the argument's machine mode.
-   TYPE is the data type of the argument (as a tree).
-    This is null for libcalls where that information may
-    not be available.
-   CUM is a variable of type CUMULATIVE_ARGS which gives info about
-    the preceding args and about the function being called.
-   NAMED is nonzero if this argument is a named parameter
-    (otherwise it is an extra parameter matching an ellipsis).  */
-
-#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
-  function_arg (&CUM, MODE, TYPE, NAMED)
-
 /* Initialize a variable CUM of type CUMULATIVE_ARGS
    for a call to a function whose data type is FNTYPE.
    For a library call, FNTYPE is 0.  */
@@ -631,18 +615,6 @@  struct cum_arg { int nbytes; int anonymous_args; };
 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
  ((CUM).nbytes = 0, (CUM).anonymous_args = 0)
 
-/* Update the data in CUM to advance over an argument
-   of mode MODE and data type TYPE.
-   (TYPE is null for libcalls where that information may not be available.)  */
-#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)			\
- ((CUM).nbytes +=							\
-  ((((TYPE) && int_size_in_bytes (TYPE) > 8)				\
-   ? GET_MODE_SIZE (Pmode)						\
-   : ((MODE) != BLKmode							\
-      ? GET_MODE_SIZE ((MODE))						\
-      : int_size_in_bytes ((TYPE))))					\
-   + UNITS_PER_WORD - 1) & -UNITS_PER_WORD)
-
 /* When a parameter is passed in a register, stack space is still
    allocated for it.  */
 #define REG_PARM_STACK_SPACE(DECL) 0