aboutsummaryrefslogtreecommitdiff
path: root/gcc/targhooks.c
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/targhooks.c
parent46183c96d2aea8181efb6bc3cfdb221987fe002d (diff)
downloadgcc-bae974e637421263e8854a69b83284fa6309f9a1.zip
gcc-bae974e637421263e8854a69b83284fa6309f9a1.tar.gz
gcc-bae974e637421263e8854a69b83284fa6309f9a1.tar.bz2
[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/targhooks.c')
-rw-r--r--gcc/targhooks.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index da4805d..5d94fce 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -1641,7 +1641,8 @@ default_have_conditional_execution (void)
/* By default we assume that c99 functions are present at the runtime,
but sincos is not. */
bool
-default_libc_has_function (enum function_class fn_class)
+default_libc_has_function (enum function_class fn_class,
+ tree type ATTRIBUTE_UNUSED)
{
if (fn_class == function_c94
|| fn_class == function_c99_misc
@@ -1660,13 +1661,15 @@ default_libc_has_fast_function (int fcode ATTRIBUTE_UNUSED)
}
bool
-gnu_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED)
+gnu_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED,
+ tree type ATTRIBUTE_UNUSED)
{
return true;
}
bool
-no_c99_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED)
+no_c99_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED,
+ tree type ATTRIBUTE_UNUSED)
{
return false;
}