Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gcc/dist/gcc/config/i386 Fix GCC to correctly ...



details:   https://anonhg.NetBSD.org/src/rev/13f5775dadf1
branches:  trunk
changeset: 781552:13f5775dadf1
user:      joerg <joerg%NetBSD.org@localhost>
date:      Fri Sep 14 13:00:01 2012 +0000

description:
Fix GCC to correctly implement the i386 psABI on NetBSD.
This consists of two parts:
- for NetBSD/i386 and NetBSD/AMD64 with -m32, use a default stack
  alignment of 23bit as specified by the ABI
- ensure that double and long long variables on the stack are by default
  only aligned to 32bit, if there is nothing else in the function
  needing a larger stack alignment

The combination ensures that SSE variables on the stack trigger the
realignment logic, but just using double or long long doesn't.

diffstat:

 external/gpl3/gcc/dist/gcc/config/i386/i386.c       |  10 +++++++---
 external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h |   4 ++++
 external/gpl3/gcc/dist/gcc/config/i386/netbsd64.h   |   4 ++++
 3 files changed, 15 insertions(+), 3 deletions(-)

diffs (56 lines):

diff -r 20d3d2aaf7ff -r 13f5775dadf1 external/gpl3/gcc/dist/gcc/config/i386/i386.c
--- a/external/gpl3/gcc/dist/gcc/config/i386/i386.c     Fri Sep 14 04:53:58 2012 +0000
+++ b/external/gpl3/gcc/dist/gcc/config/i386/i386.c     Fri Sep 14 13:00:01 2012 +0000
@@ -20104,7 +20104,9 @@
   if (!TARGET_64BIT
       && align == 64
       && ix86_preferred_stack_boundary < 64
-      && (mode == DImode || (type && TYPE_MODE (type) == DImode))
+      && (mode == DImode || (type && TYPE_MODE (type) == DImode)
+          || mode == DFmode || (type && TYPE_MODE (type) == DFmode)
+          || mode == DCmode || (type && TYPE_MODE (type) == DCmode))
       && (!type || !TYPE_USER_ALIGN (type))
       && (!decl || !DECL_USER_ALIGN (decl)))
     align = 32;
@@ -20150,7 +20152,8 @@
            || TREE_CODE (type) == QUAL_UNION_TYPE)
           && TYPE_FIELDS (type))
     {
-      if (DECL_MODE (TYPE_FIELDS (type)) == DFmode && align < 64)
+      if (DECL_MODE (TYPE_FIELDS (type)) == DFmode && align < 64
+          && (TARGET_64BIT || ix86_preferred_stack_boundary >= 64))
        return 64;
       if (ALIGN_MODE_128 (DECL_MODE (TYPE_FIELDS (type))) && align < 128)
        return 128;
@@ -20159,7 +20162,8 @@
           || TREE_CODE (type) == INTEGER_TYPE)
     {
 
-      if (TYPE_MODE (type) == DFmode && align < 64)
+      if (TYPE_MODE (type) == DFmode && align < 64
+          && (TARGET_64BIT || ix86_preferred_stack_boundary >= 64))
        return 64;
       if (ALIGN_MODE_128 (TYPE_MODE (type)) && align < 128)
        return 128;
diff -r 20d3d2aaf7ff -r 13f5775dadf1 external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h
--- a/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h       Fri Sep 14 04:53:58 2012 +0000
+++ b/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h       Fri Sep 14 13:00:01 2012 +0000
@@ -126,3 +126,7 @@
 #undef X87_ENABLE_ARITH
 #define X87_ENABLE_ARITH(MODE) \
   (flag_excess_precision == EXCESS_PRECISION_FAST || (MODE) == DFmode)
+
+/* Preserve i386 psABI  */
+#undef PREFERRED_STACK_BOUNDARY_DEFAULT
+#define PREFERRED_STACK_BOUNDARY_DEFAULT MIN_STACK_BOUNDARY
diff -r 20d3d2aaf7ff -r 13f5775dadf1 external/gpl3/gcc/dist/gcc/config/i386/netbsd64.h
--- a/external/gpl3/gcc/dist/gcc/config/i386/netbsd64.h Fri Sep 14 04:53:58 2012 +0000
+++ b/external/gpl3/gcc/dist/gcc/config/i386/netbsd64.h Fri Sep 14 13:00:01 2012 +0000
@@ -70,3 +70,7 @@
 #define ENABLE_EXECUTE_STACK NETBSD_ENABLE_EXECUTE_STACK
 
 #define TARGET_VERSION fprintf (stderr, " (NetBSD/x86_64 ELF)");
+
+/* Preserve i386 psABI  */
+#undef PREFERRED_STACK_BOUNDARY_DEFAULT
+#define PREFERRED_STACK_BOUNDARY_DEFAULT MIN_STACK_BOUNDARY



Home | Main Index | Thread Index | Old Index