Other backend port changes for function args iterator

Michael Meissner michael.meissner@amd.com
Thu Sep 13 04:22:00 GMT 2007


As I mentioned in my SSE5 message, I also committed the basic machine
independent portion of the function argument iterator patch that I submitted in
July.  This patch provides all of the backends that I modified, except for the
i386 and spu.  The i386 bits I committed along with the SSE5 changes.  I
haven't had time to retest these changes for the other backends, so I haven't
committed them yet.  If backend maintainers could test these patches, it would
be useful.  I still haven't written the SPU changes.  I don't recall if the
RS6000 changes in this set includes the support for the intrinsics, but I will
check shortly.

-- 
Michael Meissner, AMD
90 Central Street, MS 83-29, Boxborough, MA, 01719, USA
michael.meissner@amd.com
-------------- next part --------------
2007-09-12  Michael Meissner  <michael.meissner@amd.com>

	* config/sparc/sparc.c (init_cumulative_args): Use prototype_p to
	determine if a function is prototyped.

	* config/avr/avr.c (init_cumulative_args): Use stdarg_p to
	determine if a function has variable arguments.

	* config/c4x/c4x.c (c4x_init_cumulative_args): Use
	FOREACH_FUNCTION_ARGS to iterate over the argument list.  Use
	prototype_p to determine if a function is prototyped.

	* config/iq2000/iq2000.c (init_cumulative_args): Use stdarg_p to
	determine if a function has variable arguments.
	(iq2000_expand_prologue): Ditto.

	* config/mn10300/mn10300.c (mn10300_builtin_saveregs): Use
	stdarg_p to determine if a a function has variable arguments.

	* config/rs6000/rs6000.c (init_cumulative_args): Use prototype_p
	and stdarg_p to determine if a function is prototyped and/or has
	variable arguments.
	(rs6000_function_ok_for_sibcall):  Use FOREACH_FUNCTION_ARGS to
	iterate over the argument list.

	* config/rs6000/rs6000-c.c (altivec_build_resolved_builtin): Use
	FOREACH_FUNCTION_ARGS to iterate over the argument list.
	(altivec_resolve_overloaded_builtin): Ditto.

	* config/arm/arm.c (arm_init_cumulative_args): Use
	FOREACH_FUNCTION_ARGS to iterate over the argument list.

	* config/pa/pa.c (hppa_builtin_saveregs): Use stdarg_p to
	determine if a function has variable arguments.

	* config/pa/pa.h (INIT_CUMULATIVE_ARGS): Use prototype_p and
	function_args_count to determine if the function is prototyped
	and/or has variable arguments.
	
	* config/pa/som.h (ASM_DECLARE_FUNCTION_NAME): Use stdarg_p to
	determine if the function has variable arguments.

	* config/mips/mips.c (init_cumulative_args): Use prototype_p and
	stdarg_p to determine if a function is prototyped and/or has
	variable arguments.

	* config/m68k/m68k.h (RETURN_POPS_ARGS): Use prototype_p and
	stdarg_p.

	* config/ia64/ia64.h (INIT_CUMULATIVE_ARGS): Use prototype_p.

*** gcc/config/sparc/sparc.c.~1~	2007-09-12 22:02:56.445689000 -0400
--- gcc/config/sparc/sparc.c	2007-09-10 13:00:08.289103000 -0400
*************** init_cumulative_args (struct sparc_args 
*** 4461,4467 ****
  		      tree fndecl ATTRIBUTE_UNUSED)
  {
    cum->words = 0;
!   cum->prototype_p = fntype && TYPE_ARG_TYPES (fntype);
    cum->libcall_p = fntype == 0;
  }
  
--- 4461,4467 ----
  		      tree fndecl ATTRIBUTE_UNUSED)
  {
    cum->words = 0;
!   cum->prototype_p = (fntype && prototype_p (fntype));
    cum->libcall_p = fntype == 0;
  }
  
