diff mbox

[alpha] hookize FUNCTION_ARG &co.

Message ID 1286546300-17366-1-git-send-email-froydnj@codesourcery.com
State New
Headers show

Commit Message

Nathan Froyd Oct. 8, 2010, 1:58 p.m. UTC
The patch below hookizes FUNCTION_ARG and related macros for the alpha
backend.  The only odd thing is the deletion of the TARGET_ABI_UNICOSMK
hunk in alpha_function_arg, which I suppose could (ought to?) be left
in.  AFAICS, though, that code is dead.

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

	* config/alpha/alpha-protos.h (function_arg): Delete.
	* config/alpha/alpha.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete.
	* config/alpha/vms.h (FUNCTION_ARG_ADVANCE): Delete.
	* config/alpha/alpha.c (function_arg): Rename to...
	(alpha_function_arg): ...this.  Make static.  Take a const_tree and
	a bool.  Delete TARGET_ABI_UNICOSMK code.
	(alpha_function_arg_advance): New function.
	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_ARG_ADVANCE): Define.
---
 gcc/config/alpha/alpha-protos.h |    1 -
 gcc/config/alpha/alpha.c        |  112 ++++++++++++++-------------------------
 gcc/config/alpha/alpha.h        |   28 ----------
 gcc/config/alpha/vms.h          |   12 ----
 4 files changed, 39 insertions(+), 114 deletions(-)

Comments

Joseph Myers Oct. 8, 2010, 3:05 p.m. UTC | #1
On Fri, 8 Oct 2010, Nathan Froyd wrote:

> The patch below hookizes FUNCTION_ARG and related macros for the alpha
> backend.  The only odd thing is the deletion of the TARGET_ABI_UNICOSMK
> hunk in alpha_function_arg, which I suppose could (ought to?) be left
> in.  AFAICS, though, that code is dead.

I noted in the relevant deprecated target removal patch 
<http://gcc.gnu.org/ml/gcc-patches/2008-05/msg01345.html> that I was 
leaving UNICOS/mk removal to target maintainers.
Richard Henderson Oct. 8, 2010, 3:24 p.m. UTC | #2
On 10/08/2010 06:58 AM, Nathan Froyd wrote:
> 	* config/alpha/alpha-protos.h (function_arg): Delete.
> 	* config/alpha/alpha.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete.
> 	* config/alpha/vms.h (FUNCTION_ARG_ADVANCE): Delete.
> 	* config/alpha/alpha.c (function_arg): Rename to...
> 	(alpha_function_arg): ...this.  Make static.  Take a const_tree and
> 	a bool.  Delete TARGET_ABI_UNICOSMK code.
> 	(alpha_function_arg_advance): New function.
> 	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_ARG_ADVANCE): Define.

Ok with,

