patch introducing PRETEND_OUTGOING_VARARGS_NAMED installed

Joern Rennecke amylaar@cygnus.co.uk
Thu Feb 25 14:05:00 GMT 1999


I have installed the following patch.
Reviewed by Jim Wilson.

Thu Feb 25 21:52:54 1999  J"orn Rennecke <amylaar@cygnus.co.uk>

	* sh.h (PASS_IN_REG_P):  For TARGET_HITACHI, don't pass structures
	in registers.

	* expr.h (PRETEND_OUTGOING_VARARGS_NAMED): Provide default definition.
	* function.c (assign_parms): Honour PRETEND_OUTGOING_VARARGS_NAMED.
	* calls.c (expand_call): Likewise.

	* sh.c (sh_expand_prologue): For TARGET_HITACHI, don't push varargs /
	stdarg arguments.
	* sh.h (CPP_SPEC): Add -D__HITACHI__ for -mhitachi.
	(FUNCTION_ARG):  For TARGET_HITACHI, don't pass unnamed
	arguments in registers.
	(PRETEND_OUTGOING_VARARGS_NAMED): Define.
	* va-sh.h (entire file): If __HITACHI__ is defined, use sh[123]
	flavour varargs.

Index: tm.texi
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/tm.texi,v
retrieving revision 1.69
diff -p -r1.69 tm.texi
*** tm.texi	1999/02/21 19:58:20	1.69
--- tm.texi	1999/02/25 22:00:00
*************** are treated as named.  Otherwise, all na
*** 3789,3794 ****
--- 3789,3803 ----
  are treated as named.
  
  You need not define this macro if it always returns zero.
+ 
+ @findex PRETEND_OUTGOING_VARARGS_NAMED
+ @item PRETEND_OUTGOING_VARARGS_NAMED
+ If you need to conditionally change ABIs so that one works with
+ @code{SETUP_INCOMING_VARARGS}, but the other works like neither
+ @code{SETUP_INCOMING_VARARGS} nor @code{STRICT_ARGUMENT_NAMING} was
+ defined, then define this macro to return nonzero if
+ @code{SETUP_INCOMING_VARARGS} is used, zero otherwise.
+ Otherwise, you should not define this macro.
  @end table
  
  @node Trampolines
Index: expr.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/expr.h,v
retrieving revision 1.31
diff -p -r1.31 expr.h
*** expr.h	1999/01/15 18:43:43	1.31
--- expr.h	1999/02/25 22:00:00
*************** enum direction {none, upward, downward};
*** 216,221 ****
--- 216,232 ----
  #define STRICT_ARGUMENT_NAMING 0
  #endif
  
+ /* Provide a default value for PRETEND_OUTGOING_VARARGS_NAMED.  */
+ #ifdef SETUP_INCOMING_VARARGS
+ #ifndef PRETEND_OUTGOING_VARARGS_NAMED
+ #define PRETEND_OUTGOING_VARARGS_NAMED 1
+ #endif
+ #else
+ /* It is an error to define PRETEND_OUTGOING_VARARGS_NAMED without
+    defining SETUP_INCOMING_VARARGS.  */
+ #define PRETEND_OUTGOING_VARARGS_NAMED 0
+ #endif
+ 
  /* Nonzero if we do not know how to pass TYPE solely in registers.
     We cannot do so in the following cases:
  
Index: function.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/function.c,v
retrieving revision 1.75
diff -p -r1.75 function.c
*** function.c	1999/02/22 13:34:32	1.75
--- function.c	1999/02/25 22:00:02
*************** assign_parms (fndecl, second_time)
*** 4096,4101 ****
--- 4096,4102 ----
        int did_conversion = 0;
        tree passed_type = DECL_ARG_TYPE (parm);
        tree nominal_type = TREE_TYPE (parm);
+       int pretend_named;
  
        /* Set LAST_NAMED if this is last named arg before some
  	 anonymous args.  */
