diff options
author | Michael Meissner <meissner@linux.vnet.ibm.com> | 2017-10-27 18:15:38 +0000 |
---|---|---|
committer | Michael Meissner <meissner@gcc.gnu.org> | 2017-10-27 18:15:38 +0000 |
commit | ee5fd23a481f510528e00f4c988ed0e6a71218c2 (patch) | |
tree | b4520775062aec903a9f6e5ee44e864f4afa4b97 /gcc/builtins.c | |
parent | 3f563e0b55c78c53130d4082da6ba670ec1d9ba5 (diff) | |
download | gcc-ee5fd23a481f510528e00f4c988ed0e6a71218c2.zip gcc-ee5fd23a481f510528e00f4c988ed0e6a71218c2.tar.gz gcc-ee5fd23a481f510528e00f4c988ed0e6a71218c2.tar.bz2 |
builtins.c (CASE_MATHFN_FLOATN): New helper macro to add cases for math functions that have _Float<N> and...
[gcc]
2017-10-27 Michael Meissner <meissner@linux.vnet.ibm.com>
* builtins.c (CASE_MATHFN_FLOATN): New helper macro to add cases
for math functions that have _Float<N> and _Float<N>X variants.
(mathfn_built_in_2): Add support for math functions that have
_Float<N> and _Float<N>X variants.
(DEF_INTERNAL_FLT_FLOATN_FN): New helper macro.
(expand_builtin_mathfn_ternary): Add support for fma with
_Float<N> and _Float<N>X variants.
(expand_builtin): Likewise.
(fold_builtin_3): Likewise.
* builtins.def (DEF_EXT_LIB_FLOATN_NX_BUILTINS): New macro to
create math function _Float<N> and _Float<N>X variants as external
library builtins.
(BUILT_IN_COPYSIGN _Float<N> and _Float<N>X variants) Use
DEF_EXT_LIB_FLOATN_NX_BUILTINS to make built-in functions using
the __builtin_ prefix and if not strict ansi, without the prefix.
(BUILT_IN_FABS _Float<N> and _Float<N>X variants): Likewise.
(BUILT_IN_FMA _Float<N> and _Float<N>X variants): Likewise.
(BUILT_IN_FMAX _Float<N> and _Float<N>X variants): Likewise.
(BUILT_IN_FMIN _Float<N> and _Float<N>X variants): Likewise.
(BUILT_IN_NAN _Float<N> and _Float<N>X variants): Likewise.
(BUILT_IN_SQRT _Float<N> and _Float<N>X variants): Likewise.
* builtin-types.def (BT_FN_FLOAT16_FLOAT16_FLOAT16_FLOAT16): New
function signatures for fma _Float<N> and _Float<N>X variants.
(BT_FN_FLOAT32_FLOAT32_FLOAT32_FLOAT32): Likewise.
(BT_FN_FLOAT64_FLOAT64_FLOAT64_FLOAT64): Likewise.
(BT_FN_FLOAT128_FLOAT128_FLOAT128_FLOAT128): Likewise.
(BT_FN_FLOAT32X_FLOAT32X_FLOAT32X_FLOAT32X): Likewise.
(BT_FN_FLOAT64X_FLOAT64X_FLOAT64X_FLOAT64X): Likewise.
(BT_FN_FLOAT128X_FLOAT128X_FLOAT128X_FLOAT128X): Likewise.
* gencfn-macros.c (print_case_cfn): Add support for math functions
that have _Float<N> and _Float<N>X variants.
(print_define_operator_list): Likewise.
(fltfn_suffixes): Likewise.
(main): Likewise.
* internal-fn.def (DEF_INTERNAL_FLT_FLOATN_FN): New helper macro
for math functions that have _Float<N> and _Float<N>X variants.
(SQRT): Add support for sqrt, copysign, fmin and fmax _Float<N>
and _Float<N>X variants.
(COPYSIGN): Likewise.
(FMIN): Likewise.
(FMAX): Likewise.
* fold-const.c (tree_call_nonnegative_warnv_p): Add support for
copysign, fma, fmax, fmin, and sqrt _Float<N> and _Float<N>X
variants.
(integer_valued_read_call_p): Likewise.
* fold-const-call.c (fold_const_call_ss): Likewise.
(fold_const_call_sss): Add support for copysign, fmin, and fmax
_Float<N> and _Float<N>X variants.
(fold_const_call_ssss): Add support for fma _Float<N> and
_Float<N>X variants.
* gimple-ssa-backprop.c (backprop::process_builtin_call_use): Add
support for copysign and fma _Float<N> and _Float<N>X variants.
(backprop::process_builtin_call_use): Likewise.
* tree-call-cdce.c (can_test_argument_range); Add support for
sqrt _Float<N> and _Float<N>X variants.
(edom_only_function): Likewise.
(get_no_error_domain): Likewise.
* tree-ssa-math-opts.c (internal_fn_reciprocal): Likewise.
* tree-ssa-reassoc.c (attempt_builtin_copysign): Add support for
copysign _Float<N> and _Float<N>X variants.
* config/rs6000/rs6000-builtin.def (SQRTF128): Delete, this is now
handled by machine independent code.
(FMAF128): Likewise.
* doc/cpp.texi (Common Predefined Macros): Document defining
__FP_FAST_FMAF<N> and __FP_FAST_FMAF<N>X if the backend supports
fma _Float<N> and _Float<N>X variants.
[gcc/c]
2017-10-27 Michael Meissner <meissner@linux.vnet.ibm.com>
* c-decl.c (header_for_builtin_fn): Add support for copysign, fma,
fmax, fmin, and sqrt _Float<N> and _Float<N>X variants.
[gcc/c-family]
2017-10-27 Michael Meissner <meissner@linux.vnet.ibm.com>
* c-cppbuiltin.c (mode_has_fma): Add support for PowerPC KFmode.
(c_cpp_builtins): If a machine has a fast fma _Float<N> and
_Float<N>X variant, define __FP_FAST_FMA<N> and/or
__FP_FAST_FMA<N>X.
[gcc/testsuite]
2017-10-27 Michael Meissner <meissner@linux.vnet.ibm.com>
* gcc.target/powerpc/float128-hw.c: Add support for all 4 FMA
variants. Check various conversions to/from float128. Check
negation. Use {\m...\M} in the tests.
* gcc.target/powerpc/float128-hw2.c: New test for implicit
_Float128 math functions.
* gcc.target/powerpc/float128-hw3.c: New test for strict ansi mode
not implicitly adding the _Float128 math functions.
* gcc.target/powerpc/float128-fma2.c: Delete, test is no longer
valid.
* gcc.target/powerpc/float128-sqrt2.c: Likewise.
From-SVN: r254168
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 65 |
1 files changed, 53 insertions, 12 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 29778fc..a677705 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -1816,14 +1816,26 @@ expand_builtin_classify_type (tree exp) return GEN_INT (no_type_class); } -/* This helper macro, meant to be used in mathfn_built_in below, - determines which among a set of three builtin math functions is - appropriate for a given type mode. The `F' and `L' cases are - automatically generated from the `double' case. */ +/* This helper macro, meant to be used in mathfn_built_in below, determines + which among a set of builtin math functions is appropriate for a given type + mode. The `F' (float) and `L' (long double) are automatically generated + from the 'double' case. If a function supports the _Float<N> and _Float<N>X + types, there are additional types that are considered with 'F32', 'F64', + 'F128', etc. suffixes. */ #define CASE_MATHFN(MATHFN) \ CASE_CFN_##MATHFN: \ fcode = BUILT_IN_##MATHFN; fcodef = BUILT_IN_##MATHFN##F ; \ fcodel = BUILT_IN_##MATHFN##L ; break; +/* Similar to the above, but also add support for the _Float<N> and _Float<N>X + types. */ +#define CASE_MATHFN_FLOATN(MATHFN) \ + CASE_CFN_##MATHFN: \ + fcode = BUILT_IN_##MATHFN; fcodef = BUILT_IN_##MATHFN##F ; \ + fcodel = BUILT_IN_##MATHFN##L ; fcodef16 = BUILT_IN_##MATHFN##F16 ; \ + fcodef32 = BUILT_IN_##MATHFN##F32; fcodef64 = BUILT_IN_##MATHFN##F64 ; \ + fcodef128 = BUILT_IN_##MATHFN##F128 ; fcodef32x = BUILT_IN_##MATHFN##F32X ; \ + fcodef64x = BUILT_IN_##MATHFN##F64X ; fcodef128x = BUILT_IN_##MATHFN##F128X ;\ + break; /* Similar to above, but appends _R after any F/L suffix. */ #define CASE_MATHFN_REENT(MATHFN) \ case CFN_BUILT_IN_##MATHFN##_R: \ @@ -1840,7 +1852,15 @@ expand_builtin_classify_type (tree exp) static built_in_function mathfn_built_in_2 (tree type, combined_fn fn) { + tree mtype; built_in_function fcode, fcodef, fcodel; + built_in_function fcodef16 = END_BUILTINS; + built_in_function fcodef32 = END_BUILTINS; + built_in_function fcodef64 = END_BUILTINS; + built_in_function fcodef128 = END_BUILTINS; + built_in_function fcodef32x = END_BUILTINS; + built_in_function fcodef64x = END_BUILTINS; + built_in_function fcodef128x = END_BUILTINS; switch (fn) { @@ -1854,7 +1874,7 @@ mathfn_built_in_2 (tree type, combined_fn fn) CASE_MATHFN (CBRT) CASE_MATHFN (CEIL) CASE_MATHFN (CEXPI) - CASE_MATHFN (COPYSIGN) + CASE_MATHFN_FLOATN (COPYSIGN) CASE_MATHFN (COS) CASE_MATHFN (COSH) CASE_MATHFN (DREM) @@ -1867,9 +1887,9 @@ mathfn_built_in_2 (tree type, combined_fn fn) CASE_MATHFN (FABS) CASE_MATHFN (FDIM) CASE_MATHFN (FLOOR) - CASE_MATHFN (FMA) - CASE_MATHFN (FMAX) - CASE_MATHFN (FMIN) + CASE_MATHFN_FLOATN (FMA) + CASE_MATHFN_FLOATN (FMAX) + CASE_MATHFN_FLOATN (FMIN) CASE_MATHFN (FMOD) CASE_MATHFN (FREXP) CASE_MATHFN (GAMMA) @@ -1923,7 +1943,7 @@ mathfn_built_in_2 (tree type, combined_fn fn) CASE_MATHFN (SIN) CASE_MATHFN (SINCOS) CASE_MATHFN (SINH) - CASE_MATHFN (SQRT) + CASE_MATHFN_FLOATN (SQRT) CASE_MATHFN (TAN) CASE_MATHFN (TANH) CASE_MATHFN (TGAMMA) @@ -1936,12 +1956,27 @@ mathfn_built_in_2 (tree type, combined_fn fn) return END_BUILTINS; } - if (TYPE_MAIN_VARIANT (type) == double_type_node) + mtype = TYPE_MAIN_VARIANT (type); + if (mtype == double_type_node) return fcode; - else if (TYPE_MAIN_VARIANT (type) == float_type_node) + else if (mtype == float_type_node) return fcodef; - else if (TYPE_MAIN_VARIANT (type) == long_double_type_node) + else if (mtype == long_double_type_node) return fcodel; + else if (mtype == float16_type_node) + return fcodef16; + else if (mtype == float32_type_node) + return fcodef32; + else if (mtype == float64_type_node) + return fcodef64; + else if (mtype == float128_type_node) + return fcodef128; + else if (mtype == float32x_type_node) + return fcodef32x; + else if (mtype == float64x_type_node) + return fcodef64x; + else if (mtype == float128x_type_node) + return fcodef128x; else return END_BUILTINS; } @@ -1995,6 +2030,9 @@ associated_internal_fn (tree fndecl) { #define DEF_INTERNAL_FLT_FN(NAME, FLAGS, OPTAB, TYPE) \ CASE_FLT_FN (BUILT_IN_##NAME): return IFN_##NAME; +#define DEF_INTERNAL_FLT_FLOATN_FN(NAME, FLAGS, OPTAB, TYPE) \ + CASE_FLT_FN (BUILT_IN_##NAME): return IFN_##NAME; \ + CASE_FLT_FN_FLOATN_NX (BUILT_IN_##NAME): return IFN_##NAME; #define DEF_INTERNAL_INT_FN(NAME, FLAGS, OPTAB, TYPE) \ CASE_INT_FN (BUILT_IN_##NAME): return IFN_##NAME; #include "internal-fn.def" @@ -2068,6 +2106,7 @@ expand_builtin_mathfn_ternary (tree exp, rtx target, rtx subtarget) switch (DECL_FUNCTION_CODE (fndecl)) { CASE_FLT_FN (BUILT_IN_FMA): + CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMA): builtin_optab = fma_optab; break; default: gcc_unreachable (); @@ -6567,6 +6606,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode, break; CASE_FLT_FN (BUILT_IN_FMA): + CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMA): target = expand_builtin_mathfn_ternary (exp, target, subtarget); if (target) return target; @@ -8996,6 +9036,7 @@ fold_builtin_3 (location_t loc, tree fndecl, return fold_builtin_sincos (loc, arg0, arg1, arg2); CASE_FLT_FN (BUILT_IN_FMA): + CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMA): return fold_builtin_fma (loc, arg0, arg1, arg2, type); CASE_FLT_FN (BUILT_IN_REMQUO): |