> +alpha_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
> +			    const_tree type, bool named)
> +{
> +#if TARGET_ABI_OPEN_VMS
> +  if (targetm.calls.must_pass_in_stack (mode, type))
> +    cum->num_args += 6;
> +  else
> +    {
> +      if (cum->num_args < 6)
> +	cum->atypes[cum->num_args] = alpha_arg_type (mode);
> +
> +      cum->num_args += ALPHA_ARG_SIZE (mode, type, named);
> +    }
> +#elif TARGET_ABI_OSF
> +  *cum += (targetm.calls.must_pass_in_stack (mode, type)
> +	   ? 6
> +	   : ALPHA_ARG_SIZE (mode, type, named));
> +#else
> +#error Unhandled ABI
> +#endif

Move the TARGET_ABI_OPEN_VMS in, around the atypes bit.
That shares the common code along the vms/osf paths.
Don't bother with the #error.


r~
Nathan Froyd Oct. 8, 2010, 6:58 p.m. UTC | #3
On Fri, Oct 08, 2010 at 08:24:47AM -0700, Richard Henderson wrote:
> On 10/08/2010 06:58 AM, Nathan Froyd wrote:
> > +alpha_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
> > +			    const_tree type, bool named)
> > +{
> > +#if TARGET_ABI_OPEN_VMS
> > +  if (targetm.calls.must_pass_in_stack (mode, type))
> > +    cum->num_args += 6;
> > +  else
> > +    {
> > +      if (cum->num_args < 6)
> > +	cum->atypes[cum->num_args] = alpha_arg_type (mode);
> > +
> > +      cum->num_args += ALPHA_ARG_SIZE (mode, type, named);
> > +    }
> > +#elif TARGET_ABI_OSF
> > +  *cum += (targetm.calls.must_pass_in_stack (mode, type)
> > +	   ? 6
> > +	   : ALPHA_ARG_SIZE (mode, type, named));
> > +#else
> > +#error Unhandled ABI
> > +#endif
> 
> Move the TARGET_ABI_OPEN_VMS in, around the atypes bit.
> That shares the common code along the vms/osf paths.
> Don't bother with the #error.

Something like:

{
  bool onstack = targetm.calls.must_pass_in_stack (mode, type);
  int increment = onstack ? 6 : ALPHA_ARG_SIZE (mode, type, named);

#if TARGET_ABI_OSF
  *cum += increment;
#else
  if (!onstack && cum->num_args < 6)
    cum->atypes[cum->num_args] = alpha_arg_type (mode);
  cum->num_args += increment;
#endif
}

?

-Nathan
Richard Henderson Oct. 8, 2010, 7:03 p.m. UTC | #4
On 10/08/2010 11:58 AM, Nathan Froyd wrote:
> Something like:
> 
> {
>   bool onstack = targetm.calls.must_pass_in_stack (mode, type);
>   int increment = onstack ? 6 : ALPHA_ARG_SIZE (mode, type, named);
> 
> #if TARGET_ABI_OSF
>   *cum += increment;
> #else
>   if (!onstack && cum->num_args < 6)
>     cum->atypes[cum->num_args] = alpha_arg_type (mode);
>   cum->num_args += increment;
> #endif
> }

That works for me.


r~
diff mbox

Patch

diff --git a/gcc/config/alpha/alpha-protos.h b/gcc/config/alpha/alpha-protos.h
index 4b5e673..7477169 100644
--- a/gcc/config/alpha/alpha-protos.h
+++ b/gcc/config/alpha/alpha-protos.h
@@ -74,7 +74,6 @@  extern void print_operand_address (FILE *, rtx);
 extern void alpha_initialize_trampoline (rtx, rtx, rtx, int, int, int);
 
 extern rtx alpha_va_arg (tree, tree);
-extern rtx function_arg (CUMULATIVE_ARGS, enum machine_mode, tree, int);
 extern rtx function_value (const_tree, const_tree, enum machine_mode);
 
 extern void alpha_start_function (FILE *, const char *, tree);
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 46627e3..def7ef2 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -5634,9 +5634,9 @@  alpha_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
    On Alpha the first 6 words of args are normally in registers
    and the rest are pushed.  */
 
-rtx
-function_arg (CUMULATIVE_ARGS cum, enum machine_mode mode, tree type,
-	      int named ATTRIBUTE_UNUSED)
+static rtx
+alpha_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+		    const_tree type, bool named ATTRIBUTE_UNUSED)
 {
   int basereg;
   int num_args;
@@ -5661,87 +5661,22 @@  function_arg (CUMULATIVE_ARGS cum, enum machine_mode mode, tree type,
     }
 
   /* ??? Irritatingly, the definition of CUMULATIVE_ARGS is different for
-     the three platforms, so we can't avoid conditional compilation.  */
+     the two platforms, so we can't avoid conditional compilation.  */
 #if TARGET_ABI_OPEN_VMS
     {
       if (mode == VOIDmode)
 	return alpha_arg_info_reg_val (cum);
 
-      num_args = cum.num_args;
+      num_args = cum->num_args;
       if (num_args >= 6
 	  || targetm.calls.must_pass_in_stack (mode, type))
 	return NULL_RTX;
     }
-#elif TARGET_ABI_UNICOSMK
-    {
-      int size;
-
-      /* If this is the last argument, generate the call info word (CIW).  */
-      /* ??? We don't include the caller's line number in the CIW because
-	 I don't know how to determine it if debug infos are turned off.  */
-      if (mode == VOIDmode)
-	{
-	  int i;
-	  HOST_WIDE_INT lo;
-	  HOST_WIDE_INT hi;
-	  rtx ciw;
-
-	  lo = 0;
-
-	  for (i = 0; i < cum.num_reg_words && i < 5; i++)
-	    if (cum.reg_args_type[i])
-	      lo |= (1 << (7 - i));
-
-	  if (cum.num_reg_words == 6 && cum.reg_args_type[5])
-	    lo |= 7;
-	  else
-	    lo |= cum.num_reg_words;
-
-#if HOST_BITS_PER_WIDE_INT == 32
-	  hi = (cum.num_args << 20) | cum.num_arg_words;
-#else
-	  lo = lo | ((HOST_WIDE_INT) cum.num_args << 52)
-	    | ((HOST_WIDE_INT) cum.num_arg_words << 32);
-	  hi = 0;
-#endif
-	  ciw = immed_double_const (lo, hi, DImode);
-
-	  return gen_rtx_UNSPEC (DImode, gen_rtvec (1, ciw),
-				 UNSPEC_UMK_LOAD_CIW);
-	}
-
-      size = ALPHA_ARG_SIZE (mode, type, named);
-      num_args = cum.num_reg_words;
-      if (cum.force_stack
-	  || cum.num_reg_words + size > 6
-	  || targetm.calls.must_pass_in_stack (mode, type))
-	return NULL_RTX;
-      else if (type && TYPE_MODE (type) == BLKmode)
-	{
-	  rtx reg1, reg2;
-
-	  reg1 = gen_rtx_REG (DImode, num_args + 16);
-	  reg1 = gen_rtx_EXPR_LIST (DImode, reg1, const0_rtx);
-
-	  /* The argument fits in two registers. Note that we still need to
-	     reserve a register for empty structures.  */
-	  if (size == 0)
-	    return NULL_RTX;
-	  else if (size == 1)
-	    return gen_rtx_PARALLEL (mode, gen_rtvec (1, reg1));
-	  else
-	    {
-	      reg2 = gen_rtx_REG (DImode, num_args + 17);
-	      reg2 = gen_rtx_EXPR_LIST (DImode, reg2, GEN_INT (8));
-	      return gen_rtx_PARALLEL (mode, gen_rtvec (2, reg1, reg2));
-	    }
-	}
-    }
 #elif TARGET_ABI_OSF
     {
-      if (cum >= 6)
+      if (*cum >= 6)
 	return NULL_RTX;
-      num_args = cum;
+      num_args = *cum;
 
       /* VOID is passed as a special flag for "last argument".  */
       if (type == void_type_node)
@@ -5756,6 +5691,33 @@  function_arg (CUMULATIVE_ARGS cum, enum machine_mode mode, tree type,
   return gen_rtx_REG (mode, num_args + basereg);
 }
 
+/* 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
+alpha_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+			    const_tree type, bool named)
+{
+#if TARGET_ABI_OPEN_VMS
+  if (targetm.calls.must_pass_in_stack (mode, type))
+    cum->num_args += 6;
+  else
+    {
+      if (cum->num_args < 6)
+	cum->atypes[cum->num_args] = alpha_arg_type (mode);
+
+      cum->num_args += ALPHA_ARG_SIZE (mode, type, named);
+    }
+#elif TARGET_ABI_OSF
+  *cum += (targetm.calls.must_pass_in_stack (mode, type)
+	   ? 6
+	   : ALPHA_ARG_SIZE (mode, type, named));
+#else
+#error Unhandled ABI
+#endif
+}
+
 static int
 alpha_arg_partial_bytes (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED,
 			 enum machine_mode mode ATTRIBUTE_UNUSED,
@@ -6183,7 +6145,7 @@  alpha_setup_incoming_varargs (CUMULATIVE_ARGS *pcum, enum machine_mode mode,
   CUMULATIVE_ARGS cum = *pcum;
 
   /* Skip the current argument.  */
-  FUNCTION_ARG_ADVANCE (cum, mode, type, 1);
+  targetm.calls.function_arg_advance (cum, mode, type, true);
 
 #if TARGET_ABI_UNICOSMK
   /* On Unicos/Mk, the standard subroutine __T3E_MISMATCH stores all register
@@ -11149,6 +11111,10 @@  alpha_init_libfuncs (void)
 #define TARGET_GIMPLIFY_VA_ARG_EXPR alpha_gimplify_va_arg
 #undef TARGET_ARG_PARTIAL_BYTES
 #define TARGET_ARG_PARTIAL_BYTES alpha_arg_partial_bytes
+#undef TARGET_FUNCTION_ARG
+#define TARGET_FUNCTION_ARG alpha_function_arg
+#undef TARGET_FUNCTION_ARG_ADVANCE
+#define TARGET_FUNCTION_ARG_ADVANCE alpha_function_arg_advance
 #undef TARGET_TRAMPOLINE_INIT
 #define TARGET_TRAMPOLINE_INIT alpha_trampoline_init
 
diff --git a/gcc/config/alpha/alpha.h b/gcc/config/alpha/alpha.h
index bdf3159..66e215a 100644
--- a/gcc/config/alpha/alpha.h
+++ b/gcc/config/alpha/alpha.h
@@ -749,34 +749,6 @@  extern int alpha_memory_latency;
    : (((MODE) == BLKmode ? int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE)) \
       + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
 
-/* 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) += 								\
-   (targetm.calls.must_pass_in_stack (MODE, TYPE))			\
-    ? 6 : ALPHA_ARG_SIZE (MODE, TYPE, NAMED))
-
-/* 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 Alpha the first 6 words of args are normally in registers
-   and the rest are pushed.  */
-
-#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED)	\
-  function_arg((CUM), (MODE), (TYPE), (NAMED))
-
 /* Make (or fake) .linkage entry for function call.
    IS_LOCAL is 0 if name is used in call, 1 if name is used in definition.  */
 
diff --git a/gcc/config/alpha/vms.h b/gcc/config/alpha/vms.h
index 38b2068..2c151a7 100644
--- a/gcc/config/alpha/vms.h
+++ b/gcc/config/alpha/vms.h
@@ -175,18 +175,6 @@  typedef struct {int num_args; enum avms_arg_type atypes[6];} avms_arg_info;
   (CUM).atypes[0] = (CUM).atypes[1] = (CUM).atypes[2] = I64;	\
   (CUM).atypes[3] = (CUM).atypes[4] = (CUM).atypes[5] = I64;
 
-#undef FUNCTION_ARG_ADVANCE
-#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)			\
-  if (targetm.calls.must_pass_in_stack (MODE, TYPE))			\
-    (CUM).num_args += 6;						\
-  else									\
-    {									\
-      if ((CUM).num_args < 6)						\
-        (CUM).atypes[(CUM).num_args] = alpha_arg_type (MODE);		\
-									\
-     (CUM).num_args += ALPHA_ARG_SIZE (MODE, TYPE, NAMED);		\
-    }
-
 #define DEFAULT_PCC_STRUCT_RETURN 0
 
 #undef  ASM_WEAKEN_LABEL