diff mbox series

Add PowerPC configuration option --with-long-double-format={ibm,ieee}

Message ID 20180110215357.GA2785@ibm-tiger.the-meissners.org
State New
Headers show
Series Add PowerPC configuration option --with-long-double-format={ibm,ieee} | expand

Commit Message

Michael Meissner Jan. 10, 2018, 9:53 p.m. UTC
This patch is next in my series of patches to enable us to configure the long
double type on PowerPC systems.  This patch is only about the configuration
option.  A future patch will contain the multilib support.

This patch needs the previous patch I submitted today (January 10th, 2018)
applied before it will work.
https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00806.html

I built a bootstrap configuratrion on a little endian power8 system using the
--with-long-double-format-ibm option and it passed with no regressions.  I also
built a non-bootstrap version using --with-long-double-format-ieee and I
verified that it defaulted to IEEE 128-bit for long double.  Can I check this
patch into the trunk once the previous patch has been checked in?

2018-01-10  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* configure.ac (--with-long-double-format): Add support for the
	configuration option to change the default long double format on
	PowerPC systems.
	* config.gcc (powerpc*-linux*-*): Likewise.
	* configure: Regenerate.
	* config/rs6000/rs6000-c.c (rs6000_cpu_cpp_builtins): If long
	double is IEEE, define __KC__ and __KF__ to allow floatn.h to be
	used without modification.

Comments

Joseph Myers Jan. 10, 2018, 11:48 p.m. UTC | #1
On Wed, 10 Jan 2018, Michael Meissner wrote:

> This patch is next in my series of patches to enable us to configure the long
> double type on PowerPC systems.  This patch is only about the configuration
> option.  A future patch will contain the multilib support.

In general we expect configure options to be documented in install.texi.  
Is this one being deliberately omitted because it is only actually usable 
for toolchain development at present, with various ways in which the 
support for IEEE long double is not yet completely functional and library 
support is missing - with documentation intended to be added later once 
fully functional?
Segher Boessenkool Jan. 11, 2018, 6:37 p.m. UTC | #2
Hi Mike,

On Wed, Jan 10, 2018 at 04:53:57PM -0500, Michael Meissner wrote:
> This patch is next in my series of patches to enable us to configure the long
> double type on PowerPC systems.  This patch is only about the configuration
> option.  A future patch will contain the multilib support.
> 
> This patch needs the previous patch I submitted today (January 10th, 2018)
> applied before it will work.
> https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00806.html
> 
> I built a bootstrap configuratrion on a little endian power8 system using the
> --with-long-double-format-ibm option and it passed with no regressions.  I also
> built a non-bootstrap version using --with-long-double-format-ieee and I
> verified that it defaulted to IEEE 128-bit for long double.  Can I check this
> patch into the trunk once the previous patch has been checked in?
> 
> 2018-01-10  Michael Meissner  <meissner@linux.vnet.ibm.com>
> 
> 	* configure.ac (--with-long-double-format): Add support for the
> 	configuration option to change the default long double format on
> 	PowerPC systems.
> 	* config.gcc (powerpc*-linux*-*): Likewise.
> 	* configure: Regenerate.
> 	* config/rs6000/rs6000-c.c (rs6000_cpu_cpp_builtins): If long
> 	double is IEEE, define __KC__ and __KF__ to allow floatn.h to be
> 	used without modification.


> +# Check if TFmode long double target should use the IBM extended double or IEEE
> +# 128-bit floating point formats if long doubles are 128-bits long.  The long
> +# double type can only be switched on powerpc64 bit Linux systems where VSX is
> +# supported.  Other PowerPC systems do not build the IEEE 128-bit emulator in
> +# liggcc.

Typo ("libgcc").

> +AC_ARG_WITH([long-double-format],
> +  [AS_HELP_STRING([--with-long-double-format={ieee,ibm}]
> +		  [Specify whether PowerPC long double uses IEEE or IBM format])],[
> +case x"$target:$with_long_double_format" in

(This does not need the "x" thing because the string can never be empty:
there always is the ":", for starters).

> +  xpowerpc64le-*-linux*:ieee | xpowerpc64le-*-linux*:ibm)
> +    :
> +    ;;
> +  xpowerpc64-*-linux*:ieee | xpowerpc64-*-linux*:*:ibm)

I think you have an extra ":*" here.

> +    # IEEE 128-bit emulationr is only built on 64-bit VSX Linux systems

Typo ("emulation").

The configure script looks more complicated than it has to (you can first
check for valid ieee|ibm and then do the rest, for example).

Okay for trunk with the typos fixed.  Thanks,


