This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch applied to sh port: fix gcc.dg/builtin-apply2.c failures


2004-06-29  J"orn Rennecke <joern.rennecke@superh.com>

	Fix gcc.dg/builtin-apply2.c failures:
	* sh.h (TARGET_VARARGS_PRETEND_ARGS): Define.
	* sh.c (extra_push): Delete.
	(sh_expand_prologue): Don't do extra stack adjustment for
	current_function_pretend_args_size if it comes from varargs setup.
	Use TARGET_VARARGS_PRETEND_ARGS.  Don't set extra_push.
	(sh_expand_epilogue): Don't use extra_push.
	(sh_setup_incoming_varargs): Set pretend_arg_size when necessary.

Index: sh.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.c,v
retrieving revision 1.270.2.2
diff -p -r1.270.2.2 sh.c
*** sh.c	28 Jun 2004 22:55:54 -0000	1.270.2.2
--- sh.c	29 Jun 2004 17:18:41 -0000
*************** output_jump_label_table (void)
*** 4700,4707 ****
  /* Number of bytes pushed for anonymous args, used to pass information
     between expand_prologue and expand_epilogue.  */
  
- static int extra_push;
- 
  /* Adjust the stack by SIZE bytes.  REG holds the rtl of the register to be
     adjusted.  If epilogue_p is zero, this is for a prologue; otherwise, it's
     for an epilogue and a negative value means that it's for a sibcall
--- 4700,4705 ----
*************** sh_expand_prologue (void)
*** 5321,5337 ****
    int d, i;
    int d_rounding = 0;
    int save_flags = target_flags;
  
    current_function_interrupt = sh_cfun_interrupt_handler_p ();
  
    /* We have pretend args if we had an object sent partially in registers
       and partially on the stack, e.g. a large structure.  */
!   output_stack_adjust (-current_function_pretend_args_size
  		       - current_function_args_info.stack_regs * 8,
  		       stack_pointer_rtx, 0, NULL);
  
-   extra_push = 0;
- 
    if (TARGET_SHCOMPACT && flag_pic && current_function_args_info.call_cookie)
      /* We're going to use the PIC register to load the address of the
         incoming-argument decoder and/or of the return trampoline from
--- 5319,5339 ----
    int d, i;
    int d_rounding = 0;
    int save_flags = target_flags;
+   int pretend_args;
  
    current_function_interrupt = sh_cfun_interrupt_handler_p ();
  
    /* We have pretend args if we had an object sent partially in registers
       and partially on the stack, e.g. a large structure.  */
