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] S/390: Use FRAME_GROWS_DOWNWARD


Hi,

rth mentioned that the back ends need to define FRAME_GROWS_DOWNWARD
if they want to make use of his implementation of the stack-smashing 
protector:
http://gcc.gnu.org/ml/gcc-patches/2005-05/msg01193.html

The following patch does this for the s390 back end.

Bootstrapped on s390 and s390x without testsuite regressions.

OK for mainline?

Bye,

-Andreas-


2005-06-20  Andreas Krebbel  <krebbel1@de.ibm.com>

	* config/s390/s390.c (s390_decompose_address): Accept invalid
	displacements for addresses containing frame_pointer_rtx or
	virtual_stack_vars_rtx.
	(s390_frame_info): Replaced use of STARTING_FRAME_OFFSET.
	(s390_initial_elimination_offset): New offset when eliminating the 
	soft frame pointer.
	* config/s390/s390.h (FRAME_GROWS_DOWNWARD): Defined.
	(STARTING_FRAME_OFFSET, STACK_DYNAMIC_OFFSET): Definitions changed.


Index: gcc/config/s390/s390.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.c,v
retrieving revision 1.237
diff -p -c -r1.237 s390.c
*** gcc/config/s390/s390.c	9 Jun 2005 11:17:23 -0000	1.237
--- gcc/config/s390/s390.c	20 Jun 2005 12:16:33 -0000
*************** s390_decompose_address (rtx addr, struct
*** 1481,1499 ****
    /* Validate displacement.  */
    if (!disp)
      {
!       /* If the argument pointer or the return address pointer are involved,
! 	 the displacement will change later anyway as the virtual registers get
! 	 eliminated.  This could make a valid displacement invalid, but it is 
! 	 more likely to make an invalid displacement valid, because we sometimes
! 	 access the register save area via negative offsets to one of those 
! 	 registers.
  	 Thus we don't check the displacement for validity here.  If after
  	 elimination the displacement turns out to be invalid after all,
  	 this is fixed up by reload in any case.  */
        if (base != arg_pointer_rtx 
  	  && indx != arg_pointer_rtx 
  	  && base != return_address_pointer_rtx 
! 	  && indx != return_address_pointer_rtx)
  	if (!DISP_IN_RANGE (offset))
  	  return false;
      }
--- 1481,1502 ----
    /* Validate displacement.  */
    if (!disp)
      {
!       /* If virtual registers are involved, the displacement will change later 
! 	 anyway as the virtual registers get eliminated.  This could make a 
! 	 valid displacement invalid, but it is more likely to make an invalid 
! 	 displacement valid, because we sometimes access the register save area 
! 	 via negative offsets to one of those registers.
  	 Thus we don't check the displacement for validity here.  If after
  	 elimination the displacement turns out to be invalid after all,
  	 this is fixed up by reload in any case.  */
        if (base != arg_pointer_rtx 
  	  && indx != arg_pointer_rtx 
  	  && base != return_address_pointer_rtx 
! 	  && indx != return_address_pointer_rtx
! 	  && base != frame_pointer_rtx 
! 	  && indx != frame_pointer_rtx
! 	  && base != virtual_stack_vars_rtx 
! 	  && indx != virtual_stack_vars_rtx)
  	if (!DISP_IN_RANGE (offset))
  	  return false;
      }
*************** s390_frame_info (void)
*** 5763,5769 ****
      return;
  
    if (!TARGET_PACKED_STACK)
!     cfun_frame_layout.frame_size += (STARTING_FRAME_OFFSET
  				     + cfun_frame_layout.high_fprs * 8);
    else
      {
--- 5766,5773 ----
      return;
  
    if (!TARGET_PACKED_STACK)
!     cfun_frame_layout.frame_size += (STACK_POINTER_OFFSET
! 				     + current_function_outgoing_args_size
  				     + cfun_frame_layout.high_fprs * 8);
    else
      {
*************** s390_initial_elimination_offset (int fro
*** 5904,5910 ****
    switch (from)
      {
      case FRAME_POINTER_REGNUM:
!       offset = 0;
        break;
  
      case ARG_POINTER_REGNUM:
--- 5908,5916 ----
    switch (from)
      {
      case FRAME_POINTER_REGNUM:
!       offset = (get_frame_size() 
! 		+ STACK_POINTER_OFFSET
! 		+ current_function_outgoing_args_size);
        break;
  
      case ARG_POINTER_REGNUM:
Index: gcc/config/s390/s390.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.h,v
retrieving revision 1.140
diff -p -c -r1.140 s390.h
*** gcc/config/s390/s390.h	8 Jun 2005 05:05:40 -0000	1.140
--- gcc/config/s390/s390.h	20 Jun 2005 12:16:34 -0000
*************** extern const enum reg_class regclass_map
*** 506,512 ****
     are accessed by positive offsets, and function arguments are stored at
     increasing addresses.  */
  #define STACK_GROWS_DOWNWARD
! /* #undef FRAME_GROWS_DOWNWARD */
  /* #undef ARGS_GROW_DOWNWARD */
  
  /* The basic stack layout looks like this: the stack pointer points
--- 506,512 ----
     are accessed by positive offsets, and function arguments are stored at
     increasing addresses.  */
  #define STACK_GROWS_DOWNWARD
! #define FRAME_GROWS_DOWNWARD
  /* #undef ARGS_GROW_DOWNWARD */
  
  /* The basic stack layout looks like this: the stack pointer points
*************** extern const enum reg_class regclass_map
*** 518,530 ****
  #define STACK_POINTER_OFFSET (TARGET_64BIT ? 160 : 96)
  
  /* Offset within stack frame to start allocating local variables at.  */
! extern int current_function_outgoing_args_size;
! #define STARTING_FRAME_OFFSET \
!      (STACK_POINTER_OFFSET + current_function_outgoing_args_size)
  
  /* Offset from the stack pointer register to an item dynamically
     allocated on the stack, e.g., by `alloca'.  */
! #define STACK_DYNAMIC_OFFSET(FUNDECL) (STARTING_FRAME_OFFSET)
  
  /* Offset of first parameter from the argument pointer register value.
     We have a fake argument pointer register that points directly to
--- 518,530 ----
  #define STACK_POINTER_OFFSET (TARGET_64BIT ? 160 : 96)
  
  /* Offset within stack frame to start allocating local variables at.  */
! #define STARTING_FRAME_OFFSET 0
  
  /* Offset from the stack pointer register to an item dynamically
     allocated on the stack, e.g., by `alloca'.  */
! extern int current_function_outgoing_args_size;
! #define STACK_DYNAMIC_OFFSET(FUNDECL) \
!   (STACK_POINTER_OFFSET + current_function_outgoing_args_size)
  
  /* Offset of first parameter from the argument pointer register value.
     We have a fake argument pointer register that points directly to


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