Use __builtin_tgmath in tgmath.h with GCC 8 (bug 21660).
commitbe3a79a3cc8d8111811a52b0fe243b6f4dd03844
authorJoseph Myers <joseph@codesourcery.com>
Wed, 15 Nov 2017 02:08:56 +0000 (15 02:08 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 15 Nov 2017 02:08:56 +0000 (15 02:08 +0000)
treefaad3b62a4907b2252ca4a714754f3c3833cd6b4
parent2e64ec9c9eac3aeb70f7cfa2392846c87c28068e
Use __builtin_tgmath in tgmath.h with GCC 8 (bug 21660).

GCC mainline now supports __builtin_tgmath to allow <tgmath.h> macro
implementations that expand their arguments only once, so avoiding
exponential blowup in the size of macro expansions when calls to those
macros are nested in arguments to those macros.

This patch makes glibc's tgmath.h support using __builtin_tgmath, as a
much simpler and more efficient alternative to the existing
implementation.  (As a side effect, the new feature would make it much
more practical to support decimal floating point in <tgmath.h> with
new compilers; currently, libdfp does not provide a <tgmath.h>
implementation, and making decimal arguments cause integer arguments
to be considered of type _Decimal64 instead of double would have been
very problematic in the old implementation.)

Tested for x86_64 (with GCC mainline).

[BZ #21660]
* math/tgmath.h (__HAVE_BUILTIN_TGMATH): New macro.
[__HAVE_BUILTIN_TGMATH] (__TG_F16_ARG): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TG_F32_ARG): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TG_F64_ARG): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TG_F128_ARG): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TG_F32X_ARG): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TG_F64X_ARG): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TG_F128X_ARG): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_FUNCS): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_RCFUNCS): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_1): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_2): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_2STD): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_3): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_1C): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_2C): Likewise.
(__tgml): Make conditional on [!__HAVE_BUILTIN_TGMATH].
(__floating_type): Likewise.
(__real_integer_type): Likewise.
(__complex_integer_type): Likewise.
(__expr_is_real): Likewise.
(__tgmath_real_type_sub): Likewise.
(__tgmath_real_type): Likewise.
(__tgmath_complex_type_sub): Likewise.
(__tgmath_complex_type): Likewise.
(__TGMATH_F128): Likewise.
(__TGMATH_CF128): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_REAL_ONLY): Define using
new macros.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_REAL_RET_ONLY): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_FIRST_REAL_ONLY):
Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_FIRST_REAL_STD_ONLY):
Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_REAL_ONLY): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_REAL_STD_ONLY): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_REAL_RET_ONLY): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY):
Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_TERNARY_REAL_ONLY): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY):
Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_REAL_IMAG): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_IMAG): Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_REAL_IMAG_RET_REAL):
Likewise.
[__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_REAL_IMAG): Likewise.
(__TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME): New macro.
(carg): Use __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME.
(cimag): Likewise.
(creal): Likewise.
ChangeLog
math/tgmath.h