diff options
author | Joseph Myers <joseph@codesourcery.com> | 2017-06-26 22:01:27 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2017-06-26 22:02:24 +0000 |
commit | c86ed71d633c22d6f638576f7660c52a5f783d66 (patch) | |
tree | 610b82948e239aed3d612a99c01318dedf497422 /sysdeps/i386/fpu/fenv_private.h | |
parent | 3f823e87ccbf3723eb4eeb63b0619f1a0ceb174e (diff) | |
download | glibc-c86ed71d633c22d6f638576f7660c52a5f783d66.tar glibc-c86ed71d633c22d6f638576f7660c52a5f783d66.tar.gz glibc-c86ed71d633c22d6f638576f7660c52a5f783d66.tar.bz2 glibc-c86ed71d633c22d6f638576f7660c52a5f783d66.zip |
Add float128 support for x86_64, x86.
This patch enables float128 support for x86_64 and x86. All GCC
versions that can build glibc provide the required support, but since
GCC 6 and before don't provide __builtin_nanq / __builtin_nansq, sNaN
tests and some tests of NaN payloads need to be disabled with such
compilers (this does not affect the generated glibc binaries at all,
just the tests). bits/floatn.h declares float128 support to be
available for GCC versions that provide the required libgcc support
(4.3 for x86_64, 4.4 for i386 GNU/Linux, 4.5 for i386 GNU/Hurd);
compilation-only support was present some time before then, but not
really useful without the libgcc functions.
fenv_private.h needed updating to avoid trying to put _Float128 values
in registers. I make no assertion of optimality of the
math_opt_barrier / math_force_eval definitions for this case; they are
simply intended to be sufficient to work correctly.
Tested for x86_64 and x86, with GCC 7 and GCC 6. (Testing for x32 was
compilation tests only with build-many-glibcs.py to verify the ABI
baseline updates. I have not done any testing for Hurd, although the
float128 support is enabled there as for GNU/Linux.)
* sysdeps/i386/Implies: Add ieee754/float128.
* sysdeps/x86_64/Implies: Likewise.
* sysdeps/x86/bits/floatn.h: New file.
* sysdeps/x86/float128-abi.h: Likewise.
* manual/math.texi (Mathematics): Document support for _Float128
on x86_64 and x86.
* sysdeps/i386/fpu/fenv_private.h: Include <bits/floatn.h>.
(math_opt_barrier): Do not put _Float128 values in floating-point
registers.
(math_force_eval): Likewise.
[__x86_64__] (SET_RESTORE_ROUNDF128): New macro.
* sysdeps/x86/fpu/Makefile [$(subdir) = math] (CPPFLAGS): Append
to Makefile variable.
* sysdeps/x86/fpu/e_sqrtf128.c: New file.
* sysdeps/x86/fpu/sfp-machine.h: Likewise. Based on libgcc.
* sysdeps/x86/math-tests.h: New file.
* math/libm-test-support.h (XFAIL_FLOAT128_PAYLOAD): New macro.
* math/libm-test-getpayload.inc (getpayload_test_data): Use
XFAIL_FLOAT128_PAYLOAD.
* math/libm-test-setpayload.inc (setpayload_test_data): Likewise.
* math/libm-test-totalorder.inc (totalorder_test_data): Likewise.
* math/libm-test-totalordermag.inc (totalordermag_test_data):
Likewise.
* sysdeps/unix/sysv/linux/i386/libc.abilist: Update.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
* sysdeps/i386/fpu/libm-test-ulps: Likewise.
* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
Diffstat (limited to 'sysdeps/i386/fpu/fenv_private.h')
-rw-r--r-- | sysdeps/i386/fpu/fenv_private.h | 61 |
1 files changed, 39 insertions, 22 deletions
diff --git a/sysdeps/i386/fpu/fenv_private.h b/sysdeps/i386/fpu/fenv_private.h index e20e1f1662..38fd0b92b5 100644 --- a/sysdeps/i386/fpu/fenv_private.h +++ b/sysdeps/i386/fpu/fenv_private.h @@ -1,36 +1,46 @@ #ifndef FENV_PRIVATE_H #define FENV_PRIVATE_H 1 +#include <bits/floatn.h> #include <fenv.h> #include <fpu_control.h> #ifdef __SSE2_MATH__ -# define math_opt_barrier(x) \ - ({ __typeof(x) __x; \ - if (sizeof (x) <= sizeof (double)) \ - __asm ("" : "=x" (__x) : "0" (x)); \ - else \ - __asm ("" : "=t" (__x) : "0" (x)); \ +# define math_opt_barrier(x) \ + ({ __typeof(x) __x; \ + if (sizeof (x) <= sizeof (double) \ + || __builtin_types_compatible_p (__typeof (x), _Float128)) \ + __asm ("" : "=x" (__x) : "0" (x)); \ + else \ + __asm ("" : "=t" (__x) : "0" (x)); \ __x; }) -# define math_force_eval(x) \ - do { \ - if (sizeof (x) <= sizeof (double)) \ - __asm __volatile ("" : : "x" (x)); \ - else \ - __asm __volatile ("" : : "f" (x)); \ +# define math_force_eval(x) \ + do { \ + if (sizeof (x) <= sizeof (double) \ + || __builtin_types_compatible_p (__typeof (x), _Float128)) \ + __asm __volatile ("" : : "x" (x)); \ + else \ + __asm __volatile ("" : : "f" (x)); \ } while (0) #else -# define math_opt_barrier(x) \ - ({ __typeof (x) __x; \ - __asm ("" : "=t" (__x) : "0" (x)); \ +# define math_opt_barrier(x) \ + ({ __typeof (x) __x; \ + if (__builtin_types_compatible_p (__typeof (x), _Float128)) \ + { \ + __x = (x); \ + __asm ("" : "+m" (__x)); \ + } \ + else \ + __asm ("" : "=t" (__x) : "0" (x)); \ __x; }) -# define math_force_eval(x) \ - do { \ - __typeof (x) __x = (x); \ - if (sizeof (x) <= sizeof (double)) \ - __asm __volatile ("" : : "m" (__x)); \ - else \ - __asm __volatile ("" : : "f" (__x)); \ +# define math_force_eval(x) \ + do { \ + __typeof (x) __x = (x); \ + if (sizeof (x) <= sizeof (double) \ + || __builtin_types_compatible_p (__typeof (x), _Float128)) \ + __asm __volatile ("" : : "m" (__x)); \ + else \ + __asm __volatile ("" : : "f" (__x)); \ } while (0) #endif @@ -322,6 +332,13 @@ libc_feresetround_387 (fenv_t *e) # define libc_feholdsetround_53bit libc_feholdsetround_387_53bit #endif +#ifdef __x86_64__ +/* The SSE rounding mode is used by soft-fp (libgcc and glibc) on + x86_64, so that must be set for float128 computations. */ +# define SET_RESTORE_ROUNDF128(RM) \ + SET_RESTORE_ROUND_GENERIC (RM, libc_feholdsetround_sse, libc_feresetround_sse) +#endif + /* We have support for rounding mode context. */ #define HAVE_RM_CTX 1 |