Segher
Michael Meissner Jan. 11, 2018, 7:28 p.m. UTC | #3
On Wed, Jan 10, 2018 at 11:48:30PM +0000, Joseph Myers wrote:
> On Wed, 10 Jan 2018, Michael Meissner wrote:
> 
> > This patch is next in my series of patches to enable us to configure the long
> > double type on PowerPC systems.  This patch is only about the configuration
> > option.  A future patch will contain the multilib support.
> 
> In general we expect configure options to be documented in install.texi.  
> Is this one being deliberately omitted because it is only actually usable 
> for toolchain development at present, with various ways in which the 
> support for IEEE long double is not yet completely functional and library 
> support is missing - with documentation intended to be added later once 
> fully functional?

Yes, I'll try to come up with documentation for it next week if I don't get to
it today (I'll be out the next 4 days).
Michael Meissner Jan. 11, 2018, 10:35 p.m. UTC | #4
On Wed, Jan 10, 2018 at 11:48:30PM +0000, Joseph Myers wrote:
> On Wed, 10 Jan 2018, Michael Meissner wrote:
> 
> > This patch is next in my series of patches to enable us to configure the long
> > double type on PowerPC systems.  This patch is only about the configuration
> > option.  A future patch will contain the multilib support.
> 
> In general we expect configure options to be documented in install.texi.  
> Is this one being deliberately omitted because it is only actually usable 
> for toolchain development at present, with various ways in which the 
> support for IEEE long double is not yet completely functional and library 
> support is missing - with documentation intended to be added later once 
> fully functional?

Here is the first pass at documentation.  Segher is this ok?

2018-01-11  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* doc/install.texi (--with-long-double-format=): Document the
	switch, and note it isn't for general use at the moment.
Segher Boessenkool Jan. 12, 2018, 5:27 p.m. UTC | #5
On Thu, Jan 11, 2018 at 05:35:59PM -0500, Michael Meissner wrote:
> On Wed, Jan 10, 2018 at 11:48:30PM +0000, Joseph Myers wrote:
> > On Wed, 10 Jan 2018, Michael Meissner wrote:
> > 
> > > This patch is next in my series of patches to enable us to configure the long
> > > double type on PowerPC systems.  This patch is only about the configuration
> > > option.  A future patch will contain the multilib support.
> > 
> > In general we expect configure options to be documented in install.texi.  
> > Is this one being deliberately omitted because it is only actually usable 
> > for toolchain development at present, with various ways in which the 
> > support for IEEE long double is not yet completely functional and library 
> > support is missing - with documentation intended to be added later once 
> > fully functional?
> 
> Here is the first pass at documentation.  Segher is this ok?

Sure, thanks!  One tiny thing:

> +Specify what format 128-bit @code{long double} should use on PowerPC
> +VSX systems, If you use @code{--with-long-double-format=ibm},

+VSX systems.  If you use @code{--with-long-double-format=ibm},

?


Segher
diff mbox series

Patch

Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 256356)
+++ gcc/configure.ac	(working copy)
@@ -5885,6 +5885,43 @@  if test x$gcc_cv_target_ldbl128 = xyes; 
 	    [Define if TFmode long double should be the default])
 fi
 
+# Check if TFmode long double target should use the IBM extended double or IEEE
+# 128-bit floating point formats if long doubles are 128-bits long.  The long
+# double type can only be switched on powerpc64 bit Linux systems where VSX is
+# supported.  Other PowerPC systems do not build the IEEE 128-bit emulator in
+# liggcc.
+AC_ARG_WITH([long-double-format],
+  [AS_HELP_STRING([--with-long-double-format={ieee,ibm}]
+		  [Specify whether PowerPC long double uses IEEE or IBM format])],[
+case x"$target:$with_long_double_format" in
+  xpowerpc64le-*-linux*:ieee | xpowerpc64le-*-linux*:ibm)
+    :
+    ;;
+  xpowerpc64-*-linux*:ieee | xpowerpc64-*-linux*:*:ibm)
+    # IEEE 128-bit emulationr is only built on 64-bit VSX Linux systems
+    case "$with_cpu" in
+      power7 | power8 | power9 | power1*)
+	:
+	;;
+      *)
+	AC_MSG_ERROR([Configuration option --with-long-double-format is only \
+supported if the default cpu is power7 or newer])
+	with_long_double_format=""
+	;;
+      esac
+      ;;
+  xpowerpc64*-*-linux*:*)
+    AC_MSG_ERROR([--with-long-double-format argument should be ibm or ieee])
+    with_long_double_format=""
+    ;;
+  *)
+    AC_MSG_ERROR([Configure option --with-long-double-format is only supported \
+on 64-bit PowerPC VSX Linux systems])
+    with_long_double_format=""
+    ;;
+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.
 gcc_cv_libc_provides_hwcap_in_tcb=no
