Patchwork [frv] hookize FUNCTION_ARG &co.

login
register
mail settings
Submitter Nathan Froyd
Date Oct. 8, 2010, 1:58 p.m.
Message ID <1286546296-17302-1-git-send-email-froydnj@codesourcery.com>
Download mbox | patch
Permalink /patch/67199/
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 frv
backend.  The only unusual thing is that frv defines both FUNCTION_ARG
and FUNCTION_INCOMING_ARG, but AFAICS, uses the same code for both,
which is really not necessary.  I've left that as-is, but a good
follow-up patch would be to eliminate the extraneous
TARGET_FUNCTION_INCOMING_ARG.

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

	* config/frv/frv-protos.h (frv_function_arg): Delete.
	(frv_function_arg_advance): Delete.
	* config/frv/frv.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete.
	* config/frv/frv.c (frv_function_arg): Rename to...
	(frv_function_arg_1): Make static.  Take const_tree and bool
	arguments.
	(frv_function_arg, frv_function_incoming_arg): New functions.
	(frv_function_arg_advance): Make static.  Take a const_tree and
	a bool.
	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_INCOMING_ARG): Define.
	(TARGET_FUNCTION_ARG_ADVANCE): Define.
---
 gcc/config/frv/frv-protos.h |    7 -------
 gcc/config/frv/frv.c        |   42 +++++++++++++++++++++++++++++++++---------
 gcc/config/frv/frv.h        |   30 +-----------------------------
 3 files changed, 34 insertions(+), 45 deletions(-)

Patch

diff --git a/gcc/config/frv/frv-protos.h b/gcc/config/frv/frv-protos.h
index 68c2a57..af9f1cd 100644
--- a/gcc/config/frv/frv-protos.h
+++ b/gcc/config/frv/frv-protos.h
@@ -53,13 +53,6 @@  extern void frv_init_cumulative_args		(CUMULATIVE_ARGS *, tree,
 						 rtx, tree, int);
 
 extern int frv_function_arg_boundary		(enum machine_mode, tree);
-extern rtx frv_function_arg			(CUMULATIVE_ARGS *,
-						 enum machine_mode,
-						 tree, int, int);
-
-extern void frv_function_arg_advance		(CUMULATIVE_ARGS *,
-						 enum machine_mode,
-						 tree, int);
 extern bool frv_function_value_regno_p		(const unsigned int);
 #endif /* TREE_CODE */
 
diff --git a/gcc/config/frv/frv.c b/gcc/config/frv/frv.c
index 401aeec..db18900 100644
--- a/gcc/config/frv/frv.c
+++ b/gcc/config/frv/frv.c
@@ -389,6 +389,12 @@  static rtx frv_struct_value_rtx			(tree, int);
 static bool frv_must_pass_in_stack (enum machine_mode mode, const_tree type);
 static int frv_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
 				  tree, bool);
