PowerPC: Adjust float128/ibm128 warnings.

This patch ccombines two patches:

1) If GLIBC is 2.32 or newer, and the language is C or C++, allow the user to
   change the long double type without having to use -Wno-psabi.

2) Adjust the warnings for intermixing __float128 and __ibm128 to accomidate
   the future change to allow long double to use the IEEE 128-bit format.

gcc/
2020-10-29  Michael Meissner  <meissner@linux.ibm.com>

	* config/rs6000/rs6000.c (rs6000_option_override_internal): Allow
	long double type to be changed for C/C++ if glibc 2.32 or newer.
	(rs6000_invalid_binary_op): Update error messages about mixing IBM
	long double and IEEE 128-bit.

gcc/testsuite/
2020-10-27  Michael Meissner  <meissner@linux.ibm.com>

	* gcc.target/powerpc/float128-mix-2.c: New test.
	* gcc.target/powerpc/float128-mix-3.c: New test.
	* gcc.target/powerpc/float128-mix.c: Update failure messages.
This commit is contained in:
Michael Meissner 2020-10-29 22:15:10 -04:00
parent dec1eb4c27
commit 228156e849
4 changed files with 55 additions and 26 deletions

View file

@ -4158,8 +4158,15 @@ rs6000_option_override_internal (bool global_init_p)
if (rs6000_ieeequad != TARGET_IEEEQUAD_DEFAULT && TARGET_LONG_DOUBLE_128)
{
/* Determine if the user can change the default long double type at
compilation time. Only C and C++ support this, and you need GLIBC
2.32 or newer. Only issue one warning. */
static bool warned_change_long_double;
if (!warned_change_long_double)
if (!warned_change_long_double
&& (!OPTION_GLIBC
|| (!lang_GNU_C () && !lang_GNU_CXX ())
|| ((TARGET_GLIBC_MAJOR * 1000) + TARGET_GLIBC_MINOR) < 2032))
{
warned_change_long_double = true;
if (TARGET_IEEEQUAD)
@ -14392,22 +14399,10 @@ rs6000_invalid_binary_op (int op ATTRIBUTE_UNUSED,
if (!TARGET_FLOAT128_CVT)
{
if ((mode1 == KFmode && mode2 == IFmode)
|| (mode1 == IFmode && mode2 == KFmode))
return N_("__float128 and __ibm128 cannot be used in the same "
"expression");
if (TARGET_IEEEQUAD
&& ((mode1 == IFmode && mode2 == TFmode)
|| (mode1 == TFmode && mode2 == IFmode)))
return N_("__ibm128 and long double cannot be used in the same "
"expression");
if (!TARGET_IEEEQUAD
&& ((mode1 == KFmode && mode2 == TFmode)
|| (mode1 == TFmode && mode2 == KFmode)))
return N_("__float128 and long double cannot be used in the same "
"expression");
if ((FLOAT128_IEEE_P (mode1) && FLOAT128_IBM_P (mode2))
|| (FLOAT128_IBM_P (mode1) && FLOAT128_IEEE_P (mode2)))
return N_("Invalid mixing of IEEE 128-bit and IBM 128-bit floating "
"point types");
}
return NULL;

View file

@ -0,0 +1,16 @@
/* { dg-require-effective-target ppc_float128_sw } */
/* { dg-options "-O2 -mvsx -Wno-psabi -mabi=ieeelongdouble -mlong-double-128" } */
/* Test to make sure that __float128 and long double do not generate errors if
long double uses the IEEE 128-bit format. */
__float128
add (__float128 a, long double b)
{
return a+b;
}
long double
sub (long double a, __float128 b)
{
return a-b;
}

View file

@ -0,0 +1,16 @@
/* { dg-require-effective-target ppc_float128_sw } */
/* { dg-options "-O2 -mvsx -Wno-psabi -mabi=ibmlongdouble -mlong-double-128" } */
/* Test to make sure that __float128 and __ibm128 cannot be combined
together. */
__float128
add (__float128 a, __ibm128 b)
{
return a+b; /* { dg-error "IEEE 128-bit and IBM 128-bit floating point" } */
}
__ibm128
sub (__ibm128 a, __float128 b)
{
return a-b; /* { dg-error "IEEE 128-bit and IBM 128-bit floating point" } */
}

View file

@ -1,15 +1,17 @@
/* { dg-do compile { target { powerpc*-*-linux* } } } */
/* { dg-require-effective-target powerpc_vsx_ok } */
/* { dg-options "-O2 -mvsx" } */
/* { dg-require-effective-target ppc_float128_sw } */
/* { dg-options "-O2 -mvsx -Wno-psabi -mabi=ibmlongdouble -mlong-double-128" } */
/* Test to make sure that __float128 and long double cannot be combined together. */
__float128 add (__float128 a, long double b)
/* Test to make sure that __float128 and long double cannot be combined
together, when long double uses the IBM extended double format, and
__float128 uses the IEEE 128-bit format. */
__float128
add (__float128 a, long double b)
{
return a+b; /* { dg-error "__float128 and long double cannot be used in the same expression" } */
return a+b; /* { dg-error "IEEE 128-bit and IBM 128-bit floating point" } */
}
__ibm128 sub (long double a, __float128 b)
long double
sub (long double a, __float128 b)
{
return a-b; /* { dg-error "__float128 and long double cannot be used in the same expression" } */
return a-b; /* { dg-error "IEEE 128-bit and IBM 128-bit floating point" } */
}