Index: gcc/configure
===================================================================
--- gcc/configure	(revision 256356)
+++ gcc/configure	(working copy)
@@ -945,6 +945,7 @@  enable_linker_build_id
 enable_libssp
 enable_default_ssp
 with_long_double_128
+with_long_double_format
 with_gc
 with_system_zlib
 enable_maintainer_mode
@@ -1738,6 +1739,9 @@  Optional Packages:
   --with-glibc-version=M.N
                           assume GCC used with glibc version M.N or later
   --with-long-double-128  use 128-bit long double by default
+  --with-long-double-format={ieee,ibm}
+		  Specify whether PowerPC long double uses IEEE or IBM format
+
   --with-gc={page,zone}   this option is not supported anymore. It used to
                           choose the garbage collection mechanism to use with
                           the compiler
@@ -18442,7 +18446,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18445 "configure"
+#line 18449 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18548,7 +18552,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18551 "configure"
+#line 18555 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -29185,6 +29189,45 @@  $as_echo "#define TARGET_DEFAULT_LONG_DO
 
 fi
 
+# Check if TFmode long double target should use the IBM extended double or IEEE
+# 128-bit floating point formats if long doubles are 128-bits long.  The long
+# double type can only be switched on powerpc64 bit Linux systems where VSX is
+# supported.  Other PowerPC systems do not build the IEEE 128-bit emulator in
+# liggcc.
+
+# Check whether --with-long-double-format was given.
+if test "${with_long_double_format+set}" = set; then :
+  withval=$with_long_double_format;
+case x"$target:$with_long_double_format" in
+  xpowerpc64le-*-linux*:ieee | xpowerpc64le-*-linux*:ibm)
+    :
+    ;;
+  xpowerpc64-*-linux*:ieee | xpowerpc64-*-linux*:*:ibm)
+    # IEEE 128-bit emulationr is only built on 64-bit VSX Linux systems
+    case "$with_cpu" in
+      power7 | power8 | power9 | power1*)
+	:
+	;;
+      *)
+	as_fn_error "Configuration option --with-long-double-format is only \
+supported if the default cpu is power7 or newer" "$LINENO" 5
+	with_long_double_format=""
+	;;
+      esac
+      ;;
+  xpowerpc64*-*-linux*:*)
+    as_fn_error "--with-long-double-format argument should be ibm or ieee" "$LINENO" 5
+    with_long_double_format=""
+    ;;
+  *)
+    as_fn_error "Configure option --with-long-double-format is only supported \
+on 64-bit PowerPC VSX Linux systems" "$LINENO" 5
+    with_long_double_format=""
+    ;;
+esac
+fi
+
+
 # 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.
 gcc_cv_libc_provides_hwcap_in_tcb=no
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 256356)
+++ gcc/config.gcc	(working copy)
@@ -4400,6 +4400,14 @@  case "${target}" in
 			exit 1
 		    fi
 		fi
+
+		# Set up the default long double format if the user changed it.
+		if test x$with_long_double_format = xieee; then
+		    tm_defines="${tm_defines} TARGET_IEEEQUAD_DEFAULT=1"
+
+		elif test x$with_long_double_format = xibm; then
+		    tm_defines="${tm_defines} TARGET_IEEEQUAD_DEFAULT=0"
+		fi
 		;;
 
 	s390*-*-*)
Index: gcc/config/rs6000/rs6000-c.c
===================================================================
--- gcc/config/rs6000/rs6000-c.c	(revision 256356)
+++ gcc/config/rs6000/rs6000-c.c	(working copy)
@@ -708,7 +708,18 @@  rs6000_cpu_cpp_builtins (cpp_reader *pfi
       builtin_define ("__LONGDOUBLE128");
 
       if (TARGET_IEEEQUAD)
-	builtin_define ("__LONG_DOUBLE_IEEE128__");
+	{
+	  /* Older versions of GLIBC used __attribute__((__KC__)) to create the
+	     IEEE 128-bit floating point complex type for C++ (which does not
+	     support _Float128 _Complex).  If the default for long double is
+	     IEEE 128-bit mode, the library would need to use
+	     __attribute__((__TC__)) instead.  Defining __KF__ and __KC__
+	     is a stop-gap to build with the older libraries, until we
+	     get an updated library.  */
+	  builtin_define ("__LONG_DOUBLE_IEEE128__");
+	  builtin_define ("__KF__=__TF__");
+	  builtin_define ("__KC__=__TC__");
+	}
       else
 	builtin_define ("__LONG_DOUBLE_IBM128__");
     }