Patchwork [rs6000] hookize FUNCTION_ARG &co.

login
register
mail settings
Submitter Nathan Froyd
Date Aug. 24, 2010, 8:50 p.m.
Message ID <20100824205013.GR25394@codesourcery.com>
Download mbox | patch
Permalink /patch/62624/
State New
Headers show

Comments

Nathan Froyd - Aug. 24, 2010, 8:50 p.m.
The patch below hookizes FUNCTION_ARG and related macros for the rs6000
backend.  There's a bit of churn to make sure we don't get warnings from
passing const_trees around and using bools instead of ints, but nothing
major.  I *think* the `depth' argument for rs6000_function_arg_advance_1
is bogus and can be removed, but that's a reasonable follow-up patch.
AFAICS, it's never called recursively.

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

-Nathan

	* rs6000.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete.
	* rs6000-protos.h (function_arg_advance, function_arg): Delete.
	(function_arg_boundary): Take a const_tree.
	* rs6000.c (function_arg_boundary): Likewise.
	(rs6000_spe_function_arg): Likewise.
	(rs6000_parm_start): Likewise.
	(rs6000_arg_size): Likewise.
	(rs6000_darwin64_record_arg_advance_recurse): Likewise.
	(rs6000_darwin64_record_arg): Likewise.  Take a bool instead of
	an int.
	(rs6000_mixed_function_arg): Likewise.
	(function_arg): Rename to...
	(rs6000_function_arg): ...this.
	(function_arg_advance): Rename to...
	(rs6000_function_arg_advance_1): ...this
	(rs6000_function_arg_advance): New function.  Call it.
	(setup_incoming_varargs): Call rs6000_function_arg_advance_1.
	(rs6000_return_in_memory): Adjust call to rs6000_darwin64_record_arg.
	(rs6000_function_value): Likewise.
David Edelsohn - Aug. 24, 2010, 11:59 p.m.
On Tue, Aug 24, 2010 at 4:50 PM, Nathan Froyd <froydnj@codesourcery.com> wrote:
> The patch below hookizes FUNCTION_ARG and related macros for the rs6000
> backend.  There's a bit of churn to make sure we don't get warnings from
> passing const_trees around and using bools instead of ints, but nothing
> major.  I *think* the `depth' argument for rs6000_function_arg_advance_1
> is bogus and can be removed, but that's a reasonable follow-up patch.
> AFAICS, it's never called recursively.
>
> Tested on powerpc-eabispe.  I plan to commit this under the obvious rule
> after waiting for a week for comments.
>
> -Nathan
>
>        * rs6000.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete.
>        * rs6000-protos.h (function_arg_advance, function_arg): Delete.
>        (function_arg_boundary): Take a const_tree.
>        * rs6000.c (function_arg_boundary): Likewise.
>        (rs6000_spe_function_arg): Likewise.
>        (rs6000_parm_start): Likewise.
>        (rs6000_arg_size): Likewise.
>        (rs6000_darwin64_record_arg_advance_recurse): Likewise.
>        (rs6000_darwin64_record_arg): Likewise.  Take a bool instead of
>        an int.
>        (rs6000_mixed_function_arg): Likewise.
>        (function_arg): Rename to...
>        (rs6000_function_arg): ...this.
>        (function_arg_advance): Rename to...
>        (rs6000_function_arg_advance_1): ...this
>        (rs6000_function_arg_advance): New function.  Call it.
>        (setup_incoming_varargs): Call rs6000_function_arg_advance_1.
>        (rs6000_return_in_memory): Adjust call to rs6000_darwin64_record_arg.
>        (rs6000_function_value): Likewise.

Okay.

A sanity check on ppc64-linux would be nice.

