]> gcc.gnu.org Git - gcc.git/commitdiff
config.gcc (i[34567]86-*-linux*): Add i386/t-crtfm to tm-file.
authorH.J. Lu <hongjiu.lu@intel.com>
Wed, 10 Aug 2005 17:53:01 +0000 (17:53 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Wed, 10 Aug 2005 17:53:01 +0000 (10:53 -0700)
2005-08-10  H.J. Lu  <hongjiu.lu@intel.com>

* config.gcc (i[34567]86-*-linux*): Add i386/t-crtfm to tm-file.
(x86_64-*-linux*): Likewise.

* config/i386/crtfastmath.c: New file.
* config/i386/t-crtfm: Likewise.

* config/i386/linux.h (ENDFILE_SPEC): New.
* config/i386/linux64.h (ENDFILE_SPEC): Likewise.

* config/i386/t-linux64 (EXTRA_MULTILIB_PARTS): Add
crtfastmath.o.

From-SVN: r102954

gcc/ChangeLog
gcc/config.gcc
gcc/config/i386/crtfastmath.c [new file with mode: 0644]
gcc/config/i386/linux.h
gcc/config/i386/linux64.h
gcc/config/i386/t-crtfm [new file with mode: 0644]
gcc/config/i386/t-linux64

index e13b94e84281e8dc2494ac8505f9127880959f5e..4de14deb6518d49665344dcf71797c24ee723c27 100644 (file)
@@ -1,3 +1,17 @@
+2005-08-10  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * config.gcc (i[34567]86-*-linux*): Add i386/t-crtfm to tm-file.
+       (x86_64-*-linux*): Likewise.
+
+       * config/i386/crtfastmath.c: New file.
+       * config/i386/t-crtfm: Likewise.
+
+       * config/i386/linux.h (ENDFILE_SPEC): New.
+       * config/i386/linux64.h (ENDFILE_SPEC): Likewise.
+
+       * config/i386/t-linux64 (EXTRA_MULTILIB_PARTS): Add
+       crtfastmath.o.
+
 2005-08-10  Dorit Nuzman  <dorit@il.ibm.com>
 
        * doc/md.texi: (reduc_smin, reduc_umin, reduc_splus, reduc_uplus):
index c7c2cf12ea4f05d486c0403c0a61acd998da4719..f4f045ebce17c9f619186fd259e0da91425a8408 100644 (file)
@@ -1019,7 +1019,7 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu)
        i[34567]86-*-knetbsd*-gnu) tm_file="${tm_file} knetbsd-gnu.h i386/knetbsd-gnu.h" ;;
        i[34567]86-*-kfreebsd*-gnu) tm_file="${tm_file} kfreebsd-gnu.h i386/kfreebsd-gnu.h" ;;
        esac
-       tmake_file="${tmake_file} i386/t-crtstuff"
+       tmake_file="${tmake_file} i386/t-crtstuff i386/t-crtfm"
        ;;
 x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu)
        tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h linux.h \
@@ -1028,7 +1028,7 @@ x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu)
        x86_64-*-kfreebsd*-gnu) tm_file="${tm_file} kfreebsd-gnu.h" ;;
        x86_64-*-knetbsd*-gnu) tm_file="${tm_file} knetbsd-gnu.h" ;;
        esac
-       tmake_file="${tmake_file} i386/t-linux64"
+       tmake_file="${tmake_file} i386/t-linux64 i386/t-crtfm"
        ;;
 i[34567]86-*-gnu*)
        ;;
