Hello! Following aarch64 example, we can define FP_TRAPPING_EXCEPTIONS for x86, too.
2012-12-05 Uros Bizjak <ubiz...@gmail.com> * config/i386/sfp-machine.h (FP_EX_ALL): Define. (FP_TRAPPING_EXCEPTIONS): Define. * config/i386/32/sfp-machine.h (FP_EX_SHIFT): Define. * config/i386/64/sfp-machine.h (FP_EX_SHIFT): Ditto. Tested on x86_64-pc-linux-gnu {,-m32}. If there are no objections, I will commit this patch to mainline SVN tomorrow. Uros.
Index: config/i386/32/sfp-machine.h =================================================================== --- config/i386/32/sfp-machine.h (revision 194182) +++ config/i386/32/sfp-machine.h (working copy) @@ -78,6 +78,11 @@ #define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0, 0, 0 #ifndef _SOFT_FLOAT +#define FP_EX_SHIFT 0 + +#define _FP_DECL_EX \ + unsigned short _fcw __attribute__ ((unused)) = FP_RND_NEAREST; + #define FP_RND_NEAREST 0 #define FP_RND_ZERO 0xc00 #define FP_RND_PINF 0x800 @@ -85,9 +90,6 @@ #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)); \ Index: config/i386/sfp-machine.h =================================================================== --- config/i386/sfp-machine.h (revision 194182) +++ config/i386/sfp-machine.h (working copy) @@ -47,6 +47,9 @@ #define FP_EX_OVERFLOW 0x08 #define FP_EX_UNDERFLOW 0x10 #define FP_EX_INEXACT 0x20 +#define FP_EX_ALL \ + (FP_EX_INVALID | FP_EX_DENORM | FP_EX_DIVZERO | FP_EX_OVERFLOW \ + | FP_EX_UNDERFLOW | FP_EX_INEXACT) void __sfp_handle_exceptions (int); @@ -56,6 +59,8 @@ __sfp_handle_exceptions (_fex); \ } while (0); +#define FP_TRAPPING_EXCEPTIONS ((_fcw >> FP_EX_SHIFT) & FP_EX_ALL) + #define FP_ROUNDMODE (_fcw & FP_RND_MASK) #endif Index: config/i386/64/sfp-machine.h =================================================================== --- config/i386/64/sfp-machine.h (revision 194182) +++ config/i386/64/sfp-machine.h (working copy) @@ -19,6 +19,11 @@ #define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0 #ifndef _SOFT_FLOAT +#define FP_EX_SHIFT 7 + +#define _FP_DECL_EX \ + unsigned int _fcw __attribute__ ((unused)) = FP_RND_NEAREST; + #define FP_RND_NEAREST 0 #define FP_RND_ZERO 0x6000 #define FP_RND_PINF 0x4000 @@ -26,9 +31,6 @@ #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)); \