Thanks, David
Nathan Froyd - Aug. 27, 2010, 2:49 p.m.
On Tue, Aug 24, 2010 at 07:59:52PM -0400, David Edelsohn wrote:
> On Tue, Aug 24, 2010 at 4:50 PM, Nathan Froyd <froydnj@codesourcery.com> wrote:
> > The patch below hookizes FUNCTION_ARG and related macros for the rs6000
> > backend.  There's a bit of churn to make sure we don't get warnings from
> > passing const_trees around and using bools instead of ints, but nothing
> > major.  I *think* the `depth' argument for rs6000_function_arg_advance_1
> > is bogus and can be removed, but that's a reasonable follow-up patch.
> > AFAICS, it's never called recursively.
> 
> Okay.
> 
> A sanity check on ppc64-linux would be nice.

Sanity-checked by bootstrapping on ppc64-linux.  Thanks.

-Nathan

Patch

diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h
index 8708acc..79370d8 100644
--- a/gcc/config/rs6000/rs6000-protos.h
+++ b/gcc/config/rs6000/rs6000-protos.h
@@ -136,10 +136,7 @@  extern unsigned int rs6000_special_round_type_align (tree, unsigned int,
 						     unsigned int);
 extern unsigned int darwin_rs6000_special_round_type_align (tree, unsigned int,
 							    unsigned int);
-extern void function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
-				  tree, int, int);
-extern int function_arg_boundary (enum machine_mode, tree);
-extern rtx function_arg (CUMULATIVE_ARGS *, enum machine_mode, tree, int);
+extern int function_arg_boundary (enum machine_mode, const_tree);
 extern tree altivec_resolve_overloaded_builtin (location_t, tree, void *);
 extern rtx rs6000_libcall_value (enum machine_mode);
 extern rtx rs6000_va_arg (tree, tree);
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 95968a8..c5ed8d6 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -1155,20 +1155,25 @@  static int rs6000_tls_symbol_ref_1 (rtx *, void *);
 static const char *rs6000_get_some_local_dynamic_name (void);
 static int rs6000_get_some_local_dynamic_name_1 (rtx *, void *);
 static rtx rs6000_complex_function_value (enum machine_mode);
-static rtx rs6000_spe_function_arg (CUMULATIVE_ARGS *,
-				    enum machine_mode, tree);
+static rtx rs6000_spe_function_arg (const CUMULATIVE_ARGS *,
+				    enum machine_mode, const_tree);
 static void rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *,
 						      HOST_WIDE_INT, int);
 static void rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *,
-							tree, HOST_WIDE_INT);
+							const_tree,
+							HOST_WIDE_INT);
 static void rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *,
 					      HOST_WIDE_INT,
 					      rtx[], int *);
 static void rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *,
 						const_tree, HOST_WIDE_INT,
 						rtx[], int *);
-static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, const_tree, int, bool);
-static rtx rs6000_mixed_function_arg (enum machine_mode, tree, int);
+static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, const_tree, bool, bool);
+static rtx rs6000_mixed_function_arg (enum machine_mode, const_tree, int);
+static void rs6000_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
+					 const_tree, bool);
+static rtx rs6000_function_arg (CUMULATIVE_ARGS *, enum machine_mode,
+				const_tree, bool);
 static void rs6000_move_block_from_reg (int regno, rtx x, int nregs);
 static void setup_incoming_varargs (CUMULATIVE_ARGS *,
 				    enum machine_mode, tree,
@@ -1554,6 +1559,10 @@  static const struct attribute_spec rs6000_attribute_table[] =
 #define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference
 #undef TARGET_ARG_PARTIAL_BYTES
 #define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes
+#undef TARGET_FUNCTION_ARG_ADVANCE
+#define TARGET_FUNCTION_ARG_ADVANCE rs6000_function_arg_advance
+#undef TARGET_FUNCTION_ARG
+#define TARGET_FUNCTION_ARG rs6000_function_arg
 
 #undef TARGET_BUILD_BUILTIN_VA_LIST
 #define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list
@@ -7466,7 +7475,7 @@  rs6000_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED)
       valcum.vregno = ALTIVEC_ARG_MIN_REG;
       /* Do a trial code generation as if this were going to be passed
 	 as an argument; if any part goes in memory, we return NULL.  */
-      valret = rs6000_darwin64_record_arg (&valcum, type, 1, true);
+      valret = rs6000_darwin64_record_arg (&valcum, type, true, true);
       if (valret)
 	return false;
       /* Otherwise fall through to more conventional ABI rules.  */
@@ -7650,7 +7659,7 @@  function_arg_padding (enum machine_mode mode, const_tree type)
    Quadword align large synthetic vector types.   */
 
 int
-function_arg_boundary (enum machine_mode mode, tree type)
+function_arg_boundary (enum machine_mode mode, const_tree type)
 {
   if (DEFAULT_ABI == ABI_V4
       && (GET_MODE_SIZE (mode) == 8
@@ -7680,7 +7689,8 @@  function_arg_boundary (enum machine_mode mode, tree type)
    the parameter area.  NWORDS of the parameter area are already used.  */
 
 static unsigned int
-rs6000_parm_start (enum machine_mode mode, tree type, unsigned int nwords)
+rs6000_parm_start (enum machine_mode mode, const_tree type,
+		   unsigned int nwords)
 {
   unsigned int align;
   unsigned int parm_offset;
@@ -7693,7 +7703,7 @@  rs6000_parm_start (enum machine_mode mode, tree type, unsigned int nwords)
 /* Compute the size (in words) of a function argument.  */
 
 static unsigned long
-rs6000_arg_size (enum machine_mode mode, tree type)
+rs6000_arg_size (enum machine_mode mode, const_tree type)
 {
   unsigned long size;
 
@@ -7771,7 +7781,7 @@  rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *cum,
 
 static void
 rs6000_darwin64_record_arg_advance_recurse (CUMULATIVE_ARGS *cum,
-					    tree type,
+					    const_tree type,
 					    HOST_WIDE_INT startbitpos)
 {
   tree f;
@@ -7867,9 +7877,9 @@  rs6000_darwin64_struct_check_p (enum machine_mode mode, const_tree type)
    with MODE and TYPE set to that of the pointer to the arg, not the arg
    itself.  */
 
-void
-function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
-		      tree type, int named, int depth)
+static void
+rs6000_function_arg_advance_1 (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+			       const_tree type, bool named, int depth)
 {
 
   /* Only tick off an argument if we're not recursing.  */
@@ -8062,6 +8072,13 @@  function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
     }
 }
 
+static void
+rs6000_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+			     const_tree type, bool named)
+{
+  rs6000_function_arg_advance_1 (cum, mode, type, named, 0);
+}
+
 static rtx
 spe_build_register_parallel (enum machine_mode mode, int gregno)
 {
@@ -8100,8 +8117,8 @@  spe_build_register_parallel (enum machine_mode mode, int gregno)
 
 /* Determine where to put a SIMD argument on the SPE.  */
 static rtx
-rs6000_spe_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
-			 tree type)
+rs6000_spe_function_arg (const CUMULATIVE_ARGS *cum, enum machine_mode mode,
+			 const_tree type)
 {
   int gregno = cum->sysv_gregno;
 
@@ -8296,7 +8313,7 @@  rs6000_darwin64_record_arg_recurse (CUMULATIVE_ARGS *cum, const_tree type,
 
 static rtx
 rs6000_darwin64_record_arg (CUMULATIVE_ARGS *orig_cum, const_tree type,
-			    int named, bool retval)
+			    bool named, bool retval)
 {
   rtx rvec[FIRST_PSEUDO_REGISTER];
   int k = 1, kbase = 1;
@@ -8341,7 +8358,8 @@  rs6000_darwin64_record_arg (CUMULATIVE_ARGS *orig_cum, const_tree type,
 /* Determine where to place an argument in 64-bit mode with 32-bit ABI.  */
 
 static rtx
-rs6000_mixed_function_arg (enum machine_mode mode, tree type, int align_words)
+rs6000_mixed_function_arg (enum machine_mode mode, const_tree type,
+			   int align_words)
 {
   int n_units;
   int i, k;
@@ -8412,9 +8430,9 @@  rs6000_mixed_function_arg (enum machine_mode mode, tree type, int align_words)
    with MODE and TYPE set to that of the pointer to the arg, not the arg
    itself.  */
 
-rtx
-function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
-	      tree type, int named)
+static rtx
+rs6000_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+		     const_tree type, bool named)
 {
   enum rs6000_abi abi = DEFAULT_ABI;
 
@@ -8861,7 +8879,7 @@  setup_incoming_varargs (CUMULATIVE_ARGS *cum, enum machine_mode mode,
 
   /* Skip the last named argument.  */
   next_cum = *cum;
-  function_arg_advance (&next_cum, mode, type, 1, 0);
+  rs6000_function_arg_advance_1 (&next_cum, mode, type, true, 0);
 
   if (DEFAULT_ABI == ABI_V4)
     {
@@ -26584,7 +26602,7 @@  rs6000_function_value (const_tree valtype,
       valcum.vregno = ALTIVEC_ARG_MIN_REG;
       /* Do a trial code generation as if this were going to be passed as
 	 an argument; if any part goes in memory, we return NULL.  */
-      valret = rs6000_darwin64_record_arg (&valcum, valtype, 1, true);
+      valret = rs6000_darwin64_record_arg (&valcum, valtype, true, true);
       if (valret)
 	return valret;
       /* Otherwise fall through to standard ABI rules.  */
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 6065463..5058fb5 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -1696,38 +1696,6 @@  typedef struct rs6000_args
 #define INIT_CUMULATIVE_LIBCALL_ARGS(CUM, MODE, LIBNAME) \
   init_cumulative_args (&CUM, NULL_TREE, LIBNAME, FALSE, TRUE, 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)	\
-  function_arg_advance (&CUM, MODE, TYPE, NAMED, 0)
-
-/* Determine where to put an argument 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).
-
-   On RS/6000 the first eight words of non-FP are normally in registers
-   and the rest are pushed.  The first 13 FP args are in registers.
-
-   If this is floating-point and no prototype is specified, we use
-   both an FP and integer register (or possibly FP reg and stack).  Library
-   functions (when TYPE is zero) always have the proper types for args,
-   so we can pass the FP value just in one register.  emit_library_function
-   doesn't support EXPR_LIST anyway.  */
-
-#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
-  function_arg (&CUM, MODE, TYPE, NAMED)
-
 /* If defined, a C expression which determines whether, and in which
    direction, to pad out an argument with extra space.  The value
    should be of type `enum direction': either `upward' to pad above