* config.gcc (i[34567]86-*-linux*): Add i386/t-crtpc to tm-file.
authoruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Apr 2007 07:37:56 +0000 (07:37 +0000)
committeruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Apr 2007 07:37:56 +0000 (07:37 +0000)
(x86_64-*-linux*): Ditto.
* config/i386/i386.opt (mpc): New option.
* config/i386/i386.c (overrride_options): Handle
ix87_precision_string.
* config/i386/crtprec.c: New file.
* config/i386/t-crtpc: Ditto.
* config/i386/linux.h (ENDFILE_SPEC): Add handling of -mpc32, -mpc64
and -mpc80 options.
* config/i386/linux64.h (ENDFILE_SPEC): Ditto.
* config/i386/t-linux64 (EXTRA_MULTILIB_PARTS): Add
crtprec32.o, crtprec64.o and crtprec80.o.

* doc/invoke.texi (Machine Dependent Options): Add -mpc32, -mpc64
and -mpc80 options.
(i386 and x86-64 Options): Document -mpc32, -mpc64 and -mpc80 options.

libgcc/ChangeLog:

* config/i386/t-crtpc: New file.
* config.host (i[34567]86-*-linux*): Add i386/t-crtpc to tm-file.
        (x86_64-*-linux*): Ditto.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123450 138bc75d-0d04-0410-961f-82ee72b054a4

13 files changed:
gcc/ChangeLog
gcc/config.gcc
gcc/config/i386/crtprec.c [new file with mode: 0644]
gcc/config/i386/i386.c
gcc/config/i386/i386.opt
gcc/config/i386/linux.h
gcc/config/i386/linux64.h
gcc/config/i386/t-crtpc [new file with mode: 0644]
gcc/config/i386/t-linux64
gcc/doc/invoke.texi
libgcc/ChangeLog
libgcc/config.host
libgcc/config/i386/t-crtpc [new file with mode: 0644]

index e81b8b0..e9656a0 100644 (file)
@@ -1,3 +1,22 @@
+2007-04-03  Uros Bizjak  <ubizjak@gmail.com>
+
+       * config.gcc (i[34567]86-*-linux*): Add i386/t-crtpc to tm-file.
+       (x86_64-*-linux*): Ditto.
+       * config/i386/i386.opt (mpc): New option.
+       * config/i386/i386.c (overrride_options): Handle
+       ix87_precision_string.
+       * config/i386/crtprec.c: New file.
+       * config/i386/t-crtpc: Ditto.
+       * config/i386/linux.h (ENDFILE_SPEC): Add handling of -mpc32, -mpc64
+       and -mpc80 options.
+       * config/i386/linux64.h (ENDFILE_SPEC): Ditto.
+       * config/i386/t-linux64 (EXTRA_MULTILIB_PARTS): Add
+       crtprec32.o, crtprec64.o and crtprec80.o.
+
+       * doc/invoke.texi (Machine Dependent Options): Add -mpc32, -mpc64
+       and -mpc80 options.
+       (i386 and x86-64 Options): Document -mpc32, -mpc64 and -mpc80 options.
+
 2007-04-02  Eric Christopher  <echristo@apple.com>
 
        * doc/invoke.texi (i386 and x86-64 Options): Document -m64
@@ -64,7 +83,7 @@
        (call_value): Likewise.
 
 2007-03-31  Wolfgang Bangerth  <bangerth@dealii.org>
-            Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+           Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
 
        PR 14737
        * doc/invoke.texi: (optimization options): Reword description
index 7cf3299..476f7bd 100644 (file)
@@ -1147,7 +1147,7 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu)
        i[34567]86-*-knetbsd*-gnu) tm_file="${tm_file} i386/linux.h knetbsd-gnu.h i386/knetbsd-gnu.h" ;;
        i[34567]86-*-kfreebsd*-gnu) tm_file="${tm_file} i386/linux.h kfreebsd-gnu.h i386/kfreebsd-gnu.h" ;;
        esac
-       tmake_file="${tmake_file} i386/t-crtstuff i386/t-crtfm t-dfprules"
+       tmake_file="${tmake_file} i386/t-crtstuff i386/t-crtpc i386/t-crtfm t-dfprules"
        ;;
 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 \
