diff --git a/libgcc/config/rs6000/_divkc3.c b/libgcc/config/rs6000/_divkc3.c index 9f52428cfa0aaba1b356c14a5c8efc507b4245c8..b5f9e59627d0c3aadb9f3f67423f133a4d1906ce 100644 --- a/libgcc/config/rs6000/_divkc3.c +++ b/libgcc/config/rs6000/_divkc3.c @@ -26,9 +26,19 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "soft-fp.h" #include "quad-float128.h" +/* Use the correct built-in function based on whether TFmode is _Float128 or + long double. See quad-float128.h for more details. */ +#ifndef __LONG_DOUBLE_IEEE128__ #define COPYSIGN(x,y) __builtin_copysignf128 (x, y) #define INFINITY __builtin_inff128 () #define FABS __builtin_fabsf128 + +#else +#define COPYSIGN(x,y) __builtin_copysignl (x, y) +#define INFINITY __builtin_infl () +#define FABS __builtin_fabsl +#endif + #define isnan __builtin_isnan #define isinf __builtin_isinf #define isfinite __builtin_isfinite diff --git a/libgcc/config/rs6000/_mulkc3.c b/libgcc/config/rs6000/_mulkc3.c index 299d8d147b00a5c033cf3b1fe73da66f59ece943..a01cb0540547f22ffe368cfa5ef19590e1577734 100644 --- a/libgcc/config/rs6000/_mulkc3.c +++ b/libgcc/config/rs6000/_mulkc3.c @@ -26,8 +26,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "soft-fp.h" #include "quad-float128.h" +/* Use the correct built-in function based on whether TFmode is _Float128 or + long double. See quad-float128.h for more details. */ +#ifndef __LONG_DOUBLE_IEEE128__ #define COPYSIGN(x,y) __builtin_copysignf128 (x, y) #define INFINITY __builtin_inff128 () + +#else +#define COPYSIGN(x,y) __builtin_copysignl (x, y) +#define INFINITY __builtin_infl () +#endif + #define isnan __builtin_isnan #define isinf __builtin_isinf diff --git a/libgcc/config/rs6000/quad-float128.h b/libgcc/config/rs6000/quad-float128.h index 68bd9b97f2396456162efaf55c73af7e90cb4d85..974912326ba9aa82d89c57816e52c1a3c4202660 100644 --- a/libgcc/config/rs6000/quad-float128.h +++ b/libgcc/config/rs6000/quad-float128.h @@ -27,21 +27,37 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -/* quad.h defines the TFtype type by: - typedef float TFtype __attribute__ ((mode (TF))); +/* Override the types for IEEE 128-bit scalar and complex. We need to use the + same IEEE 128-bit type (either long double or _Float128) for both the + 128-bit scalar type and for the base type in _Complex. Otherwise, if + different types are used, there may be problems in mixing _Complex values + with the scalar value. - This define forces it to use KFmode (aka, ieee 128-bit floating point). - However, when the compiler's default is changed so that long double is IEEE - 128-bit floating point, we need to go back to using TFmode and TCmode. */ -#ifndef __LONG_DOUBLE_IEEE128__ -#define TF KF + We can't use _Compelx _float128 since GCC doesn't allow it. It only allows + _Complex for _Float128 or for long double. -/* We also need TCtype to represent complex ieee 128-bit float for - __mulkc3 and __divkc3. */ -typedef __complex float TCtype __attribute__ ((mode (KC))); + We use _Float128 when long double is IBM double-double or 64-bit, and long + double when long double uses the IEEE 128-bit type. We need to do this + because the compiler has a built-in prototype for __mulkc3 and __divkc3 + using those types. Since we are declaring these functions here, we need to + use the same type that the compiler uses (i.e. we can't just always use + _Float128). + + Even though the type _Float128 and long double (when long double uses IEEE + 128-bits) both hold IEEE 128-bit values, the front ends treat these as two + separate types. + + The extension keyword __float128 is currently problematical because it can + either be a synonym for _Float128 (when long double is IBM) or for long + double (when long double is IEEE). */ + +#ifdef __LONG_DOUBLE_IEEE128__ +#define TFtype long double +#define TCtype _Complex long double #else -typedef __complex float TCtype __attribute__ ((mode (TC))); +#define TFtype _Float128 +#define TCtype _Complex _Float128 #endif /* Force the use of the VSX instruction set. */ diff --git a/libgcc/libgcc2.h b/libgcc/libgcc2.h index 6f42db7f0beb859424221f86ebb078ff8e648a26..3ec9bbd81647514e299fec6b445e48b21c88943b 100644 --- a/libgcc/libgcc2.h +++ b/libgcc/libgcc2.h @@ -156,9 +156,13 @@ typedef float XFtype __attribute__ ((mode (XF))); typedef _Complex float XCtype __attribute__ ((mode (XC))); #endif #if LIBGCC2_HAS_TF_MODE +#ifndef TFtype typedef float TFtype __attribute__ ((mode (TF))); +#endif +#ifndef TCtype typedef _Complex float TCtype __attribute__ ((mode (TC))); #endif +#endif typedef int cmp_return_type __attribute__((mode (__libgcc_cmp_return__))); typedef int shift_count_type __attribute__((mode (__libgcc_shift_count__))); diff --git a/libgcc/soft-fp/quad.h b/libgcc/soft-fp/quad.h index 3889bb44f1fdc17fa122fc827144c8a0027ca9b7..71f87d36ba9801ac0aabc1d87cb947a413b5a9fc 100644 --- a/libgcc/soft-fp/quad.h +++ b/libgcc/soft-fp/quad.h @@ -65,7 +65,9 @@ #define _FP_HIGHBIT_DW_Q \ ((_FP_W_TYPE) 1 << (_FP_WFRACBITS_DW_Q - 1) % _FP_W_TYPE_SIZE) +#ifndef TFtype typedef float TFtype __attribute__ ((mode (TF))); +#endif #if _FP_W_TYPE_SIZE < 64