diff mbox series

[3/3,V2] Do not build Decimal/Float128 conversions if decimal is disabled.

Message ID 20210301171950.GC9185@ibm-toto.the-meissners.org
State New
Headers show
Series Honor --disable-decimal-float in PowerPC libgcc _Float128 | expand

Commit Message

Michael Meissner March 1, 2021, 5:19 p.m. UTC
[PATCH 3/3 V2] Do not build Decimal/Float128 conversions if decimal is disabled.

This patch suppresses building the Decimal <-> Float128 conversions if the user
used --disable-decimal-float when configuring GCC.

I have done bootstraps on a little endian power9 system with each of the long
double variants (128-bit IBM, 128-bit IEEE, 64-bit) enabled, and there were no
regressions in each of the builds with the previous version.

In addition, I have built 2 cross compilers from my x86_64 system to little
endian PowerPC Linux.  One build enabled decimal support and one disabled the
decimal support.  On the build that disabled decimal support, I verified that
the _Float128 <-> Decimal conversions were not built.

Can I check this patch into the master branch for GCC 11?

libgcc/
2021-03-01  Michael Meissner  <meissner@linux.ibm.com>

	* config.host (powerpc*-*-linux*): Add t-float128-dec if Decimal
	arithmetic is supported.
	* config/rs6000/t-float128: Add conditions to suppress building the
	Decimal <-> Float128 conversions if --disable-decimal-float.
	* config/rs6000/t-float128-dec: New file.
	* configure.ac (powerpc*-*-linux*): Record whether decimal arithmetic
	is supported.
	* configure: Regenerate.
---
 libgcc/config.host                  |  6 ++++++
 libgcc/config/rs6000/t-float128     |  4 ++++
 libgcc/config/rs6000/t-float128-dec |  4 ++++
 libgcc/configure                    | 21 ++++++++++++++++++++-
 libgcc/configure.ac                 |  7 +++++++
 5 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 libgcc/config/rs6000/t-float128-dec
diff mbox series

Patch

diff --git a/libgcc/config.host b/libgcc/config.host
index f808b61be70..4ab1952899f 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -1217,6 +1217,12 @@  powerpc*-*-linux*)
 	esac
 
 	if test $libgcc_cv_powerpc_float128 = yes; then
+		# Enable building the decimal/Float128 conversions if decimal
+		# arithmetic is supported in the compiler.
+		if test $libgcc_cv_powerpc_float128_dec = yes; then
+			tmake_file="${tmake_file} rs6000/t-float128-dec"
+		fi
+
 		tmake_file="${tmake_file} rs6000/t-float128"
 	fi
 
diff --git a/libgcc/config/rs6000/t-float128 b/libgcc/config/rs6000/t-float128
index 6fb1a3d871b..1d9a0a5e7d7 100644
--- a/libgcc/config/rs6000/t-float128
+++ b/libgcc/config/rs6000/t-float128
@@ -23,6 +23,9 @@  fp128_softfp_shared_obj	= $(addsuffix -sw_s$(objext),$(fp128_softfp_funcs))
 fp128_softfp_obj	= $(fp128_softfp_static_obj) $(fp128_softfp_shared_obj)
 
 # Decimal <-> _Float128 conversions
+# FP128_DECIMAL_CONVERT is set in t-float128-dec if decimal arithmetic is
+# supported.
+ifeq ($(FP128_DECIMAL_CONVERT),yes)
 fp128_dec_funcs		= _kf_to_sd _kf_to_dd _kf_to_td \
 			  _sd_to_kf _dd_to_kf _td_to_kf
 
@@ -33,6 +36,7 @@  fp128_decstr_funcs	= _strtokf _sprintfkf
 # Decimal <-> __ibm128 conversions
 ibm128_dec_funcs	= _tf_to_sd _tf_to_dd _tf_to_td \
 			  _sd_to_tf _dd_to_tf _td_to_tf
+endif
 
 # New functions for software emulation
 fp128_ppc_funcs		= floattikf floatuntikf fixkfti fixunskfti \
diff --git a/libgcc/config/rs6000/t-float128-dec b/libgcc/config/rs6000/t-float128-dec
new file mode 100644
index 00000000000..2873006bb36
--- /dev/null
+++ b/libgcc/config/rs6000/t-float128-dec
@@ -0,0 +1,4 @@ 
+# Enable building the Float128/Decimal conversion routines.  If decimal support
+# is not enabled, this makefile fragment is not included.
+
+FP128_DECIMAL_CONVERT	= yes
diff --git a/libgcc/configure b/libgcc/configure
index 78fc22a5784..23de3a3adfc 100755
--- a/libgcc/configure
+++ b/libgcc/configure
@@ -4913,7 +4913,7 @@  case "$host" in
     case "$enable_cet" in
       auto)
 	# Check if target supports multi-byte NOPs
-	# and if assembler supports CET insn.
+	# and if compiler and assembler support CET insn.
 	cet_save_CFLAGS="$CFLAGS"
 	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -5228,6 +5228,25 @@  fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_powerpc_float128" >&5
 $as_echo "$libgcc_cv_powerpc_float128" >&6; }
 
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PowerPC __float128 libraries with decimal support" >&5
+$as_echo_n "checking for PowerPC __float128 libraries with decimal support... " >&6; }
+if ${libgcc_cv_powerpc_float128_dec+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+_Float128 convert (_Decimal128 a) { return a; }
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libgcc_cv_powerpc_float128_dec=yes
+else
+  libgcc_cv_powerpc_float128_dec=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_powerpc_float128_dec" >&5
+$as_echo "$libgcc_cv_powerpc_float128_dec" >&6; }
+
   CFLAGS="$CFLAGS -mpower9-vector -mfloat128-hardware"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PowerPC ISA 3.0 to build hardware __float128 libraries" >&5
 $as_echo_n "checking for PowerPC ISA 3.0 to build hardware __float128 libraries... " >&6; }
diff --git a/libgcc/configure.ac b/libgcc/configure.ac
index ed50c0e9b49..389dcad7701 100644
--- a/libgcc/configure.ac
+++ b/libgcc/configure.ac
@@ -435,6 +435,13 @@  powerpc*-*-linux*)
     [libgcc_cv_powerpc_float128=yes],
     [libgcc_cv_powerpc_float128=no])])
 
+  AC_CACHE_CHECK([for PowerPC __float128 libraries with decimal support],
+		 [libgcc_cv_powerpc_float128_dec],
+		 [AC_COMPILE_IFELSE(
+    [AC_LANG_SOURCE([_Float128 convert (_Decimal128 a) { return a; }])],
+    [libgcc_cv_powerpc_float128_dec=yes],
+    [libgcc_cv_powerpc_float128_dec=no])])
+
   CFLAGS="$CFLAGS -mpower9-vector -mfloat128-hardware"
   AC_CACHE_CHECK([for PowerPC ISA 3.0 to build hardware __float128 libraries],
 		 [libgcc_cv_powerpc_float128_hw],