@@ -1156,7 +1156,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 i386/t-crtfm t-dfprules"
+       tmake_file="${tmake_file} i386/t-linux64 i386/t-crtpc i386/t-crtfm t-dfprules"
        ;;
 i[34567]86-*-gnu*)
        ;;
diff --git a/gcc/config/i386/crtprec.c b/gcc/config/i386/crtprec.c
new file mode 100644 (file)
index 0000000..0c98b81
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2007 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, 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, 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.
+ */
+
+#if __PREC == 32
+ #define X87CW         (0 << 8)        /* Single precision (24 bits) */
+#elif __PREC == 64
+ #define X87CW         (2 << 8)        /* Double precision (53 bits) */
+#elif __PREC == 80
+ #define X87CW         (3 << 8)        /* Extended precision (64 bits) */
+#else
+ #error "Wrong precision requested."
+#endif
+
+#define X87CW_PCMASK   (3 << 8)
+
+static void __attribute__((constructor))
+set_precision (void)
+{
+  unsigned short int cwd;
+
+  asm volatile ("fstcw\t%0" : "=m" (cwd));
+
+  cwd &= ~X87CW_PCMASK;
+  cwd |= X87CW;
+
+  asm volatile ("fldcw\t%0" : : "m" (cwd));
+}
index 7106e87..a782308 100644 (file)
@@ -2095,6 +2095,13 @@ override_options (void)
               ix86_tls_dialect_string);
     }
 
+  if (ix87_precision_string)
+    {
+      i = atoi (ix87_precision_string);
+      if (i != 32 && i != 64 && i != 80)
+       error ("pc%d is not valid precision setting (32, 64 or 80)", i);
+    }
+
   /* Keep nonleaf frame pointers.  */
   if (flag_omit_frame_pointer)
     target_flags &= ~MASK_OMIT_LEAF_FRAME_POINTER;
index 7eafe4e..59b7bfe 100644 (file)
@@ -151,6 +151,10 @@ momit-leaf-frame-pointer
 Target Report Mask(OMIT_LEAF_FRAME_POINTER)
 Omit the frame pointer in leaf functions
 
+mpc
+Target RejectNegative Report Joined Var(ix87_precision_string)
+Set 80387 floating-point precision (-mpc32, -mpc64, -mpc80)
+
 mpentium
 Target RejectNegative Undocumented
 ;; Deprecated
index 7eb2395..f0f7df6 100644 (file)
@@ -121,6 +121,9 @@ Boston, MA 02110-1301, USA.  */
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC \
   "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
+   %{mpc32:crtprec32.o%s} \
+   %{mpc64:crtprec64.o%s} \
+   %{mpc80:crtprec80.o%s} \
    %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
 
 /* A C statement (sans semicolon) to output to the stdio stream
index 2d0c7bf..c6a7c88 100644 (file)
@@ -78,6 +78,9 @@ Boston, MA 02110-1301, USA.  */
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC \
   "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
+   %{mpc32:crtprec32.o%s} \
+   %{mpc64:crtprec64.o%s} \
+   %{mpc80:crtprec80.o%s} \
    %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
 
 #if TARGET_64BIT_DEFAULT
diff --git a/gcc/config/i386/t-crtpc b/gcc/config/i386/t-crtpc
new file mode 100644 (file)
index 0000000..af8947b
--- /dev/null
@@ -0,0 +1,16 @@
+EXTRA_PARTS += crtprec32.o crtprec64.o crtprec80.o
+
+$(T)crtprec32.o: $(srcdir)/config/i386/crtprec.c $(GCC_PASSES)
+       $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -D__PREC=32 -c \
+               $(srcdir)/config/i386/crtprec.c \
+               -o $(T)crtprec32$(objext)
+
+$(T)crtprec64.o: $(srcdir)/config/i386/crtprec.c $(GCC_PASSES)
+       $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -D__PREC=64 -c \
+               $(srcdir)/config/i386/crtprec.c \
+               -o $(T)crtprec64$(objext)
+
+$(T)crtprec80.o: $(srcdir)/config/i386/crtprec.c $(GCC_PASSES)
+       $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -D__PREC=80 -c \
+               $(srcdir)/config/i386/crtprec.c \
+               -o $(T)crtprec80$(objext)
index aac59a0..f875126 100644 (file)
@@ -12,7 +12,8 @@ LIBGCC = stmp-multilib
 INSTALL_LIBGCC = install-multilib
 
 EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o crtbeginS.o crtendS.o \
