public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Allow preferred-stack-boundary of 3 for x86-64
@ 2007-07-24  0:54 Jan Hubicka
  2007-07-27 22:33 ` Andi Kleen
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Hubicka @ 2007-07-24  0:54 UTC (permalink / raw)
  To: gcc-patches, ak

Hi,
Andi Kleen raised point that while x86-64 ABI requires 16byte alignment,
kernel preffers to save stack psace by 8 byte alignment even though it
breaks some of features (such as XMM support or variadic arguments of
types aligned to 16 bytes, such as long double).

This patch thus makes GCC to tolerate this option and updates
documentation accrodingly.  I will install it tomorrow if there are no
complains. Bootstrapped/regtested i686-linux.

Honza

 	* i386.c (override_options): Allow preferred stack boundary of 3 for x86-64.
	* doc/invoke.texi (preferred-stack-boundary): Document.
Index: config/i386/i386.c
===================================================================
*** config/i386/i386.c	(revision 126800)
--- config/i386/i386.c	(working copy)
*************** override_options (void)
*** 2324,2332 ****
    if (ix86_preferred_stack_boundary_string)
      {
        i = atoi (ix86_preferred_stack_boundary_string);
!       if (i < (TARGET_64BIT ? 4 : 2) || i > 12)
  	error ("-mpreferred-stack-boundary=%d is not between %d and 12", i,
! 	       TARGET_64BIT ? 4 : 2);
        else
  	ix86_preferred_stack_boundary = (1 << i) * BITS_PER_UNIT;
      }
--- 2324,2332 ----
    if (ix86_preferred_stack_boundary_string)
      {
        i = atoi (ix86_preferred_stack_boundary_string);
!       if (i < (TARGET_64BIT ? 3 : 2) || i > 12)
  	error ("-mpreferred-stack-boundary=%d is not between %d and 12", i,
! 	       TARGET_64BIT ? 3 : 2);
        else
  	ix86_preferred_stack_boundary = (1 << i) * BITS_PER_UNIT;
      }
Index: doc/invoke.texi
===================================================================
*** doc/invoke.texi	(revision 126800)
--- doc/invoke.texi	(working copy)
*************** libraries that use callbacks always use 
*** 10323,10329 ****
  This extra alignment does consume extra stack space, and generally
  increases code size.  Code that is sensitive to stack space usage, such
  as embedded systems and operating system kernels, may want to reduce the
! preferred alignment to @option{-mpreferred-stack-boundary=2}.
  
  @item -mmmx
  @itemx -mno-mmx
--- 10323,10337 ----
  This extra alignment does consume extra stack space, and generally
  increases code size.  Code that is sensitive to stack space usage, such
  as embedded systems and operating system kernels, may want to reduce the
! preferred alignment to @option{-mpreferred-stack-boundary=2}
! or @option{-mpreferred-stack-boundary=3}.
! 
! The 64bit SYSV ABI require at lest 16-byte alignment. Specifying
! @option{-mpreferred-stack-boundary=3} is accepted by compiler, but will result
! in misaligning the stack. Calling functions with misaligned stack will break
! spilling of SSE registers as well as varargs of types with 16-byte alignment.
! It may be however viable alternative for stack space constrained environments.
! 
  
  @item -mmmx
  @itemx -mno-mmx
Index: config/i386/i386.h
===================================================================
*** config/i386/i386.h	(revision 126800)
--- config/i386/i386.h	(working copy)
*************** extern const char *host_detect_local_cpu
*** 775,781 ****
  /* Target OS keeps a vector-aligned (128-bit, 16-byte) stack.  This is
     mandatory for the 64-bit ABI, and may or may not be true for other
     operating systems.  */
! #define TARGET_KEEPS_VECTOR_ALIGNED_STACK TARGET_64BIT
  
  /* Minimum allocation boundary for the code of a function.  */
  #define FUNCTION_BOUNDARY 8
--- 775,782 ----
  /* Target OS keeps a vector-aligned (128-bit, 16-byte) stack.  This is
     mandatory for the 64-bit ABI, and may or may not be true for other
     operating systems.  */
! #define TARGET_KEEPS_VECTOR_ALIGNED_STACK \
!    (TARGET_64BIT && ix86_preferred_stack_boundary >= 4)
  
  /* Minimum allocation boundary for the code of a function.  */
  #define FUNCTION_BOUNDARY 8

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-07-31  3:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-24  0:54 Allow preferred-stack-boundary of 3 for x86-64 Jan Hubicka
2007-07-27 22:33 ` Andi Kleen
2007-07-31  5:03   ` Jan Hubicka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).