From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1005) id 2C5503858D37; Wed, 2 Feb 2022 22:01:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2C5503858D37 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/work077)] Use default long double from host compiler if not specified on PowerPC. X-Act-Checkin: gcc X-Git-Author: Michael Meissner X-Git-Refname: refs/users/meissner/heads/work077 X-Git-Oldrev: cff2393c38d6bf5e180bfbf21a01a24a1c7d0dc5 X-Git-Newrev: b8d97c893cc4dd49fea8970fbcd2077cf57ddc9e Message-Id: <20220202220128.2C5503858D37@sourceware.org> Date: Wed, 2 Feb 2022 22:01:28 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Feb 2022 22:01:28 -0000 https://gcc.gnu.org/g:b8d97c893cc4dd49fea8970fbcd2077cf57ddc9e commit b8d97c893cc4dd49fea8970fbcd2077cf57ddc9e Author: Michael Meissner Date: Wed Feb 2 17:01:08 2022 -0500 Use default long double from host compiler if not specified on PowerPC. If the user did not specify a default long double format, set the long double type to IEEE 128-bit if the host compiler uses IEEE 128-bit as the long double default. I used a Fedora rawhide system that was configured to use the default for long double being IEEE 128-bit. I built and bootstrapped a compiler on this system with these patches applied, and I verified that the default for the compiler used IEEE 128-bit long doubles. Can I apply this patch to the trunk for GCC 12? Ideally, this should be back-ported to GCC 11 as well. 2022-02-02 Michael Meissner gcc/ * config.in (TARGET_POWERPC_IEEE_128BIT_LONG_DOUBLE): New configure option. * config/rs6000/rs6000.cc (TARGET_IEEEQUAD_DEFAULT): If the host compiler used IEEE 128-bit long doubles and the long double format was not specified with configuration switches, set the long double format to IEEE 128-bit. * configure.ac (TARGET_POWERPC_IEEE_128BIT_LONG_DOUBLE): Set as 1 if the host compiler used IEEE 128-bit long doubles. * configure: Regenerate. Diff: --- gcc/config.in | 4 ++++ gcc/config/rs6000/rs6000.cc | 7 ++++++- gcc/configure | 33 +++++++++++++++++++++++++++++++++ gcc/configure.ac | 21 ++++++++++++++++++++- 4 files changed, 63 insertions(+), 2 deletions(-) diff --git a/gcc/config.in b/gcc/config.in index 64c27c9cfac..746c522e4e6 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -2732,3 +2732,7 @@ #undef vfork #endif +/* Define if long double is IEEE 128-bit on PowerPC systems by default. */ +#ifndef USED_FOR_TARGET +#define TARGET_POWERPC_IEEE_128BIT_LONG_DOUBLE +#endif diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 666dec694a8..a0e234438cd 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -91,10 +91,15 @@ explicitly redefine TARGET_IEEEQUAD and TARGET_IEEEQUAD_DEFAULT to 0, so those systems will not pick up this default. This needs to be after all of the include files, so that POWERPC_LINUX and POWERPC_FREEBSD are - properly defined. */ + properly defined. + + If we were built with a host compiler that defaulted to IEEE 128-bit, set + the default here to use IEEE 128-bit. */ #ifndef TARGET_IEEEQUAD_DEFAULT #if !defined (POWERPC_LINUX) && !defined (POWERPC_FREEBSD) #define TARGET_IEEEQUAD_DEFAULT 1 +#elif defined (TARGET_POWERPC_IEEE_128BIT_LONG_DOUBLE) +#define TARGET_IEEEQUAD_DEFAULT 1 #else #define TARGET_IEEEQUAD_DEFAULT 0 #endif diff --git a/gcc/configure b/gcc/configure index bd4d4721868..113860968ed 100755 --- a/gcc/configure +++ b/gcc/configure @@ -31473,6 +31473,39 @@ on 64-bit PowerPC VSX Linux systems" "$LINENO" 5 with_long_double_format="" ;; esac +else + gcc_cv_powerpc_ieee_long_double=no + case "$target" in + powerpc*-*-linux*) + # If --with-long-double format is not set, check to see whether the host + # compiler defaults to it. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if PowerPC target defaults to IEEE 128-bit long double" >&5 +$as_echo_n "checking if PowerPC target defaults to IEEE 128-bit long double... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if defined(_ARCH_PPC) && defined(__LONG_DOUBLE_IEEE128__) +IEEE_LDBL +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "IEEE_LDBL" >/dev/null 2>&1; then : + gcc_cv_powerpc_ieee_long_double=yes +else + gcc_cv_powerpc_ieee_long_double=no +fi +rm -f conftest* + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_powerpc_ieee_long_double" >&5 +$as_echo "$gcc_cv_powerpc_ieee_long_double" >&6; } + if test x$gcc_cv_powerpc_ieee_long_double = xyes; then + +$as_echo "#define TARGET_POWERPC_IEEE_128BIT_LONG_DOUBLE 1" >>confdefs.h + + fi + ;; + esac fi diff --git a/gcc/configure.ac b/gcc/configure.ac index 1171c946e6e..d7a0d6e6999 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -6975,7 +6975,26 @@ on 64-bit PowerPC VSX Linux systems]) with_long_double_format="" ;; esac], - []) + [gcc_cv_powerpc_ieee_long_double=no + case "$target" in + powerpc*-*-linux*) + # If --with-long-double format is not set, check to see whether the host + # compiler defaults to it. + AC_MSG_CHECKING(if PowerPC target defaults to IEEE 128-bit long double) + AC_EGREP_CPP(IEEE_LDBL,[ +#if defined(_ARCH_PPC) && defined(__LONG_DOUBLE_IEEE128__) +IEEE_LDBL +#endif + ], + [gcc_cv_powerpc_ieee_long_double=yes], + [gcc_cv_powerpc_ieee_long_double=no]) + AC_MSG_RESULT($gcc_cv_powerpc_ieee_long_double) + if test x$gcc_cv_powerpc_ieee_long_double = xyes; then + AC_DEFINE(TARGET_POWERPC_IEEE_128BIT_LONG_DOUBLE, 1, + [Define if long double is IEEE 128-bit on PowerPC systems by default]) + fi + ;; + esac]) # Check if the target LIBC supports exporting the AT_PLATFORM and AT_HWCAP # values in the TCB. Currently, only GLIBC 2.23 and later support this.