!   pretend_args = current_function_pretend_args_size;
!   if (TARGET_VARARGS_PRETEND_ARGS (current_function_decl)
!       && (NPARM_REGS(SImode)
! 	  > current_function_args_info.arg_count[(int) SH_ARG_INT]))
!     pretend_args = 0;
!   output_stack_adjust (-pretend_args
  		       - current_function_args_info.stack_regs * 8,
  		       stack_pointer_rtx, 0, NULL);
  
    if (TARGET_SHCOMPACT && flag_pic && current_function_args_info.call_cookie)
      /* We're going to use the PIC register to load the address of the
         incoming-argument decoder and/or of the return trampoline from
*************** sh_expand_prologue (void)
*** 5388,5396 ****
    /* Emit the code for SETUP_VARARGS.  */
    if (current_function_stdarg)
      {
!       /* This is not used by the SH2E calling convention  */
!       if (TARGET_SH1 && ! TARGET_SH2E && ! TARGET_SH5
! 	  && ! (TARGET_HITACHI || sh_cfun_attr_renesas_p ()))
  	{
  	  /* Push arg regs as if they'd been provided by caller in stack.  */
  	  for (i = 0; i < NPARM_REGS(SImode); i++)
--- 5390,5396 ----
    /* Emit the code for SETUP_VARARGS.  */
    if (current_function_stdarg)
      {
!       if (TARGET_VARARGS_PRETEND_ARGS (current_function_decl))
  	{
  	  /* Push arg regs as if they'd been provided by caller in stack.  */
  	  for (i = 0; i < NPARM_REGS(SImode); i++)
*************** sh_expand_prologue (void)
*** 5404,5410 ****
  		break;
  	      insn = push (rn);
  	      RTX_FRAME_RELATED_P (insn) = 0;
- 	      extra_push += 4;
  	    }
  	}
      }
--- 5404,5409 ----
*************** sh_expand_epilogue (bool sibcall_p)
*** 5904,5910 ****
      emit_insn (gen_toggle_sz ());
    target_flags = save_flags;
  
!   output_stack_adjust (extra_push + current_function_pretend_args_size
  		       + save_size + d_rounding
  		       + current_function_args_info.stack_regs * 8,
  		       stack_pointer_rtx, e, NULL);
--- 5903,5909 ----
      emit_insn (gen_toggle_sz ());
    target_flags = save_flags;
  
!   output_stack_adjust (current_function_pretend_args_size
  		       + save_size + d_rounding
  		       + current_function_args_info.stack_regs * 8,
  		       stack_pointer_rtx, e, NULL);
*************** sh_return_in_memory (tree type, tree fnd
*** 6789,6802 ****
     later.  Fortunately, we already have two flags that are part of struct
     function that tell if a function uses varargs or stdarg.  */
  static void
! sh_setup_incoming_varargs (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
! 			   enum machine_mode mode ATTRIBUTE_UNUSED,
! 			   tree type ATTRIBUTE_UNUSED,
! 			   int *pretend_arg_size ATTRIBUTE_UNUSED,
  			   int second_time ATTRIBUTE_UNUSED)
  {
    if (! current_function_stdarg)
      abort ();
  }
  
  static bool
--- 6788,6813 ----
     later.  Fortunately, we already have two flags that are part of struct
     function that tell if a function uses varargs or stdarg.  */
  static void
! sh_setup_incoming_varargs (CUMULATIVE_ARGS *ca,
! 			   enum machine_mode mode,
! 			   tree type,
! 			   int *pretend_arg_size,
  			   int second_time ATTRIBUTE_UNUSED)
  {
    if (! current_function_stdarg)
      abort ();
+   if (TARGET_VARARGS_PRETEND_ARGS (current_function_decl))
+     {
+       int named_parm_regs, anon_parm_regs;
+ 
+       named_parm_regs = (ROUND_REG (*ca, mode)
+ 			 + (mode == BLKmode
+ 			    ? ROUND_ADVANCE (int_size_in_bytes (type))
+ 			    : ROUND_ADVANCE (GET_MODE_SIZE (mode))));
+       anon_parm_regs = NPARM_REGS (SImode) - named_parm_regs;
+       if (anon_parm_regs > 0)
+ 	*pretend_arg_size = anon_parm_regs * 4;
+     }
  }
  
  static bool
Index: sh.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.h,v
retrieving revision 1.240.2.3
diff -p -r1.240.2.3 sh.h
*** sh.h	17 Jun 2004 19:11:20 -0000	1.240.2.3
--- sh.h	29 Jun 2004 17:18:41 -0000
*************** extern int target_flags;
*** 263,268 ****
--- 263,273 ----
  
  #define TARGET_SAVE_ALL_TARGET_REGS (target_flags & SAVE_ALL_TR_BIT)
  
+ /* This is not used by the SH2E calling convention  */
+ #define TARGET_VARARGS_PRETEND_ARGS(FUN_DECL) \
+   (TARGET_SH1 && ! TARGET_SH2E && ! TARGET_SH5 \
+    && ! (TARGET_HITACHI || sh_attr_renesas_p (FUN_DECL)))
+ 
  #ifndef TARGET_CPU_DEFAULT
  #define TARGET_CPU_DEFAULT SELECT_SH1
  #define SUPPORT_SH1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]