*** gcc/config/i386/netware.c.~1~	2007-09-12 22:02:56.495745000 -0400
--- gcc/config/i386/netware.c	2007-09-10 13:00:13.937746000 -0400
*************** gen_stdcall_or_fastcall_decoration (tree
*** 45,74 ****
       of DECL_ASSEMBLER_NAME.  */
    const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
    char *newsym;
!   tree formal_type = TYPE_ARG_TYPES (TREE_TYPE (decl));
  
!   if (formal_type != NULL_TREE)
      {
        /* These attributes are ignored for variadic functions in
  	 i386.c:ix86_return_pops_args. For compatibility with MS
  	 compiler do not add @0 suffix here.  */ 
!       if (TREE_VALUE (tree_last (formal_type)) != void_type_node)
  	return NULL_TREE;
  
        /* Quit if we hit an incomplete type.  Error is reported
  	 by convert_arguments in c-typeck.c or cp/typeck.c.  */
!       while (TREE_VALUE (formal_type) != void_type_node
! 	     && COMPLETE_TYPE_P (TREE_VALUE (formal_type)))	
  	{
! 	  unsigned parm_size
! 	    = TREE_INT_CST_LOW (TYPE_SIZE (TREE_VALUE (formal_type)));
  
  	  /* Must round up to include padding.  This is done the same
  	     way as in store_one_arg.  */
  	  parm_size = ((parm_size + PARM_BOUNDARY - 1)
  		       / PARM_BOUNDARY * PARM_BOUNDARY);
  	  total += parm_size;
- 	  formal_type = TREE_CHAIN (formal_type);
  	}
      }
  
--- 45,80 ----
       of DECL_ASSEMBLER_NAME.  */
    const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
    char *newsym;
!   tree type = TREE_TYPE (decl);
!   tree arg;
!   function_args_iterator args_iter;
  
!   if (prototype_p (type))
      {
        /* These attributes are ignored for variadic functions in
  	 i386.c:ix86_return_pops_args. For compatibility with MS
  	 compiler do not add @0 suffix here.  */ 
!       if (stdarg_p (type))
  	return NULL_TREE;
  
        /* Quit if we hit an incomplete type.  Error is reported
  	 by convert_arguments in c-typeck.c or cp/typeck.c.  */
!       FOREACH_FUNCTION_ARGS(type, arg, args_iter)
  	{
! 	  unsigned parm_size;
! 
! 	  if (! COMPLETE_TYPE_P (arg))
! 	    break;
! 
! 	  parm_size = int_size_in_bytes (TYPE_SIZE (arg));
! 	  if (parm_size < 0)
! 	    break;
  
  	  /* Must round up to include padding.  This is done the same
  	     way as in store_one_arg.  */
  	  parm_size = ((parm_size + PARM_BOUNDARY - 1)
  		       / PARM_BOUNDARY * PARM_BOUNDARY);
  	  total += parm_size;
  	}
      }
  
*************** gen_regparm_prefix (tree decl, unsigned 
*** 93,120 ****
       of DECL_ASSEMBLER_NAME.  */
    const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
    char *newsym;
!   tree formal_type = TYPE_ARG_TYPES (TREE_TYPE (decl));
  
!   if (formal_type != NULL_TREE)
      {
        /* This attribute is ignored for variadic functions.  */ 
!       if (TREE_VALUE (tree_last (formal_type)) != void_type_node)
  	return NULL_TREE;
  
        /* Quit if we hit an incomplete type.  Error is reported
  	 by convert_arguments in c-typeck.c or cp/typeck.c.  */
!       while (TREE_VALUE (formal_type) != void_type_node
! 	     && COMPLETE_TYPE_P (TREE_VALUE (formal_type)))	
  	{
! 	  unsigned parm_size
! 	    = TREE_INT_CST_LOW (TYPE_SIZE (TREE_VALUE (formal_type)));
  
- 	  /* Must round up to include padding.  This is done the same
- 	     way as in store_one_arg.  */
  	  parm_size = ((parm_size + PARM_BOUNDARY - 1)
  		       / PARM_BOUNDARY * PARM_BOUNDARY);
  	  total += parm_size;
- 	  formal_type = TREE_CHAIN (formal_type);
  	}
      }
  
--- 99,130 ----
       of DECL_ASSEMBLER_NAME.  */
    const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
    char *newsym;
!   tree type = TREE_TYPE (decl);
!   tree arg;
!   function_args_iterator args_iter;
  
!   if (prototype_p (type))
      {
        /* This attribute is ignored for variadic functions.  */ 
!       if (stdarg_p (type))
  	return NULL_TREE;
  
        /* Quit if we hit an incomplete type.  Error is reported
  	 by convert_arguments in c-typeck.c or cp/typeck.c.  */
!       FOREACH_FUNCTION_ARGS(type, arg, args_iter)
  	{
! 	  unsigned parm_size;
! 
! 	  if (! COMPLETE_TYPE_P (arg))
! 	    break;
! 
! 	  parm_size = int_size_in_bytes (arg);
! 	  if (parm_size < 0)
! 	    break;
  
  	  parm_size = ((parm_size + PARM_BOUNDARY - 1)
  		       / PARM_BOUNDARY * PARM_BOUNDARY);
  	  total += parm_size;
  	}
      }
  
*** gcc/config/i386/winnt.c.~1~	2007-09-12 22:02:56.505746000 -0400
--- gcc/config/i386/winnt.c	2007-09-10 13:00:14.279087000 -0400
*************** gen_stdcall_or_fastcall_suffix (tree dec
*** 165,204 ****
    HOST_WIDE_INT total = 0;
    const char *old_str = IDENTIFIER_POINTER (id != NULL_TREE ? id : DECL_NAME (decl));
    char *new_str, *p;
!   tree formal_type;
  
    gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);  
  
!   formal_type = TYPE_ARG_TYPES (TREE_TYPE (decl));
!   if (formal_type != NULL_TREE)
!     while (1)
!       {
! 	HOST_WIDE_INT parm_size;
! 	HOST_WIDE_INT parm_boundary_bytes = PARM_BOUNDARY / BITS_PER_UNIT;
! 
! 	/* We got to the end of the list without seeing void_list_node,
! 	   which means the function is variadic.  The suffix is to be
! 	   ignored in that case.  */
! 	if (formal_type == NULL_TREE)
! 	  return NULL_TREE;
! 
! 	/* End of arguments, non-varargs marker.  */
!         if (formal_type == void_list_node)
! 	  break;
! 
!         /* Quit if we hit an incomplete type.  Error is reported
! 	   by convert_arguments in c-typeck.c or cp/typeck.c.  */
! 	parm_size = int_size_in_bytes (TREE_VALUE (formal_type));
! 	if (parm_size < 0)
! 	  break;
! 
! 	/* Must round up to include padding.  This is done the same
! 	   way as in store_one_arg.  */
! 	parm_size = ((parm_size + parm_boundary_bytes - 1)
! 		     / parm_boundary_bytes * parm_boundary_bytes);
! 	total += parm_size;
  
! 	formal_type = TREE_CHAIN (formal_type);
        }
    /* Assume max of 8 base 10 digits in the suffix.  */
    p = new_str = alloca (1 + strlen (old_str) + 1 + 8 + 1);
--- 165,202 ----
    HOST_WIDE_INT total = 0;
    const char *old_str = IDENTIFIER_POINTER (id != NULL_TREE ? id : DECL_NAME (decl));
    char *new_str, *p;
!   tree type = TREE_TYPE (decl);
!   tree arg;
!   function_args_iterator args_iter;
  
    gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);  
  
!   if (prototype_p (type))
!     {
!       /* This attribute is ignored for variadic functions.  */ 
!       if (stdarg_p (type))
! 	return NULL_TREE;
! 
!       /* Quit if we hit an incomplete type.  Error is reported
! 	 by convert_arguments in c-typeck.c or cp/typeck.c.  */
!       FOREACH_FUNCTION_ARGS(type, arg, args_iter)
! 	{
! 	  HOST_WIDE_INT parm_size;
! 	  HOST_WIDE_INT parm_boundary_bytes = PARM_BOUNDARY / BITS_PER_UNIT;
  
! 	  if (! COMPLETE_TYPE_P (arg))
! 	    break;
! 
! 	  parm_size = int_size_in_bytes (arg);
! 	  if (parm_size < 0)
! 	    break;
! 
! 	  /* Must round up to include padding.  This is done the same
! 	     way as in store_one_arg.  */
! 	  parm_size = ((parm_size + parm_boundary_bytes - 1)
! 		       / parm_boundary_bytes * parm_boundary_bytes);
! 	  total += parm_size;
! 	}
        }
    /* Assume max of 8 base 10 digits in the suffix.  */
    p = new_str = alloca (1 + strlen (old_str) + 1 + 8 + 1);
*** gcc/config/i386/i386.c.~1~	2007-09-12 22:02:56.630874000 -0400
--- gcc/config/i386/i386.c	2007-09-12 20:04:48.761610000 -0400
*************** ix86_eax_live_at_start_p (void)
*** 3252,3273 ****
    return REGNO_REG_SET_P (df_get_live_out (ENTRY_BLOCK_PTR), 0);
  }
  
