diff mbox

[i386] : Use mxcsr register to set SFP rounding mode for 64bit targets

Message ID CAFULd4aH1ToNt2dei0JjkMVFgQs8mqCK1n5MZRuu7qGxfegQ5Q@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Oct. 10, 2012, 6:34 p.m. UTC
Hello!

For 64bit targets, we can use mxcsr register to set soft-FP rounding mode.

2012-10-10  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/sfp-machine.h (FP_RND_NEAREST, FP_RND_ZERO, FP_RND_PINF,
	FP_RND_MINF, FP_RND_MASK, FP_INIT_ROUNDMODE, _FP_DECL_EX): Move to ...
	* config/i386/32/sfp-machine.h: ... here.
	* config/i386/64/sfp-machine.h (FP_RND_NEAREST, FP_RND_ZERO,
	FP_RND_PINF, FP_RND_MINF, FP_RND_MASK, FP_INIT_ROUNDMODE, _FP_DECL_EX):
	New defines.

Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32},
committed to mainline SVN.

Uros.
diff mbox

Patch

Index: config/i386/32/sfp-machine.h
===================================================================
--- config/i386/32/sfp-machine.h	(revision 192323)
+++ config/i386/32/sfp-machine.h	(working copy)
@@ -76,3 +76,18 @@ 
    16byte since soft-fp emulation is done in 16byte.  */
 #define _FP_NANFRAC_E		_FP_QNANBIT_E, 0, 0, 0
 #define _FP_NANFRAC_Q		_FP_QNANBIT_Q, 0, 0, 0
+
+#define FP_RND_NEAREST		0
+#define FP_RND_ZERO		0xc00
+#define FP_RND_PINF		0x800
+#define FP_RND_MINF		0x400
+
+#define FP_RND_MASK		0xc00
+
+#define _FP_DECL_EX \
+  unsigned short _fcw __attribute__ ((unused)) = FP_RND_NEAREST;
+
+#define FP_INIT_ROUNDMODE				\
+  do {							\
+    __asm__ __volatile__ ("fnstcw\t%0" : "=m" (_fcw));	\
+  } while (0)
Index: config/i386/64/sfp-machine.h
===================================================================
--- config/i386/64/sfp-machine.h	(revision 192323)
+++ config/i386/64/sfp-machine.h	(working copy)
@@ -17,3 +17,18 @@ 
 #define _FP_NANFRAC_D		_FP_QNANBIT_D
 #define _FP_NANFRAC_E		_FP_QNANBIT_E, 0
 #define _FP_NANFRAC_Q		_FP_QNANBIT_Q, 0
+
+#define FP_RND_NEAREST		0
+#define FP_RND_ZERO		0x6000
+#define FP_RND_PINF		0x4000
+#define FP_RND_MINF		0x2000
+
+#define FP_RND_MASK		0x6000
+
+#define _FP_DECL_EX \
+  unsigned int _fcw __attribute__ ((unused)) = FP_RND_NEAREST;
+
+#define FP_INIT_ROUNDMODE					\
+  do {								\
+    __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw));	\
+  } while (0)
Index: config/i386/sfp-machine.h
===================================================================
--- config/i386/sfp-machine.h	(revision 192323)
+++ config/i386/sfp-machine.h	(working copy)
@@ -55,21 +55,6 @@ 
       __sfp_handle_exceptions (_fex);		\
   } while (0);
 
-#define FP_RND_NEAREST		0
-#define FP_RND_ZERO		0xc00
-#define FP_RND_PINF		0x800
-#define FP_RND_MINF		0x400
-
-#define FP_RND_MASK		0xc00
-
-#define _FP_DECL_EX \
-  unsigned short _fcw __attribute__ ((unused)) = FP_RND_NEAREST
-
-#define FP_INIT_ROUNDMODE				\
-  do {							\
-    __asm__ __volatile__ ("fnstcw\t%0" : "=m" (_fcw));	\
-  } while (0)
-
 #define FP_ROUNDMODE		(_fcw & FP_RND_MASK)
 
 #define	__LITTLE_ENDIAN	1234