*************** assign_parms (fndecl, second_time)
*** 4217,4222 ****
--- 4218,4224 ----
  	 In this case, we call FUNCTION_ARG with NAMED set to 1 instead of
  	 0 as it was the previous time.  */
  
+       pretend_named = named_arg || PRETEND_OUTGOING_VARARGS_NAMED;
        locate_and_pad_parm (nominal_mode, passed_type,
  #ifdef STACK_PARMS_IN_REG_PARM_AREA
  			   1,
*************** assign_parms (fndecl, second_time)
*** 4224,4235 ****
  #ifdef FUNCTION_INCOMING_ARG
  			   FUNCTION_INCOMING_ARG (args_so_far, promoted_mode,
  						  passed_type,
! 						  (named_arg
! 						   || varargs_setup)) != 0,
  #else
  			   FUNCTION_ARG (args_so_far, promoted_mode,
  					 passed_type,
! 					 named_arg || varargs_setup) != 0,
  #endif
  #endif
  			   fndecl, &stack_args_size, &stack_offset, &arg_size);
--- 4226,4236 ----
  #ifdef FUNCTION_INCOMING_ARG
  			   FUNCTION_INCOMING_ARG (args_so_far, promoted_mode,
  						  passed_type,
! 						  pretend_named) != 0,
  #else
  			   FUNCTION_ARG (args_so_far, promoted_mode,
  					 passed_type,
! 					 pretend_named) != 0,
  #endif
  #endif
  			   fndecl, &stack_args_size, &stack_offset, &arg_size);
Index: calls.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/calls.c,v
retrieving revision 1.47
diff -p -r1.47 calls.c
*** calls.c	1999/02/24 19:06:17	1.47
--- calls.c	1999/02/25 22:00:03
*************** expand_call (exp, target, ignore)
*** 1731,1751 ****
       (If no anonymous args follow, the result of list_length is actually
       one too large.  This is harmless.)
  
!      If SETUP_INCOMING_VARARGS is defined and STRICT_ARGUMENT_NAMING is zero,
!      this machine will be able to place unnamed args that were passed in
       registers into the stack.  So treat all args as named.  This allows the
       insns emitting for a specific argument list to be independent of the
       function declaration.
  