- /* Return true if TYPE has a variable argument list.  */
- 
- static bool
- type_has_variadic_args_p (tree type)
- {
-   tree n, t = TYPE_ARG_TYPES (type);
- 
-   if (t == NULL)
-     return false;
- 
-   while ((n = TREE_CHAIN (t)) != NULL)
-     t = n;
- 
-   return TREE_VALUE (t) != void_type_node;
- }
- 
  /* Value is the number of bytes of arguments automatically
     popped when returning from a subroutine call.
     FUNDECL is the declaration node of the function (as a tree),
--- 3252,3257 ----
*************** ix86_return_pops_args (tree fundecl, tre
*** 3305,3311 ****
            || lookup_attribute ("fastcall", TYPE_ATTRIBUTES (funtype)))
  	rtd = 1;
  
!       if (rtd && ! type_has_variadic_args_p (funtype))
  	return size;
      }
  
--- 3289,3295 ----
            || lookup_attribute ("fastcall", TYPE_ATTRIBUTES (funtype)))
  	rtd = 1;
  
!       if (rtd && ! stdarg_p (funtype))
  	return size;
      }
  
*************** init_cumulative_args (CUMULATIVE_ARGS *c
*** 3405,3412 ****
    cum->warn_sse = true;
    cum->warn_mmx = true;
    cum->maybe_vaarg = (fntype
! 		      ? (!TYPE_ARG_TYPES (fntype)
! 			 || type_has_variadic_args_p (fntype))
  		      : !libname);
  
    if (!TARGET_64BIT)
--- 3389,3395 ----
    cum->warn_sse = true;
    cum->warn_mmx = true;
    cum->maybe_vaarg = (fntype
! 		      ? (!prototype_p (fntype) || stdarg_p (fntype))
  		      : !libname);
  
    if (!TARGET_64BIT)
*************** ix86_setup_incoming_varargs (CUMULATIVE_
*** 4984,4990 ****
  {
    CUMULATIVE_ARGS next_cum;
    tree fntype;
-   int stdarg_p;
  
    /* This argument doesn't appear to be used anymore.  Which is good,
       because the old code here didn't suppress rtl generation.  */
--- 4967,4972 ----
*************** ix86_setup_incoming_varargs (CUMULATIVE_
*** 4994,5007 ****
      return;
  
    fntype = TREE_TYPE (current_function_decl);
-   stdarg_p = (TYPE_ARG_TYPES (fntype) != 0
- 	      && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
- 		  != void_type_node));
  
    /* For varargs, we do not want to skip the dummy va_dcl argument.
       For stdargs, we do want to skip the last named argument.  */
    next_cum = *cum;
!   if (stdarg_p)
      function_arg_advance (&next_cum, mode, type, 1);
  
    if (TARGET_64BIT_MS_ABI)