+static rtx frv_function_arg (CUMULATIVE_ARGS *, enum machine_mode,
+			     const_tree, bool);
+static rtx frv_function_incoming_arg (CUMULATIVE_ARGS *, enum machine_mode,
+				      const_tree, bool);
+static void frv_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
+				       const_tree, bool);
 static void frv_output_dwarf_dtprel		(FILE *, int, rtx)
   ATTRIBUTE_UNUSED;
 static reg_class_t frv_secondary_reload		(bool, rtx, reg_class_t,
@@ -480,6 +486,12 @@  static bool frv_class_likely_spilled_p 		(reg_class_t);
 #define TARGET_PASS_BY_REFERENCE hook_pass_by_reference_must_pass_in_stack
 #undef TARGET_ARG_PARTIAL_BYTES
 #define TARGET_ARG_PARTIAL_BYTES frv_arg_partial_bytes
+#undef TARGET_FUNCTION_ARG
+#define TARGET_FUNCTION_ARG frv_function_arg
+#undef TARGET_FUNCTION_INCOMING_ARG
+#define TARGET_FUNCTION_INCOMING_ARG frv_function_incoming_arg
+#undef TARGET_FUNCTION_ARG_ADVANCE
+#define TARGET_FUNCTION_ARG_ADVANCE frv_function_arg_advance
 
 #undef TARGET_EXPAND_BUILTIN_SAVEREGS
 #define TARGET_EXPAND_BUILTIN_SAVEREGS frv_expand_builtin_saveregs
@@ -3203,12 +3215,10 @@  frv_function_arg_boundary (enum machine_mode mode ATTRIBUTE_UNUSED,
   return BITS_PER_WORD;
 }
 
-rtx
-frv_function_arg (CUMULATIVE_ARGS *cum,
-                  enum machine_mode mode,
-                  tree type ATTRIBUTE_UNUSED,
-                  int named,
-                  int incoming ATTRIBUTE_UNUSED)
+static rtx
+frv_function_arg_1 (const CUMULATIVE_ARGS *cum, enum machine_mode mode,
+		    const_tree type ATTRIBUTE_UNUSED, bool named,
+		    bool incoming ATTRIBUTE_UNUSED)
 {
   enum machine_mode xmode = (mode == BLKmode) ? SImode : mode;
   int arg_num = *cum;
@@ -3242,6 +3252,20 @@  frv_function_arg (CUMULATIVE_ARGS *cum,
   return ret;
 }
 
+static rtx
+frv_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+		  const_tree type, bool named)
+{
+  return frv_function_arg_1 (cum, mode, type, named, false);
+}
+
+static rtx
+frv_function_incoming_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+			   const_tree type, bool named)
+{
+  return frv_function_arg_1 (cum, mode, type, named, true);
+}
+
 
 /* A C statement (sans semicolon) to update the summarizer variable CUM to
    advance past an argument in the argument list.  The values MODE, TYPE and
@@ -3252,11 +3276,11 @@  frv_function_arg (CUMULATIVE_ARGS *cum,
    the stack.  The compiler knows how to track the amount of stack space used
    for arguments without any special help.  */
 
-void
+static void
 frv_function_arg_advance (CUMULATIVE_ARGS *cum,
                           enum machine_mode mode,
-                          tree type ATTRIBUTE_UNUSED,
-                          int named)
+                          const_tree type ATTRIBUTE_UNUSED,
+                          bool named)
 {
   enum machine_mode xmode = (mode == BLKmode) ? SImode : mode;
   int bytes = GET_MODE_SIZE (xmode);
diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h
index bf433d9..b2dfc14 100644
--- a/gcc/config/frv/frv.h
+++ b/gcc/config/frv/frv.h
@@ -1573,23 +1573,6 @@  typedef struct frv_stack {
 
 #define FRV_NUM_ARG_REGS        6
 
-#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED)                    \
-  frv_function_arg (&CUM, MODE, TYPE, NAMED, FALSE)
-
-/* Define this macro if the target machine has "register windows", so that the
-   register in which a function sees an arguments is not necessarily the same
-   as the one in which the caller passed the argument.
-
-   For such machines, `FUNCTION_ARG' computes the register in which the caller
-   passes the value, and `FUNCTION_INCOMING_ARG' should be defined in a similar
-   fashion to tell the function being called where the arguments will arrive.
-
-   If `FUNCTION_INCOMING_ARG' is not defined, `FUNCTION_ARG' serves both
-   purposes.  */
-
-#define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED)			\
-  frv_function_arg (&CUM, MODE, TYPE, NAMED, TRUE)
-
 /* A C type for declaring a variable that is used as the first argument of
    `FUNCTION_ARG' and other related values.  For some target machines, the type
    `int' suffices and can hold the number of bytes of argument so far.
@@ -1632,20 +1615,9 @@  typedef struct frv_stack {
 #define INIT_CUMULATIVE_INCOMING_ARGS(CUM, FNTYPE, LIBNAME) \
   frv_init_cumulative_args (&CUM, FNTYPE, LIBNAME, NULL, TRUE)
 
-/* A C statement (sans semicolon) to update the summarizer variable CUM to
-   advance past an argument in the argument list.  The values MODE, TYPE and
-   NAMED describe that argument.  Once this is done, the variable CUM is
-   suitable for analyzing the *following* argument with `FUNCTION_ARG', etc.
-
-   This macro need not do anything if the argument in question was passed on
-   the stack.  The compiler knows how to track the amount of stack space used
-   for arguments without any special help.  */
-#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)			\
-  frv_function_arg_advance (&CUM, MODE, TYPE, NAMED)
-
 /* If defined, a C expression that gives the alignment boundary, in bits, of an
    argument with the specified mode and type.  If it is not defined,
-   `PARM_BOUNDARY' is used for all arguments.  */
+   'PARM_BOUNDARY' is used for all arguments.  */
 
 #define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \
   frv_function_arg_boundary (MODE, TYPE)