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]

Natural alignment for 64-bit Darwin


The 64-bit Darwin ABI calls for it to do "natural" instead of "power"
alignment, which mostly means that structs with pointers get little
4-byte pads scattered about in them now, and is reputed to yield
better performance.

This patch makes the change. Tested by bootstrapping on a new-enough
Darwin to have natural-aligned libraries, plus testsuite run (with 8
fewer failures - weird, but don't look the gift horse, yadda yadda),
plus cross-eabi build.

Stan

2005-02-22 Stan Shebs <shebs@apple.com>

       * config/rs6000/rs6000.c (rs6000_override_options): Default to
       natural alignment for 64-bit Darwin.
       (rs6000_parse_alignment_option): Warn about uses of -malign-power
       on 64-bit Darwin.
       * doc/invoke.texi: Document this.

Index: config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.786
diff -p -r1.786 rs6000.c
*** config/rs6000/rs6000.c    15 Feb 2005 23:16:46 -0000    1.786
--- config/rs6000/rs6000.c    22 Feb 2005 23:34:43 -0000
*************** rs6000_override_options (const char *def
*** 1316,1321 ****
--- 1316,1323 ----
 #if TARGET_MACHO
       darwin_one_byte_bool = "";
 #endif
+       /* Default to natural alignment, for better performance.  */
+       rs6000_alignment_flags = MASK_ALIGN_NATURAL;
     }

/* Handle -mabi= options. */
*************** rs6000_parse_alignment_option (void)
*** 1684,1690 ****
if (rs6000_alignment_string == 0)
return;
else if (! strcmp (rs6000_alignment_string, "power"))
! rs6000_alignment_flags = MASK_ALIGN_POWER;
else if (! strcmp (rs6000_alignment_string, "natural"))
rs6000_alignment_flags = MASK_ALIGN_NATURAL;
else
--- 1686,1701 ----
if (rs6000_alignment_string == 0)
return;
else if (! strcmp (rs6000_alignment_string, "power"))
! {
! /* On 64-bit Darwin, power alignment is ABI-incompatible with
! some C library functions, so warn about it. The flag may be
! useful for performance studies from time to time though, so
! don't disable it entirely. */
! if (DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT)
! warning ("-malign-power is not supported for 64-bit Darwin;"
! " it is incompatible with the installed C and C++ libraries");
! rs6000_alignment_flags = MASK_ALIGN_POWER;
! }
else if (! strcmp (rs6000_alignment_string, "natural"))
rs6000_alignment_flags = MASK_ALIGN_NATURAL;
else
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.581
diff -p -r1.581 invoke.texi
*** doc/invoke.texi 19 Feb 2005 11:44:01 -0000 1.581
--- doc/invoke.texi 22 Feb 2005 23:34:59 -0000
*************** option are incompatible.
*** 10528,10539 ****
@itemx -malign-power
@opindex malign-natural
@opindex malign-power
! On AIX, Darwin, and 64-bit PowerPC GNU/Linux, the option
@option{-malign-natural} overrides the ABI-defined alignment of larger
types, such as floating-point doubles, on their natural size-based boundary.
The option @option{-malign-power} instructs GCC to follow the ABI-specified
alignment rules. GCC defaults to the standard alignment defined in the ABI@.


@item -msoft-float
@itemx -mhard-float
@opindex msoft-float
--- 10528,10542 ----
@itemx -malign-power
@opindex malign-natural
@opindex malign-power
! On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
@option{-malign-natural} overrides the ABI-defined alignment of larger
types, such as floating-point doubles, on their natural size-based boundary.
The option @option{-malign-power} instructs GCC to follow the ABI-specified
alignment rules. GCC defaults to the standard alignment defined in the ABI@.


+ On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
+ is not supported.
+
@item -msoft-float
@itemx -mhard-float
@opindex msoft-float



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