aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorH.J. Lu <hongjiu.lu@intel.com>2005-08-10 17:53:01 +0000
committerH.J. Lu <hjl@gcc.gnu.org>2005-08-10 10:53:01 -0700
commitd75e02d6431bdc368eeff1d96212279a8ca30886 (patch)
treebc5fff1f53e3cfe22ef306e0d84c9217534d0dbd /gcc
parent863c5508d3b6531c7ab0f3380e059be02e61f4db (diff)
downloadgcc-d75e02d6431bdc368eeff1d96212279a8ca30886.zip
gcc-d75e02d6431bdc368eeff1d96212279a8ca30886.tar.gz
gcc-d75e02d6431bdc368eeff1d96212279a8ca30886.tar.bz2
config.gcc (i[34567]86-*-linux*): Add i386/t-crtfm to tm-file.
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/config.gcc4
-rw-r--r--gcc/config/i386/crtfastmath.c72
-rw-r--r--gcc/config/i386/linux.h6
-rw-r--r--gcc/config/i386/linux64.h6
-rw-r--r--gcc/config/i386/t-crtfm6
-rw-r--r--gcc/config/i386/t-linux643
7 files changed, 108 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e13b94e..4de14de 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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):
diff --git a/gcc/config.gcc b/gcc/config.gcc
index c7c2cf1..f4f045e 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -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
index 0000000..3412d6c
--- /dev/null
+++ b/gcc/config/i386/crtfastmath.c
@@ -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);
+ }
+}
diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
index 082cc95..f85a9ef 100644
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
@@ -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.
diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
index 3a37f63..d3ab452 100644
--- a/gcc/config/i386/linux64.h
+++ b/gcc/config/i386/linux64.h
@@ -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
index 0000000..fc4b587
--- /dev/null
+++ b/gcc/config/i386/t-crtfm
@@ -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)
diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64
index 3b109d8..aac59a0 100644
--- a/gcc/config/i386/t-linux64
+++ b/gcc/config/i386/t-linux64
@@ -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,