public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <jh@suse.cz>
To: gcc-patches@gcc.gnu.org, ak@suse.de
Subject: Allow preferred-stack-boundary of 3 for x86-64
Date: Tue, 24 Jul 2007 00:54:00 -0000	[thread overview]
Message-ID: <20070723230503.GA10270@kam.mff.cuni.cz> (raw)

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

             reply	other threads:[~2007-07-23 23:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-24  0:54 Jan Hubicka [this message]
2007-07-27 22:33 ` Andi Kleen
2007-07-31  5:03   ` Jan Hubicka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070723230503.GA10270@kam.mff.cuni.cz \
    --to=jh@suse.cz \
    --cc=ak@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).