-                    crtbeginT.o crtfastmath.o
+                    crtbeginT.o crtprec32.o crtprec64.o crtprec80.o \
+                    crtfastmath.o
 
 # The pushl in CTOR initialization interferes with frame pointer elimination.
 # crtend*.o cannot be compiled without -fno-asynchronous-unwind-tables,
index ff42a08..e66977a 100644 (file)
@@ -548,7 +548,7 @@ Objective-C and Objective-C++ Dialects}.
 -mthreads  -mno-align-stringops  -minline-all-stringops @gol
 -mpush-args  -maccumulate-outgoing-args  -m128bit-long-double @gol
 -m96bit-long-double  -mregparm=@var{num}  -msseregparm @gol
--mstackrealign @gol
+-mpc32 -mpc64 -mpc80 mstackrealign @gol
 -momit-leaf-frame-pointer  -mno-red-zone -mno-tls-direct-seg-refs @gol
 -mcmodel=@var{code-model} @gol
 -m32  -m64 -mlarge-data-threshold=@var{num}}
@@ -10018,6 +10018,21 @@ function by using the function attribute @samp{sseregparm}.
 modules with the same value, including any libraries.  This includes
 the system libraries and startup modules.
 
+@item -mpc32
+@itemx -mpc64
+@itemx -mpc80
+@opindex mpc32
+@opindex mpc64
+@opindex mpc80
+
+Set 80387 floating-point precision to 32, 64 or 80 bits.  When @option{-mpc32}
+is specified, the significand of floating-point operations is rounded to 24
+bits (single precision), @option{-mpc64} rounds the significand of
+floating-point operations to 53 bits (double precision) and @option{-mpc80}
+rounds the significand of floating-point operations to 64 bits (extended
+double precision).  Note that a change of default precision control may
+affect the results returned by some of the mathematical functions.
+
 @item -mstackrealign
 @opindex mstackrealign
 Realign the stack at entry.  On the Intel x86, the
index de59b9d..6b1c4b1 100644 (file)
@@ -1,3 +1,9 @@
+2007-04-03  Uros Bizjak  <ubizjak@gmail.com>
+
+       * config/i386/t-crtpc: New file.
+       * config.host (i[34567]86-*-linux*): Add i386/t-crtpc to tm-file.
+        (x86_64-*-linux*): Ditto.
+
 2007-02-30  Kai Tietz  <kai.tietz@onevision.com>
 
        * config.host (x86_64-*-mingw*): New target.
index f5fff37..3e575ab 100644 (file)
@@ -328,12 +328,12 @@ i[34567]86-*-openbsd*)
 i[34567]86-*-coff*)
        ;;
 i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu)
-       extra_parts="$extra_parts crtfastmath.o"
-       tmake_file="${tmake_file} i386/t-crtfm"
+       extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o"
+       tmake_file="${tmake_file} i386/t-crtpc i386/t-crtfm"
        ;;
 x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu)
-       extra_parts="$extra_parts crtfastmath.o"
-       tmake_file="${tmake_file} i386/t-crtfm"
+       extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o"
+       tmake_file="${tmake_file} i386/t-crtpc i386/t-crtfm"
        ;;
 i[34567]86-*-gnu*)
        ;;
diff --git a/libgcc/config/i386/t-crtpc b/libgcc/config/i386/t-crtpc
new file mode 100644 (file)
index 0000000..c231ce1
--- /dev/null
@@ -0,0 +1,8 @@
+crtprec32.o: $(gcc_srcdir)/config/i386/crtprec.c
+       $(gcc_compile) -D__PREC=32 -c $<
+
+crtprec64.o: $(gcc_srcdir)/config/i386/crtprec.c
+       $(gcc_compile) -D__PREC=64 -c $<
+
+crtprec80.o: $(gcc_srcdir)/config/i386/crtprec.c
+       $(gcc_compile) -D__PREC=80 -c $<