aboutsummaryrefslogtreecommitdiff
path: root/gcc/gencfn-macros.c
diff options
context:
space:
mode:
authorMichael Meissner <meissner@linux.vnet.ibm.com>2017-10-27 18:15:38 +0000
committerMichael Meissner <meissner@gcc.gnu.org>2017-10-27 18:15:38 +0000
commitee5fd23a481f510528e00f4c988ed0e6a71218c2 (patch)
treeb4520775062aec903a9f6e5ee44e864f4afa4b97 /gcc/gencfn-macros.c
parent3f563e0b55c78c53130d4082da6ba670ec1d9ba5 (diff)
downloadgcc-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/gencfn-macros.c')
-rw-r--r--gcc/gencfn-macros.c50
1 files changed, 36 insertions, 14 deletions
diff --git a/gcc/gencfn-macros.c b/gcc/gencfn-macros.c
index 269429f..5b38ac2 100644
--- a/gcc/gencfn-macros.c
+++ b/gcc/gencfn-macros.c
@@ -98,11 +98,12 @@ is_group (string_set *builtins, const char *name, const char *const *suffixes)
static void
print_case_cfn (const char *name, bool internal_p,
- const char *const *suffixes)
+ const char *const *suffixes, bool floatn_p)
{
- printf ("#define CASE_CFN_%s", name);
+ const char *floatn = (floatn_p) ? "_FN" : "";
+ printf ("#define CASE_CFN_%s%s", name, floatn);
if (internal_p)
- printf (" \\\n case CFN_%s", name);
+ printf (" \\\n case CFN_%s%s", name, floatn);
for (unsigned int i = 0; suffixes[i]; ++i)
printf ("%s \\\n case CFN_BUILT_IN_%s%s",
internal_p || i > 0 ? ":" : "", name, suffixes[i]);
@@ -115,9 +116,10 @@ print_case_cfn (const char *name, bool internal_p,
static void
print_define_operator_list (const char *name, bool internal_p,
- const char *const *suffixes)
+ const char *const *suffixes, bool floatn_p)
{
- printf ("(define_operator_list %s\n", name);
+ const char *floatn = (floatn_p) ? "_FN" : "";
+ printf ("(define_operator_list %s%s\n", name, floatn);
for (unsigned int i = 0; suffixes[i]; ++i)
printf (" BUILT_IN_%s%s\n", name, suffixes[i]);
if (internal_p)
@@ -148,6 +150,8 @@ const char *const internal_fn_int_names[] = {
};
static const char *const flt_suffixes[] = { "F", "", "L", NULL };
+static const char *const fltfn_suffixes[] = { "F16", "F32", "F64", "F128",
+ "F32X", "F64X", "F128X", NULL };
static const char *const int_suffixes[] = { "", "L", "LL", "IMAX", NULL };
static const char *const *const suffix_lists[] = {
@@ -200,15 +204,33 @@ main (int argc, char **argv)
{
const char *root = name + 9;
for (unsigned int j = 0; suffix_lists[j]; ++j)
- if (is_group (&builtins, root, suffix_lists[j]))
- {
- bool internal_p = internal_fns.contains (root);
- if (type == 'c')
- print_case_cfn (root, internal_p, suffix_lists[j]);
- else
- print_define_operator_list (root, internal_p,
- suffix_lists[j]);
- }
+ {
+ const char *const *const suffix = suffix_lists[j];
+
+ if (is_group (&builtins, root, suffix))
+ {
+ bool internal_p = internal_fns.contains (root);
+
+ if (type == 'c')
+ print_case_cfn (root, internal_p, suffix, false);
+ else
+ print_define_operator_list (root, internal_p,
+ suffix, false);
+
+ /* Support the _Float<N> and _Float<N>X math functions if
+ they exist. We put these out as a separate CFN macro,
+ so code can add support or not as needed. */
+ if (suffix == flt_suffixes
+ && is_group (&builtins, root, fltfn_suffixes))
+ {
+ if (type == 'c')
+ print_case_cfn (root, false, fltfn_suffixes, true);
+ else
+ print_define_operator_list (root, false, fltfn_suffixes,
+ true);
+ }
+ }
+ }
}
}