Module Name:    src
Committed By:   riz
Date:           Wed Oct 17 21:30:33 UTC 2012

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

Log Message:
Pull up following revision(s) (requested by joerg in ticket #560):
        external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h: revision 1.3
        external/gpl3/gcc/dist/gcc/config/i386/netbsd64.h: revision 1.2
        external/gpl3/gcc/dist/gcc/config/i386/i386.c: revision 1.2
        external/gpl3/gcc/dist/gcc/config/i386/i386.h: revision 1.2
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.
PR 46978: ICE on spilling MMX registers
GCC/i386 has code to lower the required alignment for long long to 32bit
as the CPU doesn't need more. It is also using the same mode for setting
up the MMX registers and in turn, the stack slots reserved for spilling
require 32bit alignment. The actual vector types used keep the original
64bit alignment, so when the compiler wants to spill a MMX register, it
hits an assertion. Fix this by using the vector type as raw type for MMX
registers.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.1.1.1.4.1 \
    src/external/gpl3/gcc/dist/gcc/config/i386/i386.c \
    src/external/gpl3/gcc/dist/gcc/config/i386/i386.h \
    src/external/gpl3/gcc/dist/gcc/config/i386/netbsd64.h
cvs rdiff -u -r1.2 -r1.2.2.1 \
    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.1.1.1.4.1
--- 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	Wed Oct 17 21:30:32 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/i386.h
diff -u src/external/gpl3/gcc/dist/gcc/config/i386/i386.h:1.1.1.1 src/external/gpl3/gcc/dist/gcc/config/i386/i386.h:1.1.1.1.4.1
--- src/external/gpl3/gcc/dist/gcc/config/i386/i386.h:1.1.1.1	Tue Jun 21 01:22:05 2011
+++ src/external/gpl3/gcc/dist/gcc/config/i386/i386.h	Wed Oct 17 21:30:33 2012
@@ -1081,6 +1081,7 @@ enum target_cpu_default
 
 #define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE)			\
   (CC_REGNO_P (REGNO) ? VOIDmode					\
+   : MMX_REGNO_P (REGNO) ? V8QImode					\
    : (MODE) == VOIDmode && (NREGS) != 1 ? VOIDmode			\
    : (MODE) == VOIDmode ? choose_hard_reg_mode ((REGNO), (NREGS), false) \
    : (MODE) == HImode && !TARGET_PARTIAL_REG_STALL ? SImode		\
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.1.1.1.4.1
--- 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	Wed Oct 17 21:30:31 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.2.2.1
--- 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	Wed Oct 17 21:30:30 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