From patchwork Mon Feb 17 22:06:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 38192 X-Patchwork-Delegate: joseph@codesourcery.com Received: (qmail 13156 invoked by alias); 17 Feb 2020 22:06:17 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 12987 invoked by uid 89); 17 Feb 2020 22:06:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=7.3, 66 X-HELO: mx0a-001b2d01.pphosted.com From: "Paul E. Murphy" To: libc-alpha@sourceware.org Subject: [PATCHv2 3/7] ldbl-128ibm-compat: Add tests for IBM long double functions Date: Mon, 17 Feb 2020 16:06:09 -0600 Message-Id: <20200217220609.26623-1-murphyp@linux.vnet.ibm.com> In-Reply-To: References: <20200214161051.32579-4-murphyp@linux.vnet.ibm.com> MIME-Version: 1.0 From: Rajalakshmi Srinivasaraghavan My brain misfired last friday. Such things are not always unheard of on such weekdays. The reason for the awkward macro usage is to work around old compiler quirks. ppc64le will need to bump the minimum compiler version to 7.3 from 6.2 to support building with the new ldouble format. The reason for the awkward __LONG_DOUBLE_USES_FLOAT128 test is that GCC 7 compilers can (and do via later patchsets) get invoked with "-mabi=ieeelongdouble" and without "-mfloat128". GCC 7 treats this as not having _Float128 and thereby __HAVE_DISTINCT_FLOAT128 == 0. I have added a comment noting the above. Likewise, the copyright year is updated in test-ibm.h. Likewise, fix up the co-authorship comments. ---8<--- This patch creates test-ibm128* tests from the long double function tests. In order to explicitly test IBM long double functions -mabi=ibmlongdouble is added to CFLAGS. Likewise, update the test headers to correct choose ULPs when redirects are enabled. Co-authored-by: Tulio Magno Quites Machado Filho Co-authored-by: Paul E. Murphy --- math/Makefile | 7 ++- math/test-float128.h | 6 ++- math/test-float64x.h | 6 ++- math/test-ibm128.h | 19 +++++++ math/test-ldouble.h | 6 +++ sysdeps/ieee754/ldbl-128ibm-compat/Makeconfig | 3 ++ sysdeps/powerpc/powerpc64/le/Makefile | 50 ++++++++++++++++--- 7 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 math/test-ibm128.h create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/Makeconfig diff --git a/math/Makefile b/math/Makefile index 1d203e7ad5..84a8b94c74 100644 --- a/math/Makefile +++ b/math/Makefile @@ -145,10 +145,15 @@ type-float128-yes := float128 # _Float64x may be supported, only as an alias type. type-float64x-yes := float64x +# IBM long double support in additional to IEEE 128 long double support +type-ibm128-suffix := l +type-ibm128-yes := ibm128 + types = $(types-basic) $(type-float128-$(float128-fcts)) test-types = $(test-types-basic) $(type-float128-$(float128-fcts)) \ float32 float64 $(type-float128-$(float128-alias-fcts)) \ - float32x $(type-float64x-$(float64x-alias-fcts)) + float32x $(type-float64x-$(float64x-alias-fcts)) \ + $(type-ibm128-$(ibm128-fcts)) # Pairs of types for which narrowing functions should be tested (this # variable has more entries than libm-narrow-types because it includes diff --git a/math/test-float128.h b/math/test-float128.h index 8f9eec14aa..4cf18fe8d1 100644 --- a/math/test-float128.h +++ b/math/test-float128.h @@ -28,7 +28,11 @@ #define CFLOAT __CFLOAT128 #define BUILD_COMPLEX(real, imag) (CMPLXF128 ((real), (imag))) #define PREFIX FLT128 -#if FLT128_MANT_DIG == LDBL_MANT_DIG +/* __LONG_DOUBLE_USES_FLOAT128 is used instead of __HAVE_DISTINCT_FLOAT128 + because GCC 7 compilers can support IEEE 128 long double without + outwardly supporting _Float128. When minimum GCC is raised to 8, this + check can be replaced. */ +#if __LONG_DOUBLE_USES_FLOAT128 == 0 && FLT128_MANT_DIG == LDBL_MANT_DIG # define TYPE_STR "ldouble" # define ULP_IDX ULP_LDBL # define ULP_I_IDX ULP_I_LDBL diff --git a/math/test-float64x.h b/math/test-float64x.h index 9543238209..1e9916c2d8 100644 --- a/math/test-float64x.h +++ b/math/test-float64x.h @@ -28,7 +28,11 @@ #define CFLOAT __CFLOAT64X #define BUILD_COMPLEX(real, imag) (CMPLXF64X ((real), (imag))) #define PREFIX FLT64X -#if FLT64X_MANT_DIG == LDBL_MANT_DIG +/* __LONG_DOUBLE_USES_FLOAT128 is used instead of __HAVE_DISTINCT_FLOAT128 + because GCC 7 compilers can support IEEE 128 long double without + outwardly supporting _Float128. When minimum GCC is raised to 8, this + check can be replaced. */ +#if __LONG_DOUBLE_USES_FLOAT128 == 0 && FLT64X_MANT_DIG == LDBL_MANT_DIG # define TYPE_STR "ldouble" # define ULP_IDX ULP_LDBL # define ULP_I_IDX ULP_I_LDBL diff --git a/math/test-ibm128.h b/math/test-ibm128.h new file mode 100644 index 0000000000..fce6ef1376 --- /dev/null +++ b/math/test-ibm128.h @@ -0,0 +1,19 @@ +/* Common definitions for libm tests for ibm long double. + Copyright (C) 2020 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. + + 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 + . */ + +#include "test-ldouble.h" diff --git a/math/test-ldouble.h b/math/test-ldouble.h index 17c526bd71..1dc1c86c07 100644 --- a/math/test-ldouble.h +++ b/math/test-ldouble.h @@ -27,6 +27,12 @@ # define TYPE_STR "double" # define ULP_IDX ULP_DBL # define ULP_I_IDX ULP_I_DBL +#elif __LONG_DOUBLE_USES_FLOAT128 == 1 +# define TYPE_STR "float128" +# define ULP_IDX ULP_FLT128 +# define ULP_I_IDX ULP_I_FLT128 +/* _Float128 unconditionally redirects to lgamma. Ensure the ULPs do too. */ +# define gamma lgamma #else # define TYPE_STR "ldouble" # define ULP_IDX ULP_LDBL diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makeconfig b/sysdeps/ieee754/ldbl-128ibm-compat/Makeconfig new file mode 100644 index 0000000000..997f632319 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makeconfig @@ -0,0 +1,3 @@ +# Include this earlier so it can be used earlier in Makefiles, +# and sysdep/ makefiles. +ibm128-fcts = yes diff --git a/sysdeps/powerpc/powerpc64/le/Makefile b/sysdeps/powerpc/powerpc64/le/Makefile index 0ce3868c3c..1594f6b179 100644 --- a/sysdeps/powerpc/powerpc64/le/Makefile +++ b/sysdeps/powerpc/powerpc64/le/Makefile @@ -6,6 +6,13 @@ # linked executables, forcing to link the loader after libgcc link. f128-loader-link = -Wl,--as-needed $(elf-objpfx)ld.so -Wl,--no-as-needed +# Bootstrapping code for enabling IEEE 128. This can be removed and +# any indirections simplified once IEEE 128 long double is enabled. +type-ldouble-CFLAGS = +ifeq ($(ibm128-fcts),yes) +type-ldouble-CFLAGS += -mabi=ibmlongdouble +endif + ifeq ($(subdir),math) # sqrtf128 requires emulation before POWER9. CPPFLAGS += -I../soft-fp @@ -28,13 +35,34 @@ CFLAGS-test-math-iscanonical.cc += -mfloat128 CFLAGS-test-math-iseqsig.cc += -mfloat128 CFLAGS-test-math-issignaling.cc += -mfloat128 CFLAGS-test-math-iszero.cc += -mfloat128 -$(foreach test, \ - test-float128% test-ifloat128% test-float64x% test-ifloat64x% \ - $(foreach pair,$(f128-pairs),test-$(pair)%) \ - test-math-iscanonical test-math-iseqsig test-math-issignaling \ - test-math-iszero, \ - $(objpfx)$(test)): \ +$(foreach test,\ + basic-test \ + bug-nextafter \ + bug-nexttoward \ + test-fenv-clear \ + test-iszero-excess-precision \ + test-math-iscanonical \ + test-math-iseqsig \ + test-math-issignaling \ + test-math-iszero \ + test-misc \ + test-nan-overflow \ + test-nan-payload \ + test-snan \ + test-tgmath \ + test-tgmath2 \ + tst-CMPLX2 \ + test-%-ldbl-128ibm \ + test-ldouble% test-ildouble% \ + test-float128% test-ifloat128% \ + test-float64x% test-ifloat64x% \ + ,$(objpfx)$(test)): \ gnulib-tests += $(f128-loader-link) + +$(foreach suf,$(all-object-suffixes),\ + $(objpfx)libm-test-%ibm128$(suf) \ + $(objpfx)test-iibm128%$(suf) $(objpfx)test-ibm128%$(suf)): \ + CFLAGS += $(type-ldouble-CFLAGS) endif # Append flags to string <-> _Float128 routines. @@ -82,3 +110,13 @@ CFLAGS-printf_fp.c = -mfloat128 CFLAGS-printf_fphex.c = -mfloat128 CFLAGS-printf_size.c = -mfloat128 endif + +$(foreach suf,$(all-object-suffixes),nldbl-%$(suf)): \ + CFLAGS += $(type-ldouble-CFLAGS) + +sysdep-CFLAGS += -mabi=ieeelongdouble -Wno-psabi +$(foreach suf,$(all-object-suffixes),\ + $(objpfx)libm-test-%ibm128$(suf) \ + $(objpfx)test-iibm128%$(suf) $(objpfx)test-ibm128%$(suf)): \ + sysdep-CFLAGS := $(filter-out -mabi=ieeelongdouble \ + -Wno-psabi, $(sysdep-CFLAGS))