!      If SETUP_INCOMING_VARARGS is not defined, we do not have any reliable
       way to pass unnamed args in registers, so we must force them into
       memory.  */
  
    if ((STRICT_ARGUMENT_NAMING
! #ifndef SETUP_INCOMING_VARARGS
!        || 1
! #endif
!        )
        && TYPE_ARG_TYPES (funtype) != 0)
      n_named_args
        = (list_length (TYPE_ARG_TYPES (funtype))
--- 1731,1748 ----
       (If no anonymous args follow, the result of list_length is actually
       one too large.  This is harmless.)
  
!      If PRETEND_OUTGOING_VARARGS_NAMED is set and STRICT_ARGUMENT_NAMING is
!      zero, this machine will be able to place unnamed args that were passed in
       registers into the stack.  So treat all args as named.  This allows the
       insns emitting for a specific argument list to be independent of the
       function declaration.
  
!      If PRETEND_OUTGOING_VARARGS_NAMED is not set, we do not have any reliable
       way to pass unnamed args in registers, so we must force them into
       memory.  */
  
    if ((STRICT_ARGUMENT_NAMING
!        || ! PRETEND_OUTGOING_VARARGS_NAMED)
        && TYPE_ARG_TYPES (funtype) != 0)
      n_named_args
        = (list_length (TYPE_ARG_TYPES (funtype))
Index: config/sh/sh.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/sh/sh.c,v
retrieving revision 1.23
diff -p -r1.23 sh.c
*** sh.c	1999/01/19 10:32:30	1.23
--- sh.c	1999/02/25 22:00:04
*************** sh_expand_prologue ()
*** 3717,3723 ****
        current_function_anonymous_args = 0;
  
        /* This is not used by the SH3E calling convention  */
!       if (!TARGET_SH3E)
  	{
  	  /* Push arg regs as if they'd been provided by caller in stack.  */
  	  for (i = 0; i < NPARM_REGS(SImode); i++)
--- 3717,3723 ----
        current_function_anonymous_args = 0;
  
        /* This is not used by the SH3E calling convention  */
!       if (! TARGET_SH3E && ! TARGET_HITACHI)
  	{
  	  /* Push arg regs as if they'd been provided by caller in stack.  */
  	  for (i = 0; i < NPARM_REGS(SImode); i++)
Index: config/sh/sh.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/sh/sh.h,v
retrieving revision 1.27
diff -p -r1.27 sh.h
*** sh.h	1999/02/11 07:48:49	1.27
--- sh.h	1999/02/25 22:00:05
*************** extern int code_for_indirect_jump_scratc
*** 46,52 ****
  %{m4-single-only:-D__SH4_SINGLE_ONLY__} \
  %{m4-single:-D__SH4_SINGLE__} \
  %{m4:-D__SH4__} \
! %{!m1:%{!m2:%{!m3:%{!m3e:%{!m4:%{!m4-single:%{!m4-single-only:-D__sh1__}}}}}}}"
  
  #define CPP_PREDEFINES "-D__sh__ -Acpu(sh) -Amachine(sh)"
  
--- 46,53 ----
  %{m4-single-only:-D__SH4_SINGLE_ONLY__} \
  %{m4-single:-D__SH4_SINGLE__} \
  %{m4:-D__SH4__} \
! %{!m1:%{!m2:%{!m3:%{!m3e:%{!m4:%{!m4-single:%{!m4-single-only:-D__sh1__}}}}}}} \
! %{mhitachi:-D__HITACHI__}"
  
  #define CPP_PREDEFINES "-D__sh__ -Acpu(sh) -Amachine(sh)"
  
*************** struct sh_args {
*** 1004,1010 ****
     This macro is only used in this file. */
  
  #define PASS_IN_REG_P(CUM, MODE, TYPE) \
!   (((TYPE) == 0 || ! TREE_ADDRESSABLE ((tree)(TYPE))) \
     && (TARGET_SH3E \
         ? ((MODE) == BLKmode \
  	  ? (((CUM).arg_count[(int) SH_ARG_INT] * UNITS_PER_WORD \
--- 1005,1013 ----
     This macro is only used in this file. */
  
  #define PASS_IN_REG_P(CUM, MODE, TYPE) \
!   (((TYPE) == 0 \
!     || (! TREE_ADDRESSABLE ((tree)(TYPE))) \
! 	&& (! TARGET_HITACHI || ! AGGREGATE_TYPE_P (TYPE))) \
     && (TARGET_SH3E \
         ? ((MODE) == BLKmode \
  	  ? (((CUM).arg_count[(int) SH_ARG_INT] * UNITS_PER_WORD \
*************** extern int current_function_varargs;
*** 1037,1048 ****
  
  #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
    ((PASS_IN_REG_P ((CUM), (MODE), (TYPE))				\
!     && ((NAMED) || TARGET_SH3E || ! current_function_varargs))		\
     ? gen_rtx (REG, (MODE),						\
  	      ((BASE_ARG_REG (MODE) + ROUND_REG ((CUM), (MODE))) 	\
  	       ^ ((MODE) == SFmode && TARGET_SH4			\
  		  && TARGET_LITTLE_ENDIAN != 0)))			\
     : 0)
  
  /* For an arg passed partly in registers and partly in memory,
     this is the number of registers used.
--- 1040,1054 ----
  
  #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
    ((PASS_IN_REG_P ((CUM), (MODE), (TYPE))				\
!     && ((NAMED)								\
! 	|| (! TARGET_HITACHI && (TARGET_SH3E || ! current_function_varargs)))) \
     ? gen_rtx (REG, (MODE),						\
  	      ((BASE_ARG_REG (MODE) + ROUND_REG ((CUM), (MODE))) 	\
  	       ^ ((MODE) == SFmode && TARGET_SH4			\
  		  && TARGET_LITTLE_ENDIAN != 0)))			\
     : 0)
+ 
+ #define PRETEND_OUTGOING_VARARGS_NAMED (! TARGET_HITACHI)
  
  /* For an arg passed partly in registers and partly in memory,
     this is the number of registers used.
Index: ginclude/va-sh.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/ginclude/va-sh.h,v
retrieving revision 1.4
diff -p -r1.4 va-sh.h
*** va-sh.h	1998/12/16 21:19:43	1.4
--- va-sh.h	1999/02/25 22:00:05
***************
*** 1,12 ****
! /* This is just like the default gvarargs.h
!    except for differences described below.  */
  
  /* Define __gnuc_va_list.  */
  
  #ifndef __GNUC_VA_LIST
  #define __GNUC_VA_LIST
  
! #if defined (__SH3E__) || defined (__SH4_SINGLE__) || defined (__SH4__) || defined (__SH4_SINGLE_ONLY__)
  
  typedef long __va_greg;
  typedef float __va_freg;
--- 1,15 ----
! /* The ! __SH3E_VARG case is similar to the default gvarargs.h .  */
  
+ #if (defined (__SH3E__) || defined (__SH4_SINGLE__) || defined (__SH4__) || defined (__SH4_SINGLE_ONLY__)) && ! defined (__HITACHI__)
+ #define __SH3E_VARG
+ #endif
+ 
  /* Define __gnuc_va_list.  */
  
  #ifndef __GNUC_VA_LIST
  #define __GNUC_VA_LIST
  
! #ifdef __SH3E_VARG
  
  typedef long __va_greg;
  typedef float __va_freg;
*************** typedef void *__gnuc_va_list;
*** 33,39 ****
  
  #ifdef _STDARG_H
  
! #if defined (__SH3E__) || defined (__SH4_SINGLE__) || defined (__SH4__) || defined (__SH4_SINGLE_ONLY__)
  
  #define va_start(AP, LASTARG) \
  __extension__ \
--- 36,42 ----
  
  #ifdef _STDARG_H
  
! #ifdef __SH3E_VARG
  
  #define va_start(AP, LASTARG) \
  __extension__ \
*************** __extension__ \
*** 59,65 ****
  #define va_alist  __builtin_va_alist
  #define va_dcl    int __builtin_va_alist;...
  
! #if defined (__SH3E__) || defined (__SH4_SINGLE__) || defined (__SH4__) || defined (__SH4_SINGLE_ONLY__)
  
  #define va_start(AP) \
  __extension__ \
--- 62,68 ----
  #define va_alist  __builtin_va_alist
  #define va_dcl    int __builtin_va_alist;...
  
! #ifdef __SH3E_VARG
  
  #define va_start(AP) \
  __extension__ \
*************** enum __va_type_classes {
*** 164,170 ****
     ? (((union { TYPE t; int i;} *__VA_REF) (AP))++)->t			\
     : ((union {TYPE t;TYPE u;}*) ((char *)++(int *__VA_REF)(AP) - sizeof (TYPE)))->t);})
  
! #if defined (__SH3E__) || defined (__SH4_SINGLE__) || defined (__SH4__) || defined (__SH4_SINGLE_ONLY__)
  
  #define __PASS_AS_FLOAT(TYPE_CLASS,SIZE) \
    (TYPE_CLASS == __real_type_class && SIZE == 4)
--- 167,173 ----
     ? (((union { TYPE t; int i;} *__VA_REF) (AP))++)->t			\
     : ((union {TYPE t;TYPE u;}*) ((char *)++(int *__VA_REF)(AP) - sizeof (TYPE)))->t);})
  
! #ifdef __SH3E_VARG
  
  #define __PASS_AS_FLOAT(TYPE_CLASS,SIZE) \
    (TYPE_CLASS == __real_type_class && SIZE == 4)


More information about the Gcc-patches mailing list