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: fix packed stack ABI incompatibility


Hi,

with the packed stack layout we accepted that the -mpacked-stack/-mbackchain 
pair breaks our ABI because as the only user we had the linux kernel in mind. 
Ulrich made me aware that this breakage can be avoided using another special 
layout for the -mbackchain/-mpacked-stack/-mhard-float case (the -msoft-float 
case can be repaired easily).
The patch I've created to do this got much more complex than I had thought 
at the first glance. So that issue will be moved to 4.1.

But nevertheless the unnecessary incompatibility should be removed also in the
current version. So I've compiled a patch which only fixes the 
-mbackchain/-mpacked-stack/-msoft-float case and disables the combination
with -mhard-float. This way it is possible to compile the kernel (which should set
-msoft-float anyway) without creating any ABI incompatibilities and it is 
prevented that a user does wrong things when compiling user space code (where 
-mhard-float is the default).

Bootstrapped on s390 and s390x.

Testsuite runs with 
{-mpacked-stack, -mno-packed-stack}/{-mbackchain, -mno-backchain}/{-mhard-float, -msoft-float}
except -mpacked-stack/-mbackchain/-mhard-float because it is disabled ;-)
completed without regressions.

OK?

Bye,

-Andreas-


2005-01-07  Andreas Krebbel  <krebbel1@de.ibm.com>

	* config/s390/s390.c (override_options): Return error if
	-mbackchain, -mpacked-stack and -mhard-float are used together.
	(s390_va_start): Remove the backchain && packed-stack special case.
	(s390_gimplify_va_arg): Likewise.
	* doc/invoke.texi: Remove the ABI incompatibility note.


Index: gcc/config/s390/s390.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.c,v
retrieving revision 1.210
diff -p -c -r1.210 s390.c
*** gcc/config/s390/s390.c	17 Dec 2004 13:18:00 -0000	1.210
--- gcc/config/s390/s390.c	2 Jan 2005 16:25:48 -0000
*************** override_options (void)
*** 1411,1416 ****
--- 1411,1420 ----
      s390_cost = &z900_cost;
  
  
