diff options
author | Paul E. Murphy <murphyp@linux.vnet.ibm.com> | 2016-08-09 16:48:54 -0500 |
---|---|---|
committer | Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com> | 2017-06-26 15:04:47 -0300 |
commit | f819dbea0a58270293c49b514b64848c6e84fda1 (patch) | |
tree | 8445824e54752726301e6d4c8d906bd3273451d0 /sysdeps/powerpc/powerpc64le | |
parent | a27d2c19355a15569dfcdd5da741b57acf1a106a (diff) | |
download | glibc-f819dbea0a58270293c49b514b64848c6e84fda1.tar.gz glibc-f819dbea0a58270293c49b514b64848c6e84fda1.tar.xz glibc-f819dbea0a58270293c49b514b64848c6e84fda1.zip |
powerpc64le: Enable float128
This patch adds ULPs for the float128 type, updates the abilist for libc and libm, and adds the files bits/floatn.h and float128-abi.h, in order to enable the new type for powerpc64le. This patch also adds the implementation of sqrtf128 for powerpc64le, since it is not implemented in libgcc. The sfp-machine.h header is taken from libgcc. Tested for powerpc64le (GCC 6.2 and GCC 7.1), powerpc64 and s390x. * manual/math.texi (Mathematics): Mention the enabling of float128 for powerpc64le. * sysdeps/powerpc/bits/floatn.h: New file. * sysdeps/powerpc/fpu/libm-test-ulps: Regenerated. * sysdeps/powerpc/fpu/math_private.h: (__ieee754_sqrtf128): New inline override. * sysdeps/powerpc/powerpc64le/Implies-before: New file. * sysdeps/powerpc/powerpc64le/Makefile: New file. * sysdeps/powerpc/powerpc64le/fpu/e_sqrtf128.c: New file. * sysdeps/powerpc/powerpc64le/fpu/sfp-machine.h: New file. * sysdeps/powerpc/powerpc64le/power9/fpu/e_sqrtf128.c: New file. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Updated. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64le/float128-abi.h: New file.
Diffstat (limited to 'sysdeps/powerpc/powerpc64le')
-rw-r--r-- | sysdeps/powerpc/powerpc64le/Implies-before | 1 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64le/Makefile | 45 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64le/fpu/e_sqrtf128.c | 51 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64le/fpu/sfp-machine.h | 115 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64le/power9/fpu/e_sqrtf128.c | 36 |
5 files changed, 248 insertions, 0 deletions
diff --git a/sysdeps/powerpc/powerpc64le/Implies-before b/sysdeps/powerpc/powerpc64le/Implies-before new file mode 100644 index 0000000000..48065141a9 --- /dev/null +++ b/sysdeps/powerpc/powerpc64le/Implies-before @@ -0,0 +1 @@ +ieee754/float128 diff --git a/sysdeps/powerpc/powerpc64le/Makefile b/sysdeps/powerpc/powerpc64le/Makefile new file mode 100644 index 0000000000..bd8a82dd85 --- /dev/null +++ b/sysdeps/powerpc/powerpc64le/Makefile @@ -0,0 +1,45 @@ +# When building float128 we need to ensure -mfloat128 is +# passed to all such object files. + +ifeq ($(subdir),math) +# sqrtf128 requires emulation before POWER9. +CPPFLAGS += -I../soft-fp + +# float128 requires adding a handful of extra flags. +$(foreach suf,$(all-object-suffixes),%f128$(suf)): CFLAGS += -mfloat128 +$(foreach suf,$(all-object-suffixes),%f128_r$(suf)): CFLAGS += -mfloat128 +$(objpfx)test-float128%.o $(objpfx)test-float128%.os: CFLAGS += -mfloat128 +$(objpfx)test-ifloat128%.o $(objpfx)test-ifloat128%.os: CFLAGS += -mfloat128 +CFLAGS-libm-test-support-float128.c += -mfloat128 +endif + +# Append flags to string <-> _Float128 routines. +ifneq ($(filter $(subdir),wcsmbs stdlib),) +%f128.o %f128.os %f128_l.o %f128_l.os %f128_nan.o %f128_nan.os %float1282mpn.o %float1282mpn.os %mpn2float128.o %mpn2float128.os: CFLAGS += -mfloat128 +CFLAGS-bug-strtod.c += -mfloat128 +CFLAGS-bug-strtod2.c += -mfloat128 +CFLAGS-tst-strtod-round.c += -mfloat128 +CFLAGS-tst-wcstod-round.c += -mfloat128 +CFLAGS-tst-strtod6.c += -mfloat128 +CFLAGS-tst-strfrom.c += -mfloat128 +CFLAGS-tst-strfrom-locale.c += -mfloat128 +CFLAGS-strfrom-skeleton.c += -mfloat128 + +# When building glibc with support for _Float128, the powers of ten tables in +# fpioconst.c and in the string conversion functions must be extended. +sysdep-CFLAGS += $(sysdep-CFLAGS-$(<F)) +sysdep-CFLAGS-fpioconst.c += -mfloat128 +sysdep-CFLAGS-strtod_l.c += -mfloat128 +sysdep-CFLAGS-strtof_l.c += -mfloat128 +sysdep-CFLAGS-strtold_l.c += -mfloat128 +sysdep-CFLAGS-wcstod_l.c += -mfloat128 +sysdep-CFLAGS-wcstof_l.c += -mfloat128 +sysdep-CFLAGS-wcstold_l.c += -mfloat128 +endif + +# Append flags to printf routines. +ifeq ($(subdir),stdio-common) +CFLAGS-printf_fp.c = -mfloat128 +CFLAGS-printf_fphex.c = -mfloat128 +CFLAGS-printf_size.c = -mfloat128 +endif diff --git a/sysdeps/powerpc/powerpc64le/fpu/e_sqrtf128.c b/sysdeps/powerpc/powerpc64le/fpu/e_sqrtf128.c new file mode 100644 index 0000000000..4dcc3637ba --- /dev/null +++ b/sysdeps/powerpc/powerpc64le/fpu/e_sqrtf128.c @@ -0,0 +1,51 @@ +/* soft-fp sqrt for _Float128 + Return sqrt(a) + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file into + combinations with other programs, and to distribute those + combinations without any restriction coming from the use of this + file. (The Lesser General Public License restrictions do apply in + other respects; for example, they cover modification of the file, + and distribution when not linked into a combine executable.) + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Unavoidable hacks since TFmode is assumed to be binary128. */ +#define TFtype KFtype +#define TF KF + +#include <soft-fp.h> +#include <quad.h> + +__float128 +__ieee754_sqrtf128 (__float128 a) +{ + FP_DECL_EX; + FP_DECL_Q (A); + FP_DECL_Q (R); + __float128 r; + + FP_INIT_ROUNDMODE; + FP_UNPACK_Q (A, a); + FP_SQRT_Q (R, A); + FP_PACK_Q (r, R); + FP_HANDLE_EXCEPTIONS; + return r; +} +strong_alias (__ieee754_sqrtf128, __sqrtf128_finite) diff --git a/sysdeps/powerpc/powerpc64le/fpu/sfp-machine.h b/sysdeps/powerpc/powerpc64le/fpu/sfp-machine.h new file mode 100644 index 0000000000..fac5dd0347 --- /dev/null +++ b/sysdeps/powerpc/powerpc64le/fpu/sfp-machine.h @@ -0,0 +1,115 @@ +#define _FP_W_TYPE_SIZE 64 +#define _FP_W_TYPE unsigned long long +#define _FP_WS_TYPE signed long long +#define _FP_I_TYPE long long + +typedef int TItype __attribute__ ((mode (TI))); +typedef unsigned int UTItype __attribute__ ((mode (TI))); + +#define TI_BITS (__CHAR_BIT__ * (int)sizeof(TItype)) + +/* The type of the result of a floating point comparison. This must + match `__libgcc_cmp_return__' in GCC for the target. */ +typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); +#define CMPtype __gcc_CMPtype + +#define _FP_MUL_MEAT_S(R,X,Y) \ + _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm) + +#define _FP_MUL_MEAT_D(R,X,Y) \ + _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm) +#define _FP_MUL_MEAT_Q(R,X,Y) \ + _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm) + +#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_loop(S,R,X,Y) + +#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_1_udiv(D,R,X,Y) +#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_2_udiv(Q,R,X,Y) + +#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1) + +#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1) +#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1 + +#define _FP_NANSIGN_S 0 +#define _FP_NANSIGN_D 0 +#define _FP_NANSIGN_Q 0 + +#define _FP_KEEPNANFRACP 1 +#define _FP_QNANNEGATEDP 0 + +/* Someone please check this. */ +#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \ + do { \ + if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \ + && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \ + { \ + R##_s = Y##_s; \ + _FP_FRAC_COPY_##wc(R,Y); \ + } \ + else \ + { \ + R##_s = X##_s; \ + _FP_FRAC_COPY_##wc(R,X); \ + } \ + R##_c = FP_CLS_NAN; \ + } while (0) + +#define _FP_TININESS_AFTER_ROUNDING 0 + +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __BYTE_ORDER __LITTLE_ENDIAN + +/* Only provide exception support if we have hardware floating point using + floating point registers and we can execute the mtfsf instruction. This + would only be true if we are using the emulation routines for IEEE 128-bit + floating point on pre-ISA 3.0 machines without the IEEE 128-bit floating + point support. */ + +#ifdef __FLOAT128__ +#define ISA_BIT(x) (1LL << (63 - x)) + +/* Use the same bits of the FPSCR. */ +# define FP_EX_INVALID ISA_BIT(34) +# define FP_EX_OVERFLOW ISA_BIT(35) +# define FP_EX_UNDERFLOW ISA_BIT(36) +# define FP_EX_DIVZERO ISA_BIT(37) +# define FP_EX_INEXACT ISA_BIT(38) +# define FP_EX_ALL (FP_EX_INVALID | FP_EX_OVERFLOW \ + | FP_EX_UNDERFLOW | FP_EX_DIVZERO \ + | FP_EX_INEXACT) + +void __sfp_handle_exceptions (int); + +# define FP_HANDLE_EXCEPTIONS \ + do { \ + if (__builtin_expect (_fex, 0)) \ + __sfp_handle_exceptions (_fex); \ + } while (0); + +/* The FP_EX_* bits track whether the exception has occurred. This macro + must set the FP_EX_* bits of those exceptions which are configured to + trap. The FPSCR bit which indicates this is 22 ISA bits above the + respective FP_EX_* bit. Note, the ISA labels bits from msb to lsb, + so 22 ISA bits above is 22 bits below when counted from the lsb. */ +# define FP_TRAPPING_EXCEPTIONS ((_fpscr.i << 22) & FP_EX_ALL) + +# define FP_RND_NEAREST 0x0 +# define FP_RND_ZERO 0x1 +# define FP_RND_PINF 0x2 +# define FP_RND_MINF 0x3 +# define FP_RND_MASK 0x3 + +# define _FP_DECL_EX \ + union { unsigned long long i; double d; } _fpscr __attribute__ ((unused)) = \ + { .i = FP_RND_NEAREST } + +#define FP_INIT_ROUNDMODE \ + do { \ + __asm__ __volatile__ ("mffs %0" \ + : "=f" (_fpscr.d)); \ + } while (0) + +# define FP_ROUNDMODE (_fpscr.i & FP_RND_MASK) +#endif /* !__FLOAT128__ */ diff --git a/sysdeps/powerpc/powerpc64le/power9/fpu/e_sqrtf128.c b/sysdeps/powerpc/powerpc64le/power9/fpu/e_sqrtf128.c new file mode 100644 index 0000000000..769d3f8922 --- /dev/null +++ b/sysdeps/powerpc/powerpc64le/power9/fpu/e_sqrtf128.c @@ -0,0 +1,36 @@ +/* POWER9 sqrt for _Float128 + Return sqrt(a) + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file into + combinations with other programs, and to distribute those + combinations without any restriction coming from the use of this + file. (The Lesser General Public License restrictions do apply in + other respects; for example, they cover modification of the file, + and distribution when not linked into a combine executable.) + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +__float128 +__ieee754_sqrtf128 (__float128 a) +{ + __float128 z; + asm ("xssqrtqp %0,%1" : "=wq" (z) : "wq" (a)); + return z; +} +strong_alias (__ieee754_sqrtf128, __sqrtf128_finite) |