summaryrefslogtreecommitdiff
path: root/gcc/builtins.def
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2020-09-29 10:10:06 +0200
committerTom de Vries <tdevries@suse.de>2020-09-30 14:36:56 +0200
commitbae974e637421263e8854a69b83284fa6309f9a1 (patch)
treeb25d0b206b5e27d31777f62f9f92c229065976ae /gcc/builtins.def
parent46183c96d2aea8181efb6bc3cfdb221987fe002d (diff)
downloadgcc-bae974e637421263e8854a69b83284fa6309f9a1.tar.gz
[nvptx] Add type arg to TARGET_LIBC_HAS_FUNCTION
GCC has a target hook TARGET_LIBC_HAS_FUNCTION, which tells the compiler which functions it can expect to be present in libc. The default target hook does not include the sincos functions. The nvptx port of newlib does include sincos and sincosf, but not sincosl. The target hook TARGET_LIBC_HAS_FUNCTION does not distinguish between sincos, sincosf and sincosl, so if we enable it for the sincos functions, then for test.c: ... long double x, a, b; int main (void) { x = 0.5; a = sinl (x); b = cosl (x); printf ("a: %f\n", (double)a); printf ("b: %f\n", (double)b); return 0; } ... we introduce a regression: ... $ gcc test.c -lm -O2 unresolved symbol sincosl collect2: error: ld returned 1 exit status ... Add a type argument to target hook TARGET_LIBC_HAS_FUNCTION_TYPE, and use it in nvptx_libc_has_function_type to enable sincos and sincosf, but not sincosl. Build and reg-tested on x86_64-linux. Build and tested on nvptx. gcc/ChangeLog: 2020-09-28 Tobias Burnus <tobias@codesourcery.com> Tom de Vries <tdevries@suse.de> * builtins.c (expand_builtin_cexpi, fold_builtin_sincos): Update targetm.libc_has_function call. * builtins.def (DEF_C94_BUILTIN, DEF_C99_BUILTIN, DEF_C11_BUILTIN): (DEF_C2X_BUILTIN, DEF_C99_COMPL_BUILTIN, DEF_C99_C90RES_BUILTIN): Same. * config/darwin-protos.h (darwin_libc_has_function): Update prototype. * config/darwin.c (darwin_libc_has_function): Add arg. * config/linux-protos.h (linux_libc_has_function): Update prototype. * config/linux.c (linux_libc_has_function): Add arg. * config/i386/i386.c (ix86_libc_has_function): Update targetm.libc_has_function call. * config/nvptx/nvptx.c (nvptx_libc_has_function): New function. (TARGET_LIBC_HAS_FUNCTION): Redefine to nvptx_libc_has_function. * convert.c (convert_to_integer_1): Update targetm.libc_has_function call. * match.pd: Same. * target.def (libc_has_function): Add arg. * doc/tm.texi: Regenerate. * targhooks.c (default_libc_has_function, gnu_libc_has_function) (no_c99_libc_has_function): Add arg. * targhooks.h (default_libc_has_function, no_c99_libc_has_function) (gnu_libc_has_function): Update prototype. * tree-ssa-math-opts.c (pass_cse_sincos::execute): Update targetm.libc_has_function call. gcc/fortran/ChangeLog: 2020-09-30 Tom de Vries <tdevries@suse.de> * f95-lang.c (gfc_init_builtin_functions): Update targetm.libc_has_function call.
Diffstat (limited to 'gcc/builtins.def')
-rw-r--r--gcc/builtins.def20
1 files changed, 14 insertions, 6 deletions
diff --git a/gcc/builtins.def b/gcc/builtins.def
index 102322b7912..95428c010d9 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -138,34 +138,41 @@ along with GCC; see the file COPYING3. If not see
#undef DEF_C94_BUILTIN
#define DEF_C94_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
- true, true, !flag_isoc94, ATTRS, targetm.libc_has_function (function_c94), true)
+ true, true, !flag_isoc94, ATTRS, \
+ targetm.libc_has_function (function_c94, NULL_TREE), true)
/* Like DEF_LIB_BUILTIN, except that the function is only a part of
the standard in C99 or above. */
#undef DEF_C99_BUILTIN
#define DEF_C99_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
- true, true, !flag_isoc99, ATTRS, targetm.libc_has_function (function_c99_misc), true)
+ true, true, !flag_isoc99, ATTRS, \
+ targetm.libc_has_function (function_c99_misc, NULL_TREE), true)
/* Like DEF_LIB_BUILTIN, except that the function is only a part of
the standard in C11 or above. */
#undef DEF_C11_BUILTIN
#define DEF_C11_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
- true, true, !flag_isoc11, ATTRS, targetm.libc_has_function (function_c11_misc), true)
+ true, true, !flag_isoc11, ATTRS, \
+ targetm.libc_has_function (function_c11_misc, NULL_TREE), true)
/* Like DEF_LIB_BUILTIN, except that the function is only a part of
the standard in C2x or above. */
#undef DEF_C2X_BUILTIN
#define DEF_C2X_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
- true, true, !flag_isoc2x, ATTRS, targetm.libc_has_function (function_c2x_misc), true)
+ true, true, !flag_isoc2x, ATTRS, \
+ targetm.libc_has_function (function_c2x_misc, NULL_TREE), true)
/* Like DEF_C99_BUILTIN, but for complex math functions. */
#undef DEF_C99_COMPL_BUILTIN
#define DEF_C99_COMPL_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
- true, true, !flag_isoc99, ATTRS, targetm.libc_has_function (function_c99_math_complex), true)
+ true, true, !flag_isoc99, ATTRS, \
+ targetm.libc_has_function (function_c99_math_complex, \
+ NULL_TREE), \
+ true)
/* Builtin that is specified by C99 and C90 reserve the name for future use.
We can still recognize the builtin in C90 mode but we can't produce it
@@ -173,7 +180,8 @@ along with GCC; see the file COPYING3. If not see
#undef DEF_C99_C90RES_BUILTIN
#define DEF_C99_C90RES_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
- true, true, !flag_isoc99, ATTRS, targetm.libc_has_function (function_c99_misc), true)
+ true, true, !flag_isoc99, ATTRS, \
+ targetm.libc_has_function (function_c99_misc, NULL_TREE), true)
/* Builtin that C99 reserve the name for future use. We can still recognize
the builtin in C99 mode but we can't produce it implicitly. */