[PATCH] rs6000: float128 on BE and 32-bit
This fixes float128 on BE and on 32-bit. The configure tests need to use -mabi=altivec for 32-bit, since it is not the default there. That also enables the "vector" keyword, used by the tests. To do this it temporarily adds a few flags to the CFLAGS variable. It also fixes a syntax error in the libgcc_cv_powerpc_float128_hw test (the function name was missing in the function declaration). Regenerating config.in (via autoreconf) removed the duplicate definition of HAVE_SOLARIS_CRTS. Finally, this adds a "-mfloat128-hardware requires -m64" test to rs6000.c: all the current patterns need 64-bit registers. Maybe we'll want to add float128 hardware support to 32-bit some day, but certainly not today. Tested on powerpc64-linux {-m32,-m64}, powerpc64le-linux, and powerpc-linux-paired. Committing to trunk. Segher 2017-03-10 Segher Boessenkool* config/rs6000/rs6000.c (rs6000_option_override_internal): Disallow -mfloat128-hardware without -m64. libgcc/ * configure.ac (test for libgcc_cv_powerpc_float128): Temporarily modify CFLAGS. Add -mabi=altivec -mvsx -mfloat128. (test for libgcc_cv_powerpc_float128_hw): Add -mpower9-vector and -mfloat128-hardware to the CFLAGS. Fix syntax error in the C snippet. * configure: Regenerate. * config.in: Regenerate. --- gcc/config/rs6000/rs6000.c | 8 libgcc/config.in | 3 --- libgcc/configure | 12 +++- libgcc/configure.ac| 12 +++- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index aa7c8c3..9aa0d58 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -4687,6 +4687,14 @@ rs6000_option_override_internal (bool global_init_p) rs6000_isa_flags &= ~OPTION_MASK_FLOAT128_HW; } + if (TARGET_FLOAT128_HW && !TARGET_64BIT) +{ + if ((rs6000_isa_flags_explicit & OPTION_MASK_FLOAT128_HW) != 0) + error ("-mfloat128-hardware requires -m64"); + + rs6000_isa_flags &= ~OPTION_MASK_FLOAT128_HW; +} + if (TARGET_FLOAT128_HW && !TARGET_FLOAT128_KEYWORD && (rs6000_isa_flags_explicit & OPTION_MASK_FLOAT128_HW) != 0 && (rs6000_isa_flags_explicit & OPTION_MASK_FLOAT128_KEYWORD) == 0) diff --git a/libgcc/config.in b/libgcc/config.in index 4d33411..25aa0d9 100644 --- a/libgcc/config.in +++ b/libgcc/config.in @@ -21,9 +21,6 @@ /* Define if the system-provided CRTs are present on Solaris. */ #undef HAVE_SOLARIS_CRTS -/* Define if the system-provided CRTs are present on Solaris. */ -#undef HAVE_SOLARIS_CRTS - /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H diff --git a/libgcc/configure b/libgcc/configure index 5c900cc..45c4597 100644 --- a/libgcc/configure +++ b/libgcc/configure @@ -4779,6 +4779,8 @@ case ${host} in # software libraries, and whether the assembler can handle xsaddqp # for hardware support. powerpc*-*-linux*) + saved_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -mabi=altivec -mvsx -mfloat128" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PowerPC ISA 2.06 to build __float128 libraries" >&5 $as_echo_n "checking for PowerPC ISA 2.06 to build __float128 libraries... " >&6; } if test "${libgcc_cv_powerpc_float128+set}" = set; then : @@ -4786,8 +4788,7 @@ if test "${libgcc_cv_powerpc_float128+set}" = set; then : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#pragma GCC target ("vsx") - vector double dadd (vector double a, vector double b) { return a + b; } +vector double dadd (vector double a, vector double b) { return a + b; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : libgcc_cv_powerpc_float128=yes @@ -4799,6 +4800,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_powerpc_float128" >&5 $as_echo "$libgcc_cv_powerpc_float128" >&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; } if test "${libgcc_cv_powerpc_float128_hw+set}" = set; then : @@ -4806,12 +4808,11 @@ if test "${libgcc_cv_powerpc_float128_hw+set}" = set; then : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#pragma GCC target ("vsx,power9-vector") - #include +#include #ifndef AT_PLATFORM #error "AT_PLATFORM is not defined" #endif - vector unsigned char (vector unsigned char a, vector unsigned char b) + vector unsigned char add (vector unsigned char a, vector unsigned char b) { vector unsigned char ret; __asm__ ("xsaddqp %0,%1,%2" : "=v" (ret) : "v" (a), "v" (b)); @@ -4830,6 +4831,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result:
Re: [PATCH] rs6000: float128 on BE and 32-bit
On Mon, Feb 13, 2017 at 10:20:48PM +, Segher Boessenkool wrote: > This fixes float128 on BE and on 32-bit. > > The configure tests need to use -mabi=altivec for 32-bit, since it is > not the default there. That also enables the "vector" keyword, used by > the tests. To do this it temporarily adds a few flags to the CFLAGS > variable. > > It also fixes a syntax error in the libgcc_cv_powerpc_float128_hw test > (the function name was missing in the function declaration). > > Regenerating config.in (via autoreconf) removed the duplicate definition > of HAVE_SOLARIS_CRTS. > > Finally, this adds a "-mfloat128-hardware requires -m64" test to > rs6000.c: all the current patterns need 64-bit registers. Maybe we'll > want to add float128 hardware support to 32-bit some day, but certainly > not today. > > Tested on powerpc64-linux {-m32,-m64} so far. I see I also need to > update some code comments, ugh. This patch fixes problems with float128. Thanks for doing it. I verified that float128-hw.o is now built, and when I compile code with -mcpu=power8 and run it on the power9 simulator it correctly switches __{add,sub,mul,div}kf3 to use the hardware instructions. Yeah, if there is a demand for -mfloat128-hardware -m32, we could do it, but for now I think it is best to require 64-bit. -- Michael Meissner, IBM IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797
[PATCH] rs6000: float128 on BE and 32-bit
This fixes float128 on BE and on 32-bit. The configure tests need to use -mabi=altivec for 32-bit, since it is not the default there. That also enables the "vector" keyword, used by the tests. To do this it temporarily adds a few flags to the CFLAGS variable. It also fixes a syntax error in the libgcc_cv_powerpc_float128_hw test (the function name was missing in the function declaration). Regenerating config.in (via autoreconf) removed the duplicate definition of HAVE_SOLARIS_CRTS. Finally, this adds a "-mfloat128-hardware requires -m64" test to rs6000.c: all the current patterns need 64-bit registers. Maybe we'll want to add float128 hardware support to 32-bit some day, but certainly not today. Tested on powerpc64-linux {-m32,-m64} so far. I see I also need to update some code comments, ugh. Segher 2017-02-13 Segher Boessenkool* config/rs6000/rs6000.c (rs6000_option_override_internal): Disallow -mfloat128-hardware without -m64. libgcc/ * configure.ac (test for libgcc_cv_powerpc_float128): Temporarily modify CFLAGS. Add -mabi=altivec. (test for libgcc_cv_powerpc_float128_hw): Add -mpower9-vector and -mfloat128-hardware to the CFLAGS. Fix syntax error in the C snippet. * configure: Regenerate. * config.in: Regenerate. --- gcc/config/rs6000/rs6000.c | 8 libgcc/config.in | 3 --- libgcc/configure | 12 +++- libgcc/configure.ac| 12 +++- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 11f11f0..8ca42fd 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -4686,6 +4686,14 @@ rs6000_option_override_internal (bool global_init_p) rs6000_isa_flags &= ~OPTION_MASK_FLOAT128_HW; } + if (TARGET_FLOAT128_HW && !TARGET_64BIT) +{ + if ((rs6000_isa_flags_explicit & OPTION_MASK_FLOAT128_HW) != 0) + error ("-mfloat128-hardware requires -m64"); + + rs6000_isa_flags &= ~OPTION_MASK_FLOAT128_HW; +} + if (TARGET_FLOAT128_HW && !TARGET_FLOAT128_KEYWORD && (rs6000_isa_flags_explicit & OPTION_MASK_FLOAT128_HW) != 0 && (rs6000_isa_flags_explicit & OPTION_MASK_FLOAT128_KEYWORD) == 0) diff --git a/libgcc/config.in b/libgcc/config.in index 4d33411..25aa0d9 100644 --- a/libgcc/config.in +++ b/libgcc/config.in @@ -21,9 +21,6 @@ /* Define if the system-provided CRTs are present on Solaris. */ #undef HAVE_SOLARIS_CRTS -/* Define if the system-provided CRTs are present on Solaris. */ -#undef HAVE_SOLARIS_CRTS - /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H diff --git a/libgcc/configure b/libgcc/configure index 5c900cc..7ef84bc 100644 --- a/libgcc/configure +++ b/libgcc/configure @@ -4779,6 +4779,8 @@ case ${host} in # software libraries, and whether the assembler can handle xsaddqp # for hardware support. powerpc*-*-linux*) + saved_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -mabi=altivec -mvsx" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PowerPC ISA 2.06 to build __float128 libraries" >&5 $as_echo_n "checking for PowerPC ISA 2.06 to build __float128 libraries... " >&6; } if test "${libgcc_cv_powerpc_float128+set}" = set; then : @@ -4786,8 +4788,7 @@ if test "${libgcc_cv_powerpc_float128+set}" = set; then : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#pragma GCC target ("vsx") - vector double dadd (vector double a, vector double b) { return a + b; } +vector double dadd (vector double a, vector double b) { return a + b; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : libgcc_cv_powerpc_float128=yes @@ -4799,6 +4800,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_powerpc_float128" >&5 $as_echo "$libgcc_cv_powerpc_float128" >&6; } + CFLAGS="$CFLAGS -mpower9-vector -mfloat128 -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; } if test "${libgcc_cv_powerpc_float128_hw+set}" = set; then : @@ -4806,12 +4808,11 @@ if test "${libgcc_cv_powerpc_float128_hw+set}" = set; then : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#pragma GCC target ("vsx,power9-vector") - #include +#include #ifndef AT_PLATFORM #error "AT_PLATFORM is not defined" #endif - vector unsigned char (vector unsigned char a, vector unsigned char b) + vector unsigned char add (vector unsigned char a, vector unsigned char b) { vector unsigned char ret; __asm__ ("xsaddqp %0,%1,%2" : "=v" (ret) : "v" (a), "v" (b)); @@ -4830,6 +4831,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_powerpc_float128_hw" >&5