--- 4976,4986 ----
      return;
  
    fntype = TREE_TYPE (current_function_decl);
  
    /* For varargs, we do not want to skip the dummy va_dcl argument.
       For stdargs, we do want to skip the last named argument.  */
    next_cum = *cum;
!   if (stdarg_p (fntype))
      function_arg_advance (&next_cum, mode, type, 1);
  
    if (TARGET_64BIT_MS_ABI)
*************** x86_this_parameter (tree function)
*** 21450,21457 ****
        return gen_rtx_REG (DImode, parm_regs[aggr]);
      }
  
!   if (ix86_function_regparm (type, function) > 0
!       && !type_has_variadic_args_p (type))
      {
        int regno = 0;
        if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (type)))
--- 21429,21435 ----
        return gen_rtx_REG (DImode, parm_regs[aggr]);
      }
  
!   if (ix86_function_regparm (type, function) > 0 && !stdarg_p (type))
      {
        int regno = 0;
        if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (type)))
*** gcc/config/sh/sh.c.~1~	2007-09-12 22:02:56.950196000 -0400
--- gcc/config/sh/sh.c	2007-09-12 20:04:49.291121000 -0400
*************** sh_init_cumulative_args (CUMULATIVE_ARGS
*** 10516,10522 ****
      {
        pcum->force_mem = ((TARGET_HITACHI || pcum->renesas_abi)
  			 && aggregate_value_p (TREE_TYPE (fntype), fndecl));
!       pcum->prototype_p = TYPE_ARG_TYPES (fntype) ? TRUE : FALSE;
        pcum->arg_count [(int) SH_ARG_INT]
  	= TARGET_SH5 && aggregate_value_p (TREE_TYPE (fntype), fndecl);
  
--- 10516,10522 ----
      {
        pcum->force_mem = ((TARGET_HITACHI || pcum->renesas_abi)
  			 && aggregate_value_p (TREE_TYPE (fntype), fndecl));
!       pcum->prototype_p = prototype_p (fntype);
        pcum->arg_count [(int) SH_ARG_INT]
  	= TARGET_SH5 && aggregate_value_p (TREE_TYPE (fntype), fndecl);
  
*** gcc/config/avr/avr.c.~1~	2007-09-12 22:02:57.032272000 -0400
--- gcc/config/avr/avr.c	2007-09-10 13:00:19.662465000 -0400
*************** init_cumulative_args (CUMULATIVE_ARGS *c
*** 1476,1485 ****
    cum->regno = FIRST_CUM_REG;
    if (!libname && fntype)
      {
!       int stdarg = (TYPE_ARG_TYPES (fntype) != 0
!                     && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
!                         != void_type_node));
!       if (stdarg)
          cum->nregs = 0;
      }
  }
--- 1476,1482 ----
    cum->regno = FIRST_CUM_REG;
    if (!libname && fntype)
      {
!       if (stdarg_p (fntype))
          cum->nregs = 0;
      }
  }
*** gcc/config/crx/crx.c.~1~	2007-09-12 22:02:57.103343000 -0400
--- gcc/config/crx/crx.c	2007-09-10 13:00:20.752556000 -0400
*************** crx_init_cumulative_args (CUMULATIVE_ARG
*** 479,499 ****
  {
    tree param, next_param;
  
!   cum->ints = 0;
! 
!   /* Determine if this function has variable arguments.  This is indicated by
!    * the last argument being 'void_type_mode' if there are no variable
!    * arguments.  Change here for a different vararg.  */
!   for (param = (fntype) ? TYPE_ARG_TYPES (fntype) : 0;
!        param != (tree) 0; param = next_param)
!     {
!       next_param = TREE_CHAIN (param);
!       if (next_param == (tree) 0 && TREE_VALUE (param) != void_type_node)
! 	{
! 	  cum->ints = -1;
! 	  return;
! 	}
!     }
  }
  
  /* Implements the macro FUNCTION_ARG_ADVANCE defined in crx.h.  */
--- 479,486 ----
  {
    tree param, next_param;
  
!   /* Determine if this function has variable arguments.  */
!   cum->ints = (stdarg_p (fntype)) ? -1 : 0;
  }
  
  /* Implements the macro FUNCTION_ARG_ADVANCE defined in crx.h.  */
*** gcc/config/c4x/c4x.c.~1~	2007-09-12 22:02:57.559805000 -0400
--- gcc/config/c4x/c4x.c	2007-09-10 13:00:21.509310000 -0400
*************** static const int c4x_fp_reglist[2] = {R2
*** 511,522 ****
  void
  c4x_init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype, rtx libname)
  {
!   tree param, next_param;
  
    cum->floats = cum->ints = 0;
    cum->init = 0;
    cum->var = 0;
    cum->args = 0;
  
    if (TARGET_DEBUG)
      {
--- 511,524 ----
  void
  c4x_init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype, rtx libname)
  {
!   function_args_iterator args_iter;
!   tree type, last_type = NULL_TREE;
  
    cum->floats = cum->ints = 0;
    cum->init = 0;
    cum->var = 0;
    cum->args = 0;
+   cum->prototype = 0;
  
    if (TARGET_DEBUG)
      {
*************** c4x_init_cumulative_args (CUMULATIVE_ARG
*** 536,574 ****
  	fprintf (stderr, ", libname = %s", XSTR (libname, 0));
      }
  
!   cum->prototype = (fntype && TYPE_ARG_TYPES (fntype));
! 
!   for (param = fntype ? TYPE_ARG_TYPES (fntype) : 0;
!        param; param = next_param)
      {
!       tree type;
! 
!       next_param = TREE_CHAIN (param);
  
!       type = TREE_VALUE (param);
!       if (type && type != void_type_node)
  	{
! 	  enum machine_mode mode;
! 
! 	  /* If the last arg doesn't have void type then we have
! 	     variable arguments.  */
! 	  if (! next_param)
! 	    cum->var = 1;
! 
! 	  if ((mode = TYPE_MODE (type)))
  	    {
! 	      if (! targetm.calls.must_pass_in_stack (mode, type))
  		{
! 		  /* Look for float, double, or long double argument.  */
! 		  if (mode == QFmode || mode == HFmode)
! 		    cum->floats++;
! 		  /* Look for integer, enumeral, boolean, char, or pointer
! 		     argument.  */
! 		  else if (mode == QImode || mode == Pmode)
! 		    cum->ints++;
  		}
  	    }
- 	  cum->args++;
  	}
      }
  
--- 538,570 ----
  	fprintf (stderr, ", libname = %s", XSTR (libname, 0));
      }
  
!   if (fntype)
      {
!       cum->prototype = prototype_p (fntype);
!       cum->var = stdarg_p (fntype);
  
!       FOREACH_FUNCTION_ARGS(fntype, type, args_iter)
  	{
! 	  last_type = type;
! 	  if (type && type != void_type_node)
  	    {
! 	      enum machine_mode mode;
! 
! 	      if ((mode = TYPE_MODE (type)))
  		{
! 		  if (! targetm.calls.must_pass_in_stack (mode, type))
! 		    {
! 		      /* Look for float, double, or long double argument.  */
! 		      if (mode == QFmode || mode == HFmode)
! 			cum->floats++;
! 		      /* Look for integer, enumeral, boolean, char, or pointer
! 			 argument.  */
! 		      else if (mode == QImode || mode == Pmode)
! 			cum->ints++;
! 		    }
  		}
+ 	      cum->args++;
  	    }
  	}
      }
  
*** gcc/config/iq2000/iq2000.c.~1~	2007-09-12 22:02:57.627871000 -0400
--- gcc/config/iq2000/iq2000.c	2007-09-10 13:00:26.034831000 -0400
*************** init_cumulative_args (CUMULATIVE_ARGS *c
*** 1078,1085 ****
  		      rtx libname ATTRIBUTE_UNUSED)
  {
    static CUMULATIVE_ARGS zero_cum;
-   tree param;
-   tree next_param;
  
    if (TARGET_DEBUG_D_MODE)
      {
--- 1078,1083 ----
*************** init_cumulative_args (CUMULATIVE_ARGS *c
*** 1101,1118 ****
  
    *cum = zero_cum;
  
!   /* Determine if this function has variable arguments.  This is
!      indicated by the last argument being 'void_type_mode' if there
!      are no variable arguments.  The standard IQ2000 calling sequence
!      passes all arguments in the general purpose registers in this case.  */
! 
!   for (param = fntype ? TYPE_ARG_TYPES (fntype) : 0;
!        param != 0; param = next_param)
!     {
!       next_param = TREE_CHAIN (param);
!       if (next_param == 0 && TREE_VALUE (param) != void_type_node)
! 	cum->gp_reg_found = 1;
!     }
  }
  
  /* Advance the argument of type TYPE and mode MODE to the next argument
--- 1099,1109 ----
  
    *cum = zero_cum;
  
!   /* Determine if this function has variable arguments.  The standard IQ2000
!      calling sequence passes all arguments in the general purpose registers in
!      this case.  */
! 
!   cum->gp_reg_found = stdarg_p (fntype);
  }
  
  /* Advance the argument of type TYPE and mode MODE to the next argument
*************** iq2000_expand_prologue (void)
*** 1969,1979 ****
  
    /* If this function is a varargs function, store any registers that
       would normally hold arguments ($4 - $7) on the stack.  */
!   if (store_args_on_stack
!       && ((TYPE_ARG_TYPES (fntype) != 0
! 	   && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
! 	       != void_type_node))
! 	  || last_arg_is_vararg_marker))
      {
        int offset = (regno - GP_ARG_FIRST) * UNITS_PER_WORD;
        rtx ptr = stack_pointer_rtx;
--- 1960,1966 ----
  
    /* If this function is a varargs function, store any registers that
       would normally hold arguments ($4 - $7) on the stack.  */
!   if (store_args_on_stack && (stdarg_p (fntype) || last_arg_is_vararg_marker))
      {
        int offset = (regno - GP_ARG_FIRST) * UNITS_PER_WORD;
        rtx ptr = stack_pointer_rtx;
*** gcc/config/mn10300/mn10300.c.~1~	2007-09-12 22:02:57.680919000 -0400
--- gcc/config/mn10300/mn10300.c	2007-09-10 13:00:27.211006000 -0400
*************** mn10300_builtin_saveregs (void)
*** 1446,1455 ****
  {
    rtx offset, mem;
    tree fntype = TREE_TYPE (current_function_decl);
!   int argadj = ((!(TYPE_ARG_TYPES (fntype) != 0
!                    && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
!                        != void_type_node)))
!                 ? UNITS_PER_WORD : 0);
    alias_set_type set = get_varargs_alias_set ();
  
    if (argadj)
--- 1446,1452 ----
  {
    rtx offset, mem;
    tree fntype = TREE_TYPE (current_function_decl);
!   int argadj = (!stdarg_p (fntype) ? UNITS_PER_WORD : 0);
    alias_set_type set = get_varargs_alias_set ();
  
    if (argadj)
*** gcc/config/ia64/ia64.h.~1~	2007-09-12 22:02:57.792032000 -0400
--- gcc/config/ia64/ia64.h	2007-09-12 20:04:50.267081000 -0400
*************** do {									\
*** 1081,1087 ****
    (CUM).words = 0;							\
    (CUM).int_regs = 0;							\
    (CUM).fp_regs = 0;							\
!   (CUM).prototype = ((FNTYPE) && TYPE_ARG_TYPES (FNTYPE)) || (LIBNAME);	\
  } while (0)
  
  /* Like `INIT_CUMULATIVE_ARGS' but overrides it for the purposes of finding the
--- 1081,1087 ----
    (CUM).words = 0;							\
    (CUM).int_regs = 0;							\
    (CUM).fp_regs = 0;							\
!   (CUM).prototype = ((FNTYPE) && prototype_p (FNTYPE)) || (LIBNAME);	\
  } while (0)
  
  /* Like `INIT_CUMULATIVE_ARGS' but overrides it for the purposes of finding the
*** gcc/config/m68k/m68k.h.~1~	2007-09-12 22:02:58.332573000 -0400
--- gcc/config/m68k/m68k.h	2007-09-12 20:04:50.693510000 -0400
*************** extern enum reg_class regno_reg_class[];
*** 527,535 ****
     the caller must always pop the args.  */
  #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE)   \
    ((TARGET_RTD && (!(FUNDECL) || TREE_CODE (FUNDECL) != IDENTIFIER_NODE)	\
!     && (TYPE_ARG_TYPES (FUNTYPE) == 0				\
! 	|| (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE)))	\
! 	    == void_type_node)))				\
     ? (SIZE) : 0)
  
  /* On the m68k the return value defaults to D0.  */
--- 527,533 ----
     the caller must always pop the args.  */
  #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE)   \
    ((TARGET_RTD && (!(FUNDECL) || TREE_CODE (FUNDECL) != IDENTIFIER_NODE)	\
!     && (! prototype_p (FUNDECL) || stdarg_p (FUNTYPE)))				\
     ? (SIZE) : 0)
  
  /* On the m68k the return value defaults to D0.  */
*** gcc/config/rs6000/rs6000-c.c.~1~	2007-09-12 22:02:58.384623000 -0400
--- gcc/config/rs6000/rs6000-c.c	2007-09-10 13:00:35.605393000 -0400
*************** altivec_build_resolved_builtin (tree *ar
*** 2436,2448 ****
  {
    tree impl_fndecl = rs6000_builtin_decls[desc->overloaded_code];
    tree ret_type = rs6000_builtin_type (desc->ret_type);
!   tree argtypes = TYPE_ARG_TYPES (TREE_TYPE (impl_fndecl));
    tree arg_type[3];
    tree call;
! 
    int i;
!   for (i = 0; i < n; i++)
!     arg_type[i] = TREE_VALUE (argtypes), argtypes = TREE_CHAIN (argtypes);
  
    /* The AltiVec overloading implementation is overall gross, but this
       is particularly disgusting.  The vec_{all,any}_{ge,le} builtins
--- 2436,2459 ----
  {
    tree impl_fndecl = rs6000_builtin_decls[desc->overloaded_code];
    tree ret_type = rs6000_builtin_type (desc->ret_type);
!   tree type = TREE_TYPE (impl_fndecl);
!   tree arg;
    tree arg_type[3];
    tree call;
!   function_args_iterator args_iter;
    int i;
! 
!   i = 0;
!   FOREACH_FUNCTION_ARGS(type, arg, args_iter)
!     {
!       if (VOID_TYPE_P (arg))
! 	break;
! 
!       gcc_assert (i < 3 && i < n);
!       arg_type[i++] = arg;
!     }
!   
!   gcc_assert (i == n);
  
    /* The AltiVec overloading implementation is overall gross, but this
       is particularly disgusting.  The vec_{all,any}_{ge,le} builtins
*************** tree
*** 2498,2520 ****
  altivec_resolve_overloaded_builtin (tree fndecl, tree arglist)
  {
    unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
!   tree fnargs = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
    tree types[3], args[3];
    const struct altivec_builtin_types *desc;
    int n;
  
    if (fcode < ALTIVEC_BUILTIN_OVERLOADED_FIRST
        || fcode > ALTIVEC_BUILTIN_OVERLOADED_LAST)
      return NULL_TREE;
  
!   for (n = 0;
!        !VOID_TYPE_P (TREE_VALUE (fnargs)) && arglist;
!        fnargs = TREE_CHAIN (fnargs), arglist = TREE_CHAIN (arglist), n++)
      {
!       tree decl_type = TREE_VALUE (fnargs);
!       tree arg = TREE_VALUE (arglist);
        tree type;
  
        if (arg == error_mark_node)
  	return error_mark_node;
  
--- 2509,2539 ----
  altivec_resolve_overloaded_builtin (tree fndecl, tree arglist)
  {
    unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
!   tree fntype = TREE_TYPE (fndecl);
!   tree decl_type = NULL_TREE;
    tree types[3], args[3];
    const struct altivec_builtin_types *desc;
+   function_args_iterator args_iter;
    int n;
  
    if (fcode < ALTIVEC_BUILTIN_OVERLOADED_FIRST
        || fcode > ALTIVEC_BUILTIN_OVERLOADED_LAST)
      return NULL_TREE;
  
!   n = 0;
!   FOREACH_FUNCTION_ARGS(fntype, decl_type, args_iter)
      {
!       tree arg;
        tree type;
  
+       if (!arglist)
+ 	break;
+ 
+       arg = TREE_VALUE (arglist);
+ 
+       if (VOID_TYPE_P (decl_type))
+ 	break;
+ 
        if (arg == error_mark_node)
  	return error_mark_node;
  
*************** altivec_resolve_overloaded_builtin (tree
*** 2554,2564 ****
  
        args[n] = arg;
        types[n] = type;
      }
  
    /* If the number of arguments did not match the prototype, return NULL
       and the generic code will issue the appropriate error message.  */
!   if (!VOID_TYPE_P (TREE_VALUE (fnargs)) || arglist)
      return NULL;
  
    if (n == 0)
--- 2573,2586 ----
  
        args[n] = arg;
        types[n] = type;
+ 
+       n++;
+       arglist = TREE_CHAIN (arglist);
      }
  
    /* If the number of arguments did not match the prototype, return NULL
       and the generic code will issue the appropriate error message.  */
!   if (!decl_type || !VOID_TYPE_P (decl_type) || arglist)
      return NULL;
  
    if (n == 0)
*** gcc/config/rs6000/rs6000.c.~1~	2007-09-12 22:02:58.502747000 -0400
--- gcc/config/rs6000/rs6000.c	2007-09-10 13:00:35.777567000 -0400
*************** init_cumulative_args (CUMULATIVE_ARGS *c
*** 4849,4863 ****
    cum->words = 0;
    cum->fregno = FP_ARG_MIN_REG;
    cum->vregno = ALTIVEC_ARG_MIN_REG;
!   cum->prototype = (fntype && TYPE_ARG_TYPES (fntype));
    cum->call_cookie = ((DEFAULT_ABI == ABI_V4 && libcall)
  		      ? CALL_LIBCALL : CALL_NORMAL);
    cum->sysv_gregno = GP_ARG_MIN_REG;
!   cum->stdarg = fntype
!     && (TYPE_ARG_TYPES (fntype) != 0
! 	&& (TREE_VALUE (tree_last  (TYPE_ARG_TYPES (fntype)))
! 	    != void_type_node));
! 
    cum->nargs_prototype = 0;
    if (incoming || cum->prototype)
      cum->nargs_prototype = n_named_args;
--- 4849,4859 ----
    cum->words = 0;
    cum->fregno = FP_ARG_MIN_REG;
    cum->vregno = ALTIVEC_ARG_MIN_REG;
!   cum->prototype = (fntype && prototype_p (fntype));
    cum->call_cookie = ((DEFAULT_ABI == ABI_V4 && libcall)
  		      ? CALL_LIBCALL : CALL_NORMAL);
    cum->sysv_gregno = GP_ARG_MIN_REG;
!   cum->stdarg = (fntype && stdarg_p (fntype));
    cum->nargs_prototype = 0;
    if (incoming || cum->prototype)
      cum->nargs_prototype = n_named_args;
*************** static bool
*** 14428,14441 ****
  rs6000_function_ok_for_sibcall (tree decl, tree exp ATTRIBUTE_UNUSED)
  {
    tree type;
    if (decl)
      {
        if (TARGET_ALTIVEC_VRSAVE)
  	{
! 	  for (type = TYPE_ARG_TYPES (TREE_TYPE (decl));
! 	       type; type = TREE_CHAIN (type))
  	    {
! 	      if (TREE_CODE (TREE_VALUE (type)) == VECTOR_TYPE)
  		return false;
  	    }
  	}
--- 14424,14438 ----
  rs6000_function_ok_for_sibcall (tree decl, tree exp ATTRIBUTE_UNUSED)
  {
    tree type;
+   function_args_iterator args_iter;
+ 
    if (decl)
      {
        if (TARGET_ALTIVEC_VRSAVE)
  	{
! 	  FOREACH_FUNCTION_ARGS(TREE_TYPE (decl), type, args_iter)
  	    {
! 	      if (TREE_CODE (type) == VECTOR_TYPE)
  		return false;
  	    }
  	}
*** gcc/config/arm/arm.c.~1~	2007-09-12 22:02:58.714969000 -0400
--- gcc/config/arm/arm.c	2007-09-10 13:00:42.244024000 -0400
*************** arm_init_cumulative_args (CUMULATIVE_ARG
*** 2882,2893 ****
  
    if (TARGET_REALLY_IWMMXT && fntype)
      {
        tree fn_arg;
  
!       for (fn_arg = TYPE_ARG_TYPES (fntype);
! 	   fn_arg;
! 	   fn_arg = TREE_CHAIN (fn_arg))
! 	pcum->named_count += 1;
  
        if (! pcum->named_count)
  	pcum->named_count = INT_MAX;
--- 2882,2894 ----
  
    if (TARGET_REALLY_IWMMXT && fntype)
      {
+       function_args_iterator args_iter;
        tree fn_arg;
  
!       FOREACH_FUNCTION_ARGS(fndecl, fn_arg, args_iter)
! 	{
! 	  pcum->named_count += 1;
! 	}
  
        if (! pcum->named_count)
  	pcum->named_count = INT_MAX;
*** gcc/config/pa/som.h.~1~	2007-09-12 22:02:58.927165000 -0400
--- gcc/config/pa/som.h	2007-09-10 13:00:47.695473000 -0400
*************** do {								\
*** 157,165 ****
  		   }							\
  	       }							\
  	     /* anonymous args */					\
! 	     if (TYPE_ARG_TYPES (tree_type) != 0			\
! 		 && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (tree_type)))\
! 		     != void_type_node))				\
  	       {							\
  		 for (; i < 4; i++)					\
  		   fprintf (FILE, ",ARGW%d=GR", i);			\
--- 157,163 ----
  		   }							\
  	       }							\
  	     /* anonymous args */					\
! 	     if (stdarg_p (tree_type))					\
  	       {							\
  		 for (; i < 4; i++)					\
  		   fprintf (FILE, ",ARGW%d=GR", i);			\
*** gcc/config/pa/pa.c.~1~	2007-09-12 22:02:59.124362000 -0400
--- gcc/config/pa/pa.c	2007-09-10 13:00:48.637411000 -0400
*************** hppa_builtin_saveregs (void)
*** 5849,5858 ****
  {
    rtx offset, dest;
    tree fntype = TREE_TYPE (current_function_decl);
!   int argadj = ((!(TYPE_ARG_TYPES (fntype) != 0
! 		   && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
! 		       != void_type_node)))
! 		? UNITS_PER_WORD : 0);
  
    if (argadj)
      offset = plus_constant (current_function_arg_offset_rtx, argadj);
--- 5849,5855 ----
  {
    rtx offset, dest;
    tree fntype = TREE_TYPE (current_function_decl);
!   int argadj = (!stdarg_p (fntype) ? UNITS_PER_WORD : 0);
  
    if (argadj)
      offset = plus_constant (current_function_arg_offset_rtx, argadj);
*** gcc/config/pa/pa.h.~1~	2007-09-12 22:02:59.243487000 -0400
--- gcc/config/pa/pa.h	2007-09-10 13:00:48.724497000 -0400
*************** struct hppa_args {int words, nargs_proto
*** 645,652 ****
    (CUM).words = 0, 							\
    (CUM).incoming = 0,							\
    (CUM).indirect = (FNTYPE) && !(FNDECL),				\
!   (CUM).nargs_prototype = (FNTYPE && TYPE_ARG_TYPES (FNTYPE)		\
! 			   ? (list_length (TYPE_ARG_TYPES (FNTYPE)) - 1	\
  			      + (TYPE_MODE (TREE_TYPE (FNTYPE)) == BLKmode \
  				 || pa_return_in_memory (TREE_TYPE (FNTYPE), 0))) \
  			   : 0)
--- 645,652 ----
    (CUM).words = 0, 							\
    (CUM).incoming = 0,							\
    (CUM).indirect = (FNTYPE) && !(FNDECL),				\
!   (CUM).nargs_prototype = (FNTYPE && prototype_p (FNTYPE)		\
! 			   ? (function_args_count (FNTYPE) - 1		\
  			      + (TYPE_MODE (TREE_TYPE (FNTYPE)) == BLKmode \
  				 || pa_return_in_memory (TREE_TYPE (FNTYPE), 0))) \
  			   : 0)
*** gcc/config/mips/mips.c.~1~	2007-09-12 22:02:59.422660000 -0400
--- gcc/config/mips/mips.c	2007-09-12 20:04:52.096888000 -0400
*************** init_cumulative_args (CUMULATIVE_ARGS *c
*** 4472,4491 ****
    tree param, next_param;
  
    *cum = zero_cum;
!   cum->prototype = (fntype && TYPE_ARG_TYPES (fntype));
  
!   /* Determine if this function has variable arguments.  This is
!      indicated by the last argument being 'void_type_mode' if there
!      are no variable arguments.  The standard MIPS calling sequence
!      passes all arguments in the general purpose registers in this case.  */
! 
!   for (param = fntype ? TYPE_ARG_TYPES (fntype) : 0;
!        param != 0; param = next_param)
!     {
!       next_param = TREE_CHAIN (param);
!       if (next_param == 0 && TREE_VALUE (param) != void_type_node)
! 	cum->gp_reg_found = 1;
!     }
  }
  
  
--- 4472,4484 ----
    tree param, next_param;
  
    *cum = zero_cum;
!   cum->prototype = (fntype && prototype_p (fntype));
  
!   /* Determine if this function has variable arguments.  The standard MIPS
!      calling sequence passes all arguments in the general purpose registers in
!      this case.  */
! 
!   cum->gp_reg_found = stdarg_p (fntype);
  }
  
  


More information about the Gcc-patches mailing list