diff options
Diffstat (limited to 'math/tgmath.h')
-rw-r--r-- | math/tgmath.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/math/tgmath.h b/math/tgmath.h index 5f19cf4..5fdc798 100644 --- a/math/tgmath.h +++ b/math/tgmath.h @@ -57,15 +57,21 @@ (F ## l (X)) # define __TGMATH_2_NARROW_D(F, X, Y) \ (F ## l (X, Y)) +# define __TGMATH_3_NARROW_D(F, X, Y, Z) \ + (F ## l (X, Y, Z)) # define __TGMATH_1_NARROW_F64X(F, X) \ (F ## f128 (X)) # define __TGMATH_2_NARROW_F64X(F, X, Y) \ (F ## f128 (X, Y)) +# define __TGMATH_3_NARROW_F64X(F, X, Y, Z) \ + (F ## f128 (X, Y, Z)) # if !__HAVE_FLOAT128 # define __TGMATH_1_NARROW_F32X(F, X) \ (F ## f64 (X)) # define __TGMATH_2_NARROW_F32X(F, X, Y) \ (F ## f64 (X, Y)) +# define __TGMATH_3_NARROW_F32X(F, X, Y, Z) \ + (F ## f64 (X, Y, Z)) # endif # if __HAVE_BUILTIN_TGMATH @@ -137,23 +143,33 @@ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F (F) (X)) # define __TGMATH_2_NARROW_F(F, X, Y) \ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F (F) (X), (Y)) +# define __TGMATH_3_NARROW_F(F, X, Y, Z) \ + __builtin_tgmath (__TGMATH_NARROW_FUNCS_F (F) (X), (Y), (Z)) # define __TGMATH_1_NARROW_F16(F, X) \ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F16 (F) (X)) # define __TGMATH_2_NARROW_F16(F, X, Y) \ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F16 (F) (X), (Y)) +# define __TGMATH_3_NARROW_F16(F, X, Y, Z) \ + __builtin_tgmath (__TGMATH_NARROW_FUNCS_F16 (F) (X), (Y), (Z)) # define __TGMATH_1_NARROW_F32(F, X) \ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F32 (F) (X)) # define __TGMATH_2_NARROW_F32(F, X, Y) \ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F32 (F) (X), (Y)) +# define __TGMATH_3_NARROW_F32(F, X, Y, Z) \ + __builtin_tgmath (__TGMATH_NARROW_FUNCS_F32 (F) (X), (Y), (Z)) # define __TGMATH_1_NARROW_F64(F, X) \ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F64 (F) (X)) # define __TGMATH_2_NARROW_F64(F, X, Y) \ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F64 (F) (X), (Y)) +# define __TGMATH_3_NARROW_F64(F, X, Y, Z) \ + __builtin_tgmath (__TGMATH_NARROW_FUNCS_F64 (F) (X), (Y), (Z)) # if __HAVE_FLOAT128 # define __TGMATH_1_NARROW_F32X(F, X) \ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F32X (F) (X)) # define __TGMATH_2_NARROW_F32X(F, X, Y) \ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F32X (F) (X), (Y)) +# define __TGMATH_3_NARROW_F32X(F, X, Y, Z) \ + __builtin_tgmath (__TGMATH_NARROW_FUNCS_F32X (F) (X), (Y), (Z)) # endif # else /* !__HAVE_BUILTIN_TGMATH. */ @@ -565,6 +581,12 @@ + (__tgmath_real_type (Y)) 0) > sizeof (double) \ ? F ## l (X, Y) \ : F (X, Y))) +# define __TGMATH_3_NARROW_F(F, X, Y, Z) \ + (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ + + (__tgmath_real_type (Y)) 0 \ + + (__tgmath_real_type (Z)) 0) > sizeof (double) \ + ? F ## l (X, Y, Z) \ + : F (X, Y, Z))) /* In most cases, these narrowing macro definitions based on sizeof ensure that the function called has the right argument format, as for other <tgmath.h> macros for compilers before GCC 8, but may not @@ -594,6 +616,13 @@ ? __TGMATH_F128 ((X) + (Y), F, (X, Y)) \ F ## f64x (X, Y) \ : F ## f64 (X, Y))) +# define __TGMATH_3_NARROW_F32(F, X, Y, Z) \ + (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ + + (__tgmath_real_type (Y)) 0 \ + + (__tgmath_real_type (Z)) 0) > sizeof (_Float64) \ + ? __TGMATH_F128 ((X) + (Y) + (Z), F, (X, Y, Z)) \ + F ## f64x (X, Y, Z) \ + : F ## f64 (X, Y, Z))) # define __TGMATH_1_NARROW_F64(F, X) \ (__extension__ (sizeof ((__tgmath_real_type (X)) 0) > sizeof (_Float64) \ ? __TGMATH_F128 ((X), F, (X)) \ @@ -605,6 +634,13 @@ ? __TGMATH_F128 ((X) + (Y), F, (X, Y)) \ F ## f64x (X, Y) \ : F ## f128 (X, Y))) +# define __TGMATH_3_NARROW_F64(F, X, Y, Z) \ + (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ + + (__tgmath_real_type (Y)) 0 \ + + (__tgmath_real_type (Z)) 0) > sizeof (_Float64) \ + ? __TGMATH_F128 ((X) + (Y) + (Z), F, (X, Y, Z)) \ + F ## f64x (X, Y, Z) \ + : F ## f128 (X, Y, Z))) # define __TGMATH_1_NARROW_F32X(F, X) \ (__extension__ (sizeof ((__tgmath_real_type (X)) 0) > sizeof (_Float64) \ ? __TGMATH_F128 ((X), F, (X)) \ @@ -616,6 +652,13 @@ ? __TGMATH_F128 ((X) + (Y), F, (X, Y)) \ F ## f64x (X, Y) \ : F ## f64 (X, Y))) +# define __TGMATH_3_NARROW_F32X(F, X, Y, Z) \ + (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ + + (__tgmath_real_type (Y)) 0 \ + + (__tgmath_real_type (Z)) 0) > sizeof (_Float64) \ + ? __TGMATH_F128 ((X) + (Y) + (Z), F, (X, Y, Z)) \ + F ## f64x (X, Y, Z) \ + : F ## f64 (X, Y, Z))) # elif __HAVE_FLOAT128 # define __TGMATH_1_NARROW_F32(F, X) \ (__extension__ (sizeof ((__tgmath_real_type (X)) 0) > sizeof (_Float64) \ @@ -626,10 +669,18 @@ + (__tgmath_real_type (Y)) 0) > sizeof (_Float64) \ ? F ## f128 (X, Y) \ : F ## f64 (X, Y))) +# define __TGMATH_3_NARROW_F32(F, X, Y, Z) \ + (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ + + (__tgmath_real_type (Y)) 0 \ + + (__tgmath_real_type (Z)) 0) > sizeof (_Float64) \ + ? F ## f128 (X, Y, Z) \ + : F ## f64 (X, Y, Z))) # define __TGMATH_1_NARROW_F64(F, X) \ (F ## f128 (X)) # define __TGMATH_2_NARROW_F64(F, X, Y) \ (F ## f128 (X, Y)) +# define __TGMATH_3_NARROW_F64(F, X, Y, Z) \ + (F ## f128 (X, Y, Z)) # define __TGMATH_1_NARROW_F32X(F, X) \ (__extension__ (sizeof ((__tgmath_real_type (X)) 0) > sizeof (_Float32x) \ ? F ## f64x (X) \ @@ -639,11 +690,19 @@ + (__tgmath_real_type (Y)) 0) > sizeof (_Float32x) \ ? F ## f64x (X, Y) \ : F ## f64 (X, Y))) +# define __TGMATH_3_NARROW_F32X(F, X, Y, Z) \ + (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ + + (__tgmath_real_type (Y)) 0 \ + + (__tgmath_real_type (Z)) 0) > sizeof (_Float32x) \ + ? F ## f64x (X, Y, Z) \ + : F ## f64 (X, Y, Z))) # else # define __TGMATH_1_NARROW_F32(F, X) \ (F ## f64 (X)) # define __TGMATH_2_NARROW_F32(F, X, Y) \ (F ## f64 (X, Y)) +# define __TGMATH_3_NARROW_F32(F, X, Y, Z) \ + (F ## f64 (X, Y, Z)) # endif # endif /* !__HAVE_BUILTIN_TGMATH. */ #else @@ -916,6 +975,10 @@ # define fsqrt(Val) __TGMATH_1_NARROW_F (fsqrt, Val) # define dsqrt(Val) __TGMATH_1_NARROW_D (dsqrt, Val) +/* Fused multiply-add. */ +# define ffma(Val1, Val2, Val3) __TGMATH_3_NARROW_F (ffma, Val1, Val2, Val3) +# define dfma(Val1, Val2, Val3) __TGMATH_3_NARROW_D (dfma, Val1, Val2, Val3) + #endif #if __GLIBC_USE (IEC_60559_TYPES_EXT) @@ -926,6 +989,8 @@ # define f16mul(Val1, Val2) __TGMATH_2_NARROW_F16 (f16mul, Val1, Val2) # define f16sub(Val1, Val2) __TGMATH_2_NARROW_F16 (f16sub, Val1, Val2) # define f16sqrt(Val) __TGMATH_1_NARROW_F16 (f16sqrt, Val) +# define f16fma(Val1, Val2, Val3) \ + __TGMATH_3_NARROW_F16 (f16fma, Val1, Val2, Val3) # endif # if __HAVE_FLOAT32 @@ -934,6 +999,8 @@ # define f32mul(Val1, Val2) __TGMATH_2_NARROW_F32 (f32mul, Val1, Val2) # define f32sub(Val1, Val2) __TGMATH_2_NARROW_F32 (f32sub, Val1, Val2) # define f32sqrt(Val) __TGMATH_1_NARROW_F32 (f32sqrt, Val) +# define f32fma(Val1, Val2, Val3) \ + __TGMATH_3_NARROW_F32 (f32fma, Val1, Val2, Val3) # endif # if __HAVE_FLOAT64 && (__HAVE_FLOAT64X || __HAVE_FLOAT128) @@ -942,6 +1009,8 @@ # define f64mul(Val1, Val2) __TGMATH_2_NARROW_F64 (f64mul, Val1, Val2) # define f64sub(Val1, Val2) __TGMATH_2_NARROW_F64 (f64sub, Val1, Val2) # define f64sqrt(Val) __TGMATH_1_NARROW_F64 (f64sqrt, Val) +# define f64fma(Val1, Val2, Val3) \ + __TGMATH_3_NARROW_F64 (f64fma, Val1, Val2, Val3) # endif # if __HAVE_FLOAT32X @@ -950,6 +1019,8 @@ # define f32xmul(Val1, Val2) __TGMATH_2_NARROW_F32X (f32xmul, Val1, Val2) # define f32xsub(Val1, Val2) __TGMATH_2_NARROW_F32X (f32xsub, Val1, Val2) # define f32xsqrt(Val) __TGMATH_1_NARROW_F32X (f32xsqrt, Val) +# define f32xfma(Val1, Val2, Val3) \ + __TGMATH_3_NARROW_F32X (f32xfma, Val1, Val2, Val3) # endif # if __HAVE_FLOAT64X && (__HAVE_FLOAT128X || __HAVE_FLOAT128) @@ -958,6 +1029,8 @@ # define f64xmul(Val1, Val2) __TGMATH_2_NARROW_F64X (f64xmul, Val1, Val2) # define f64xsub(Val1, Val2) __TGMATH_2_NARROW_F64X (f64xsub, Val1, Val2) # define f64xsqrt(Val) __TGMATH_1_NARROW_F64X (f64xsqrt, Val) +# define f64xfma(Val1, Val2, Val3) \ + __TGMATH_3_NARROW_F64X (f64xfma, Val1, Val2, Val3) # endif #endif |