+   if (TARGET_BACKCHAIN && TARGET_PACKED_STACK && TARGET_HARD_FLOAT)
+     error ("-mbackchain -mpacked-stack -mhard-float are not supported "
+ 	   "in combination.");
+ 
    if (s390_warn_framesize_string)
      {
        if (sscanf (s390_warn_framesize_string, HOST_WIDE_INT_PRINT_DEC,
*************** s390_va_start (tree valist, rtx nextarg 
*** 7682,7696 ****
  
    /* Find the register save area.  */
    t = make_tree (TREE_TYPE (sav), return_address_pointer_rtx);
!   if (TARGET_BACKCHAIN && TARGET_PACKED_STACK) /* kernel stack layout */
!     t = build (PLUS_EXPR, TREE_TYPE (sav), t,
! 	       build_int_cst (NULL_TREE,
! 			      -(RETURN_REGNUM - 2) * UNITS_PER_WORD
! 			      - (TARGET_64BIT ? 4 : 2) * 8));
!   else
!     t = build (PLUS_EXPR, TREE_TYPE (sav), t,
! 	       build_int_cst (NULL_TREE, -RETURN_REGNUM * UNITS_PER_WORD));
! 
    t = build (MODIFY_EXPR, TREE_TYPE (sav), sav, t);
    TREE_SIDE_EFFECTS (t) = 1;
    expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
--- 7686,7694 ----
  
    /* Find the register save area.  */
    t = make_tree (TREE_TYPE (sav), return_address_pointer_rtx);
!   t = build (PLUS_EXPR, TREE_TYPE (sav), t,
! 	     build_int_cst (NULL_TREE, -RETURN_REGNUM * UNITS_PER_WORD));
!   
    t = build (MODIFY_EXPR, TREE_TYPE (sav), sav, t);
    TREE_SIDE_EFFECTS (t) = 1;
    expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
*************** s390_gimplify_va_arg (tree valist, tree 
*** 7758,7765 ****
        /* kernel stack layout on 31 bit: It is assumed here that no padding
  	 will be added by s390_frame_info because for va_args always an even
  	 number of gprs has to be saved r15-r2 = 14 regs.  */
!       sav_ofs = ((TARGET_BACKCHAIN && TARGET_PACKED_STACK) ?
! 		 (TARGET_64BIT ? 4 : 2) * 8 : 2 * UNITS_PER_WORD);
        sav_scale = UNITS_PER_WORD;
        size = UNITS_PER_WORD;
        max_reg = 4;
--- 7756,7762 ----
        /* kernel stack layout on 31 bit: It is assumed here that no padding
  	 will be added by s390_frame_info because for va_args always an even
  	 number of gprs has to be saved r15-r2 = 14 regs.  */
!       sav_ofs = 2 * UNITS_PER_WORD;
        sav_scale = UNITS_PER_WORD;
        size = UNITS_PER_WORD;
        max_reg = 4;
*************** s390_gimplify_va_arg (tree valist, tree 
*** 7776,7783 ****
        indirect_p = 0;
        reg = fpr;
        n_reg = 1;
!       sav_ofs = ((TARGET_BACKCHAIN && TARGET_PACKED_STACK) ?
! 		 0 : 16 * UNITS_PER_WORD);
        sav_scale = 8;
        /* TARGET_64BIT has up to 4 parameter in fprs */
        max_reg = TARGET_64BIT ? 3 : 1;
--- 7773,7779 ----
        indirect_p = 0;
        reg = fpr;
        n_reg = 1;
!       sav_ofs = 16 * UNITS_PER_WORD;
        sav_scale = 8;
        /* TARGET_64BIT has up to 4 parameter in fprs */
        max_reg = TARGET_64BIT ? 3 : 1;
*************** s390_gimplify_va_arg (tree valist, tree 
*** 7798,7805 ****
        /* kernel stack layout on 31 bit: It is assumed here that no padding
  	 will be added by s390_frame_info because for va_args always an even
  	 number of gprs has to be saved r15-r2 = 14 regs.  */
!       sav_ofs = ((TARGET_BACKCHAIN && TARGET_PACKED_STACK) ? 
! 		 (TARGET_64BIT ? 4 : 2) * 8 : 2 * UNITS_PER_WORD);
  
        if (size < UNITS_PER_WORD)
  	sav_ofs += UNITS_PER_WORD - size;
--- 7794,7800 ----
        /* kernel stack layout on 31 bit: It is assumed here that no padding
  	 will be added by s390_frame_info because for va_args always an even
  	 number of gprs has to be saved r15-r2 = 14 regs.  */
!       sav_ofs = 2 * UNITS_PER_WORD;
  
        if (size < UNITS_PER_WORD)
  	sav_ofs += UNITS_PER_WORD - size;
Index: gcc/doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.563
diff -p -c -r1.563 invoke.texi
*** gcc/doc/invoke.texi	28 Dec 2004 04:24:30 -0000	1.563
--- gcc/doc/invoke.texi	2 Jan 2005 16:25:50 -0000
*************** save area.
*** 10892,10899 ****
  In general, code compiled with @option{-mbackchain} is call-compatible with
  code compiled with @option{-mmo-backchain}; however, use of the backchain
  for debugging purposes usually requires that the whole binary is built with
! @option{-mbackchain}.  Note that the combination of @option{-mbackchain} and
! @option{-mpacked-stack} generates code that is not ABI-compatible.
  
  The default is to not maintain the backchain.
  
--- 10892,10900 ----
  In general, code compiled with @option{-mbackchain} is call-compatible with
  code compiled with @option{-mmo-backchain}; however, use of the backchain
  for debugging purposes usually requires that the whole binary is built with
! @option{-mbackchain}.  Note that the combination of @option{-mbackchain},
! @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
! to build a linux kernel use @option{-msoft-float}.
  
  The default is to not maintain the backchain.
  
*************** As long as the stack frame backchain is 
*** 10917,10924 ****
  S/390 or zSeries generated code that uses the stack frame backchain at run
  time, not just for debugging purposes.  Such code is not call-compatible
  with code compiled with @option{-mpacked-stack}.  Also, note that the
! combination of @option{-mbackchain} and @option{-mpacked-stack} generates code
! that is not ABI-compatible.
  
  The default is to not use the packed stack layout.
  
--- 10918,10926 ----
  S/390 or zSeries generated code that uses the stack frame backchain at run
  time, not just for debugging purposes.  Such code is not call-compatible
  with code compiled with @option{-mpacked-stack}.  Also, note that the
! combination of @option{-mbackchain},
! @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
! to build a linux kernel use @option{-msoft-float}.
  
  The default is to not use the packed stack layout.
  


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