From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1005) id 9030538493C8; Wed, 18 Jan 2023 16:19:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9030538493C8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674058781; bh=SxJm+GO2Lac+IaoBlnHSNYr8Iys82Eu4Vuz3a3aMBjE=; h=From:To:Subject:Date:From; b=B4o9FnVQiVSOxYhKx4OaHoUj/PLWwsO1zMnZj0PIS3qTug8xGDMkiPVSGDXPhzt+v 6sw1AtASxuTdT30n4q1Wk8zGutr4jXR14jOWaWYBjqOb4jGkDT93Lsb1RovgDeJ0yg eQ6ZD1c4reAy9vBsTgqlyaljGl1OnjEbrYZWNaPI= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Michael Meissner To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/meissner/heads/work106)] PR target/107299: Fix build issue when long double is IEEE 128-bit X-Act-Checkin: gcc X-Git-Author: Michael Meissner X-Git-Refname: refs/users/meissner/heads/work106 X-Git-Oldrev: 68ed94d070d5b216376052662f57532afa088c1d X-Git-Newrev: d54e3d92dd6541057c7feb7dace84f4eb8497012 Message-Id: <20230118161941.9030538493C8@sourceware.org> Date: Wed, 18 Jan 2023 16:19:41 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d54e3d92dd6541057c7feb7dace84f4eb8497012 commit d54e3d92dd6541057c7feb7dace84f4eb8497012 Author: Michael Meissner Date: Wed Jan 18 11:19:20 2023 -0500 PR target/107299: Fix build issue when long double is IEEE 128-bit This patch updates the IEEE 128-bit types used in libgcc. At the moment, we cannot build GCC when the target uses IEEE 128-bit long doubles, such as building the compiler for a native Fedora 36 system. The build dies when it is trying to build the _mulkc3.c and _divkc3 modules. This patch changes libgcc to use long double for the IEEE 128-bit base type if long double is IEEE 128-bit, and it uses _Float128 otherwise. The built-in functions are adjusted to be the correct version based on the IEEE 128-bit base type used. While it is desirable to ultimately have __float128 and _Float128 use the same internal type and mode within GCC, at present if you use the option -mabi=ieeelongdouble, the __float128 type will use the long double type and not the _Float128 type. We get an internal compiler error if we combine the signbitf128 built-in with a long double type. I've gone through several iterations of trying to fix this within GCC, and there are various problems that have come up. I developed this alternative patch that changes libgcc so that it does not tickle the issue. I hope we can fix the compiler at some point, but right now, this is preventing people on Fedora 36 systems from building compilers where the default long double is IEEE 128-bit. 2023-01-18 Michael Meissner PR target/107299 * config/rs6000/_divkc3.c (COPYSIGN): Use the correct built-in based on whether long double is IBM or IEEE. (INFINITY): Likewise. (FABS): Likewise. * config/rs6000/_mulkc3.c (COPYSIGN): Likewise. (INFINITY): Likewise. * config/rs6000/quad-float128.h (TF): Remove definition. (TFtype): Define to be long double or _Float128. (TCtype): Define to be _Complex long double or _Complex _Float128. * libgcc2.h (TFtype): Allow machine config files to override this. (TCtype): Likewise. * soft-fp/quad.h (TFtype): Likewise. Diff: --- libgcc/config/rs6000/_divkc3.c | 8 ++++++++ libgcc/config/rs6000/_mulkc3.c | 7 +++++++ libgcc/config/rs6000/quad-float128.h | 19 ++++++------------- libgcc/libgcc2.h | 4 ++++ libgcc/soft-fp/quad.h | 2 ++ 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/libgcc/config/rs6000/_divkc3.c b/libgcc/config/rs6000/_divkc3.c index 59ab2137d1d..8eeb0f76ba4 100644 --- a/libgcc/config/rs6000/_divkc3.c +++ b/libgcc/config/rs6000/_divkc3.c @@ -26,9 +26,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "soft-fp.h" #include "quad-float128.h" +#ifndef __LONG_DOUBLE_IEEE128__ #define COPYSIGN(x,y) __builtin_copysignf128 (x, y) #define INFINITY __builtin_inff128 () #define FABS __builtin_fabsf128 + +#else +#define COPYSIGN(x,y) __builtin_copysignl (x, y) +#define INFINITY __builtin_infl () +#define FABS __builtin_fabsl +#endif + #define isnan __builtin_isnan #define isinf __builtin_isinf #define isfinite __builtin_isfinite diff --git a/libgcc/config/rs6000/_mulkc3.c b/libgcc/config/rs6000/_mulkc3.c index cfae81f8b5f..290dc89bbc1 100644 --- a/libgcc/config/rs6000/_mulkc3.c +++ b/libgcc/config/rs6000/_mulkc3.c @@ -26,8 +26,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "soft-fp.h" #include "quad-float128.h" +#ifndef __LONG_DOUBLE_IEEE128__ #define COPYSIGN(x,y) __builtin_copysignf128 (x, y) #define INFINITY __builtin_inff128 () + +#else +#define COPYSIGN(x,y) __builtin_copysignl (x, y) +#define INFINITY __builtin_infl () +#endif + #define isnan __builtin_isnan #define isinf __builtin_isinf diff --git a/libgcc/config/rs6000/quad-float128.h b/libgcc/config/rs6000/quad-float128.h index ae0622c744c..8332184348a 100644 --- a/libgcc/config/rs6000/quad-float128.h +++ b/libgcc/config/rs6000/quad-float128.h @@ -27,21 +27,14 @@ License along with the GNU C Library; if not, see . */ -/* quad.h defines the TFtype type by: - typedef float TFtype __attribute__ ((mode (TF))); - - This define forces it to use KFmode (aka, ieee 128-bit floating point). - However, when the compiler's default is changed so that long double is IEEE - 128-bit floating point, we need to go back to using TFmode and TCmode. */ -#ifndef __LONG_DOUBLE_IEEE128__ -#define TF KF - -/* We also need TCtype to represent complex ieee 128-bit float for - __mulkc3 and __divkc3. */ -typedef __complex float TCtype __attribute__ ((mode (KC))); +/* Override the types for IEEE 128-bit scalar and complex. */ +#ifdef __LONG_DOUBLE_IEEE128__ +#define TFtype long double +#define TCtype _Complex long double #else -typedef __complex float TCtype __attribute__ ((mode (TC))); +#define TFtype _Float128 +#define TCtype _Complex _Float128 #endif /* Force the use of the VSX instruction set. */ diff --git a/libgcc/libgcc2.h b/libgcc/libgcc2.h index fc24ac34502..6a249877c7a 100644 --- a/libgcc/libgcc2.h +++ b/libgcc/libgcc2.h @@ -156,9 +156,13 @@ typedef float XFtype __attribute__ ((mode (XF))); typedef _Complex float XCtype __attribute__ ((mode (XC))); #endif #if LIBGCC2_HAS_TF_MODE +#ifndef TFtype typedef float TFtype __attribute__ ((mode (TF))); +#endif +#ifndef TCtype typedef _Complex float TCtype __attribute__ ((mode (TC))); #endif +#endif typedef int cmp_return_type __attribute__((mode (__libgcc_cmp_return__))); typedef int shift_count_type __attribute__((mode (__libgcc_shift_count__))); diff --git a/libgcc/soft-fp/quad.h b/libgcc/soft-fp/quad.h index 3889bb44f1f..71f87d36ba9 100644 --- a/libgcc/soft-fp/quad.h +++ b/libgcc/soft-fp/quad.h @@ -65,7 +65,9 @@ #define _FP_HIGHBIT_DW_Q \ ((_FP_W_TYPE) 1 << (_FP_WFRACBITS_DW_Q - 1) % _FP_W_TYPE_SIZE) +#ifndef TFtype typedef float TFtype __attribute__ ((mode (TF))); +#endif #if _FP_W_TYPE_SIZE < 64