diff --git a/gcc/config/i386/crtfastmath.c b/gcc/config/i386/crtfastmath.c
new file mode 100644 (file)
index 0000000..3412d6c
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2005 Free Software Foundation, Inc.
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ * 
+ * In addition to the permissions in the GNU General Public License, the
+ * Free Software Foundation gives you unlimited permission to link the
+ * compiled version of this file with other programs, and to distribute
+ * those programs without any restriction coming from the use of this
+ * file.  (The General Public License restrictions do apply in other
+ * respects; for example, they cover modification of the file, and
+ * distribution when not linked into another program.)
+ * 
+ * This file is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ * 
+ *    As a special exception, if you link this library with files
+ *    compiled with GCC to produce an executable, this does not cause
+ *    the resulting executable to be covered by the GNU General Public License.
+ *    This exception does not however invalidate any other reasons why
+ *    the executable file might be covered by the GNU General Public License.
+ */
+
+#define MXCSR_DAZ (1 << 6)     /* Enable denormals are zero mode */
+#define MXCSR_FTZ (1 << 15)    /* Enable flush to zero mode */
+
+static void __attribute__((constructor))
+set_fast_math (void)
+{
+#ifndef __x86_64__
+  /* SSE is the part of 64bit. Only need to check it for 32bit.  */
+  unsigned int eax, ebx, ecx, edx;
+
+  /* See if we can use cpuid.  */
+  asm volatile ("pushfl; pushfl; popl %0; movl %0,%1; xorl %2,%0;"
+               "pushl %0; popfl; pushfl; popl %0; popfl"
+               : "=&r" (eax), "=&r" (ebx)
+               : "i" (0x00200000));
+
+  if (((eax ^ ebx) & 0x00200000) == 0)
+    return;
+
+  /* Check the highest input value for eax.  */
+  asm volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1"
+               : "=a" (eax), "=r" (ebx), "=c" (ecx), "=d" (edx)
+               : "0" (0));
+
+  if (eax == 0)
+    return;
+
+  asm volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1"
+               : "=a" (eax), "=r" (ebx), "=c" (ecx), "=d" (edx)
+               : "0" (1));
+
+  if (edx & (1 << 25))
+#endif
+    {
+      unsigned int mxcsr = __builtin_ia32_stmxcsr ();
+      mxcsr |= MXCSR_DAZ | MXCSR_FTZ;
+      __builtin_ia32_ldmxcsr (mxcsr);
+    }
+}
index 082cc958e0717f73c5b63a8c4424f3394b712877..f85a9ef6cbb1d6e30c324150034073f73921beb8 100644 (file)
@@ -121,6 +121,12 @@ Boston, MA 02110-1301, USA.  */
        %{!dynamic-linker:-dynamic-linker %(dynamic_linker)}} \
        %{static:-static}}}"
 
+/* Similar to standard Linux, but adding -ffast-math support.  */
+#undef  ENDFILE_SPEC
+#define ENDFILE_SPEC \
+  "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
+   %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+
 /* A C statement (sans semicolon) to output to the stdio stream
    FILE the assembler definition of uninitialized global DECL named
    NAME whose size is SIZE bytes and alignment is ALIGN bytes.
index 3a37f634bb6fa6d19db6f641c27aba416d19e65c..d3ab452db324bae2efe858cb89eac84dd6d9cc99 100644 (file)
@@ -64,6 +64,12 @@ Boston, MA 02110-1301, USA.  */
       %{!m32:%{!dynamic-linker:-dynamic-linker /lib64/ld-linux-x86-64.so.2}}} \
     %{static:-static}}"
 
+/* Similar to standard Linux, but adding -ffast-math support.  */
+#undef  ENDFILE_SPEC
+#define ENDFILE_SPEC \
+  "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
+   %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+
 #define MULTILIB_DEFAULTS { "m64" }
 
 #undef NEED_INDICATE_EXEC_STACK
diff --git a/gcc/config/i386/t-crtfm b/gcc/config/i386/t-crtfm
new file mode 100644 (file)
index 0000000..fc4b587
--- /dev/null
@@ -0,0 +1,6 @@
+EXTRA_PARTS += crtfastmath.o
+
+$(T)crtfastmath.o: $(srcdir)/config/i386/crtfastmath.c $(GCC_PASSES)
+       $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -msse -c \
+               $(srcdir)/config/i386/crtfastmath.c \
+               -o $(T)crtfastmath$(objext)
index 3b109d8b0ce1f0856de7d6099edb9cf6085175ab..aac59a08e36840fa0609a419e24f097520127a1b 100644 (file)
@@ -11,7 +11,8 @@ MULTILIB_OSDIRNAMES = ../lib64 ../lib
 LIBGCC = stmp-multilib
 INSTALL_LIBGCC = install-multilib
 
-EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o
+EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o crtbeginS.o crtendS.o \
+                    crtbeginT.o crtfastmath.o
 
 # The pushl in CTOR initialization interferes with frame pointer elimination.
 # crtend*.o cannot be compiled without -fno-asynchronous-unwind-tables,
This page took 0.086228 seconds and 5 git commands to generate.