Module Name:    src
Committed By:   joerg
Date:           Fri Sep 14 13:00:01 UTC 2012

Modified Files:
        src/external/gpl3/gcc/dist/gcc/config/i386: i386.c netbsd-elf.h
            netbsd64.h

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
    src/external/gpl3/gcc/dist/gcc/config/i386/i386.c \
    src/external/gpl3/gcc/dist/gcc/config/i386/netbsd64.h
cvs rdiff -u -r1.2 -r1.3 \
    src/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gcc/dist/gcc/config/i386/i386.c
diff -u src/external/gpl3/gcc/dist/gcc/config/i386/i386.c:1.1.1.1 src/external/gpl3/gcc/dist/gcc/config/i386/i386.c:1.2
--- src/external/gpl3/gcc/dist/gcc/config/i386/i386.c:1.1.1.1	Tue Jun 21 01:22:07 2011
+++ src/external/gpl3/gcc/dist/gcc/config/i386/i386.c	Fri Sep 14 13:00:01 2012
@@ -20104,7 +20104,9 @@ ix86_local_alignment (tree exp, enum mac
   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 @@ ix86_local_alignment (tree exp, enum mac
 	    || 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 @@ ix86_local_alignment (tree exp, enum mac
 	   || 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;
Index: src/external/gpl3/gcc/dist/gcc/config/i386/netbsd64.h
diff -u src/external/gpl3/gcc/dist/gcc/config/i386/netbsd64.h:1.1.1.1 src/external/gpl3/gcc/dist/gcc/config/i386/netbsd64.h:1.2
--- src/external/gpl3/gcc/dist/gcc/config/i386/netbsd64.h:1.1.1.1	Tue Jun 21 01:22:04 2011
+++ src/external/gpl3/gcc/dist/gcc/config/i386/netbsd64.h	Fri Sep 14 13:00:01 2012
@@ -70,3 +70,7 @@ along with GCC; see the file COPYING3.  
 #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

Index: src/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h
diff -u src/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h:1.2 src/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h:1.3
--- src/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h:1.2	Thu Feb  2 13:07:33 2012
+++ src/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h	Fri Sep 14 13:00:01 2012
@@ -126,3 +126,7 @@ along with GCC; see the file COPYING3.  
 #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

Reply via email to