This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH], Add optional IEEE/IBM long double multilib support


This patch is the beginning step to switching the PowerPC long double support
from IBM extended double to IEEE 128-bit floating point on PowerPC servers.  It
will be necessary to have this patch or a similar patch to allow the GLIBC team
to begin their modifications in GLIBC 2.28, so that by the time GCC 9 comes
out, we can decide to switch the default.  It is likely, the default will only
be switched on the 64-bit little endian PowerPC systems, when a distribution
goes through a major level, such that they can contemplate major changes.

If you do not use the configuration option --with-long-double-format=ieee or
--with-long-double-format=ibm, the system will not build multilibs, and just
build normal libraries with the default set to IBM extended double.  If you do
use either of the switches, and allow multilibs, it will build two sets of
multilibs, one for -mabi=ieeelongdouble and one for -mabi=ibmlongdouble.

Now, to build a compiler with multilibs, you need to do the following steps:

1) Install the IBM Advance Toolchain AT 11.0-2.

2) Clone the AT directory:
	# rsync -aH /opt/at11.0/ /opt/at11.0-ieee/

3) Go into the new directory and add a symlink from lib64 to ieee64.
Eventually once we have versions of the libraries compiled for
-mabi=ieeelongdouble, these libraries and objects would go into the ieee64
directory.  However, to do a build, you need the crt files in order to build
the shared libraries.

4) Configure the compiler with these options:
	--with-long-double-128			# should be default
	--with-cpu=power8			# or power9
	--with-long-double-format=ibm		# specify long double format
	--enable-multilib			# enable multilibs
	--with-system-libz			# do not build our own libz
	--with-advance-toolchain=at11.0-ieee	# use the special AT library
						# Use the AT library's includes
	--with-native-system-header-dir=/opt/at11.0-ieee/include
	--with-gnu-ld=/opt/at11.0-ieee/bin/ld	# specify as/ld locations
	--with-gnu-as=/opt/at11.0-ieee/bin/as
	--with-ld=/opt/at11.0-ieee/bin/ld
	--with-as=/opt/at11.0-ieee/bin/as

The libgcc changes were changes that show up when you build libgcc with the
default set to IEEE 128-bit.

There is a work around in rs6000-c.c to allow the AT 11.0-2 include files to be
used as is.  Otherwise, we need to modify /opt/at11.0/include/bits/floatn.h to
specify the correct IEEE 128-bit complex type in C++ (C++ does not support the
_Float128 keyword, and __float128 _Complex does not work, so we have to use the
mode attribute to declare the type).  When -mabi=ieeelongdouble is used, the
default Float128 types are TFmode for scalar and TCmode for complex.  With the
default -mabi=ibmlongdouble is used, the default Float128 types are KFmode and
KCmode.  It is hoped that in AT 11.0-3, we can fix floatn.h to declare the
appropriate type.

I have built bootstrap builds on a little endian power8 system without using
the --with-long-double-format switch and it runs the same as the unpatched
compiler.

I have also built bootstrap builds on a little endian power8 system with the
switches listed above, and the tests for the default long double format are the
same.  Obviously, we can't run multilib make checks until the necessary work
has been done in GLIBC.

I will do a big endian build shortly to make sure it builds normally.

What changes or additional tests do you feel I need to make before checking
this into the trunk?

[gcc]
2018-01-04  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* configure.ac (--with-long-double-format): Add support for
	configuration option to change the default long double format in
	PowerPC Linux systems.
	* configure: Regenerate.
	* config.gcc (powerpc*-linux*-*): Add support for
	--with-long-double-format={ieee,ibm}.  If the format is explicit
	set, also set up IBM and IEEE multilibs.
	* config/rs6000/rs6000.h (FLOAT128_IEEE_P): Explicitly check for
	128-bit long doubles before checking TFmode or TCmode.
	(FLOAT128_IBM_P): Likewise.
	(TARGET_IEEEQUAD_MULTILIB): Set to 0 if not already defined.
	* config/rs6000/rs6000.c (rs6000_option_override_internal): If we
	have IBM/IEEE multilibs, don't give a warning if the user chagnes
	the long double format.
	(is_complex_IBM_long_double): Explicitly check for 128-bit long
	doubles before checking TCmode.
	* 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.
	* config/rs6000/linux64.h (MULTILIB_DEFAULTS_IEEE): Specify the
	-mabi={ieee,ibm}longdouble default for multilibs.
	(MULTILIB_DEFAULTS): Likewise.
	* config/rs6000/t-ldouble: New file, add IEEE/IBM long double
	multilibs.

[libgcc]
2018-01-04  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* config/rs6000/quad-float128.h (IBM128_TYPE): Explicitly use
	__ibm128, instead of trying to use long double.
	(CVT_FLOAT128_TO_IBM128): Use TFtype instead of __float128 to
	accomidate -mabi=ieeelongdouble multilibs.
	(CVT_IBM128_TO_FLOAT128): Likewise.
	* config/rs6000/ibm-ldouble.c (IBM128_TYPE): New macro to define
	the appropriate IBM extended double type.
	(__gcc_qadd): Change all occurances of long double to IBM128_TYPE.
	(__gcc_qsub): Likewise.
	(__gcc_qmul): Likewise.
	(__gcc_qdiv): Likewise.
	(pack_ldouble): Likewise.
	(__gcc_qneg): Likewise.
	(__gcc_qeq): Likewise.
	(__gcc_qne): Likewise.
	(__gcc_qge): Likewise.
	(__gcc_qle): Likewise.
	(__gcc_stoq): Likewise.
	(__gcc_dtoq): Likewise.
	(__gcc_itoq): Likewise.
	(__gcc_utoq): Likewise.
	(__gcc_qunord): Likewise.
	* config/rs6000/_mulkc3.c (toplevel): Include soft-fp.h and
	quad-float128.h for the definitions.
	(COPYSIGN): Use the f128 version instead of the q version.
	(INFINITY): Likewise.
	(__mulkc3): Use TFmode/TCmode for float128 scalar/complex types.
	* config/rs6000/_divkc3.c (toplevel): Include soft-fp.h and
	quad-float128.h for the definitions.
	(COPYSIGN): Use the f128 version instead of the q version.
	(INFINITY): Likewise.
	(FABS): Likewise.
	(__divkc3): Use TFmode/TCmode for float128 scalar/complex types.
	* config/rs6000/extendkftf2-sw.c (__extendkftf2_sw): Likewise.
	* config/rs6000/trunctfkf2-sw.c (__trunctfkf2_sw): Likewise.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.vnet.ibm.com, phone: +1 (978) 899-4797

Attachment: ieee128-patch73b
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]