diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8708f83..f7f0072 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,65 @@ +2012-12-21 Alexander Ivchenko + + * gcc/target.def (TARGET_LIBC_HAS_FUNCTION): New target hook. + * gcc/builtins.c (default_libc_has_function): New. + (gnu_libc_has_function): Ditto. + (no_c99_libc_has_function): Ditto. + (expand_builtin_cexpi): Using new target hook TARGET_LIBC_HAS_FUNCTION + istead of TARGET_HAS_SINCOS and TARGET_C99_FUNCTIONS. + (fold_builtin_sincos): Likewise. + (fold_builtin_cexp): Likewise. + * gcc/builtins.def (DEF_C94_BUILTIN): Likewise. + (DEF_C99_BUILTIN): Likewise. + (DEF_C99_C90RES_BUILTIN): Likewise. + (DEF_C99_COMPL_BUILTIN): New define. Change all complex c99 builtin + definitions to using this define. + * gcc/config/alpha/linux.h: Remove TARGET_C99_FUNCTIONS and + TARGET_HAS_SINCOS. Redefine TARGET_LIBC_HAS_FUNCTION. + * gcc/config/darwin.h: Ditto. + * gcc/config/darwin10.h: Ditto. + * gcc/config/darwin9.h: Ditto. + * gcc/config/elfos.h: Ditto. + * gcc/config/freebsd.h: Ditto. + * gcc/config/gnu-user.h: Ditto. + * gcc/config/ia64/hpux.h: Ditto. + * gcc/config/linux.h: Ditto. + * gcc/config/netbsd.h: Ditto. + * gcc/config/openbsd.h: Ditto. + * gcc/config/rs6000/aix52.h: Ditto. + * gcc/config/rs6000/aix53.h: Ditto. + * gcc/config/rs6000/aix61.h: Ditto. + * gcc/config/rs6000/darwin.h: Ditto. + * gcc/config/rs6000/linux.h: Ditto. + * gcc/config/rs6000/linux64.h: Ditto. + * gcc/config/s390/tpf.h: Ditto. + * gcc/config/sol2-10.h: Ditto. + * gcc/config/sol2.h: Ditto. + * gcc/config/vxworks.h: Ditto. + * gcc/config/host-linux.c (linux_libc_has_function): New linux-specific + implementation of TARGET_LIBC_HAS_FUNCTION. + * gcc/config/i386/i386.c (ix86_libc_has_function): New. + * gcc/config/i386/i386-protos.h + (ix86_libc_has_function): New declaration. + * gcc/config/i386/i386.md + ("isinfxf2"): Change condition for TARGET_LIBC_HAS_FUNCTION. + ("isinf2): Likewise. + * gcc/convert.c (convert_to_integer): Using new target hook + TARGET_LIBC_HAS_FUNCTION istead of TARGET_HAS_SINCOS and + TARGET_C99_FUNCTIONS. + * gcc/fortran/f95-lang.c (gfc_init_builtin_functions): Ditto. + * gcc/tree-ssa-math-opts.c (execute_cse_sincos): Ditto. + * gcc/coretypes.h (function_class): New enum for different + classes of functions. + * gcc/defaults.h: Remove TARGET_C99_FUNCTIONS and TARGET_HAS_SINCOS. + * gcc/doc/tm.texi.in (TARGET_C99_FUNCTIONS): Remove documentation. + (TARGET_HAS_SINCOS): Likewise. + (TARGET_LIBC_HAS_FUNCTION): New. + * gcc/doc/tm.texi: Regenerated. + * gcc/output.h (default_libc_has_function): New declaration. + (no_c99_libc_has_function): Ditto. + (gnu_libc_has_function): Ditto. + (linux_libc_has_function): Ditto. + 2012-12-20 Thomas Schwinge PR bootstrap/55202 diff --git a/gcc/builtins.c b/gcc/builtins.c index fb7b537..940b1e1 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -248,6 +248,33 @@ is_builtin_fn (tree decl) return TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl); } +/* 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, + const char *name ATTRIBUTE_UNUSED) +{ + if (fn_class == function_c94 + || fn_class == function_c99_misc + || fn_class == function_c99_math_complex) + return true; + + return false; +} + +bool +gnu_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED, + const char *name ATTRIBUTE_UNUSED) +{ + return true; +} + +bool +no_c99_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED, + const char *name ATTRIBUTE_UNUSED) +{ + return false; +} /* Return true if NODE should be considered for inline expansion regardless of the optimization level. This means whenever a function is invoked with @@ -2535,7 +2562,7 @@ expand_builtin_cexpi (tree exp, rtx target) /* Compute into op1 and op2. */ expand_twoval_unop (sincos_optab, op0, op2, op1, 0); } - else if (TARGET_HAS_SINCOS) + else if (targetm.libc_has_function (function_sincos, "")) { tree call, fn = NULL_TREE; tree top1, top2; @@ -7803,7 +7830,7 @@ fold_builtin_sincos (location_t loc, return res; /* Canonicalize sincos to cexpi. */ - if (!TARGET_C99_FUNCTIONS) + if (!targetm.libc_has_function (function_c99_math_complex, "")) return NULL_TREE; fn = mathfn_built_in (type, BUILT_IN_CEXPI); if (!fn) @@ -7843,7 +7870,7 @@ fold_builtin_cexp (location_t loc, tree arg0, tree type) /* In case we can figure out the real part of arg0 and it is constant zero fold to cexpi. */ - if (!TARGET_C99_FUNCTIONS) + if (!targetm.libc_has_function (function_c99_math_complex, "")) return NULL_TREE; ifn = mathfn_built_in (rtype, BUILT_IN_CEXPI); if (!ifn) diff --git a/gcc/builtins.def b/gcc/builtins.def index 9f0692d..6f209a3 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.def @@ -103,14 +103,20 @@ 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, TARGET_C99_FUNCTIONS, true) + true, true, !flag_isoc94, ATTRS, targetm.libc_has_function (function_c94, NAME), 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, TARGET_C99_FUNCTIONS, true) + true, true, !flag_isoc99, ATTRS, targetm.libc_has_function (function_c99_misc, NAME), 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, NAME), 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 @@ -118,7 +124,7 @@ 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, TARGET_C99_FUNCTIONS, true) + true, true, !flag_isoc99, ATTRS, targetm.libc_has_function (function_c99_misc, NAME), 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. */ @@ -459,78 +465,78 @@ DEF_EXT_LIB_BUILTIN (BUILT_IN_YNF, "ynf", BT_FN_FLOAT_INT_FLOAT, ATTR_MATHFN_ DEF_EXT_LIB_BUILTIN (BUILT_IN_YNL, "ynl", BT_FN_LONGDOUBLE_INT_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO) /* Category: _Complex math builtins. */ -DEF_C99_BUILTIN (BUILT_IN_CABS, "cabs", BT_FN_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CABSF, "cabsf", BT_FN_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CABSL, "cabsl", BT_FN_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CACOS, "cacos", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CACOSF, "cacosf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CACOSH, "cacosh", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CACOSHF, "cacoshf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CACOSHL, "cacoshl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CACOSL, "cacosl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CARG, "carg", BT_FN_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CARGF, "cargf", BT_FN_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CARGL, "cargl", BT_FN_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CASIN, "casin", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CASINF, "casinf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CASINH, "casinh", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CASINHF, "casinhf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CASINHL, "casinhl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CASINL, "casinl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CATAN, "catan", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CATANF, "catanf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CATANH, "catanh", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CATANHF, "catanhf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CATANHL, "catanhl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CATANL, "catanl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CCOS, "ccos", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CCOSF, "ccosf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CCOSH, "ccosh", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CCOSHF, "ccoshf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CCOSHL, "ccoshl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CCOSL, "ccosl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CEXP, "cexp", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CEXPF, "cexpf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CEXPL, "cexpl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CABS, "cabs", BT_FN_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CABSF, "cabsf", BT_FN_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CABSL, "cabsl", BT_FN_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CACOS, "cacos", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CACOSF, "cacosf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CACOSH, "cacosh", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CACOSHF, "cacoshf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CACOSHL, "cacoshl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CACOSL, "cacosl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CARG, "carg", BT_FN_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CARGF, "cargf", BT_FN_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CARGL, "cargl", BT_FN_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CASIN, "casin", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CASINF, "casinf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CASINH, "casinh", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CASINHF, "casinhf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CASINHL, "casinhl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CASINL, "casinl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CATAN, "catan", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CATANF, "catanf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CATANH, "catanh", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CATANHF, "catanhf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CATANHL, "catanhl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CATANL, "catanl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CCOS, "ccos", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CCOSF, "ccosf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CCOSH, "ccosh", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CCOSHF, "ccoshf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CCOSHL, "ccoshl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CCOSL, "ccosl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CEXP, "cexp", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CEXPF, "cexpf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CEXPL, "cexpl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) DEF_GCC_BUILTIN (BUILT_IN_CEXPI, "cexpi", BT_FN_COMPLEX_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING) DEF_GCC_BUILTIN (BUILT_IN_CEXPIF, "cexpif", BT_FN_COMPLEX_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING) DEF_GCC_BUILTIN (BUILT_IN_CEXPIL, "cexpil", BT_FN_COMPLEX_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CIMAG, "cimag", BT_FN_DOUBLE_COMPLEX_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_C99_BUILTIN (BUILT_IN_CIMAGF, "cimagf", BT_FN_FLOAT_COMPLEX_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_C99_BUILTIN (BUILT_IN_CIMAGL, "cimagl", BT_FN_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_C99_BUILTIN (BUILT_IN_CLOG, "clog", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CLOGF, "clogf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CLOGL, "clogl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CIMAG, "cimag", BT_FN_DOUBLE_COMPLEX_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CIMAGF, "cimagf", BT_FN_FLOAT_COMPLEX_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CIMAGL, "cimagl", BT_FN_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CLOG, "clog", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CLOGF, "clogf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CLOGL, "clogl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) DEF_EXT_C99RES_BUILTIN (BUILT_IN_CLOG10, "clog10", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) DEF_EXT_C99RES_BUILTIN (BUILT_IN_CLOG10F, "clog10f", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) DEF_EXT_C99RES_BUILTIN (BUILT_IN_CLOG10L, "clog10l", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CONJ, "conj", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_C99_BUILTIN (BUILT_IN_CONJF, "conjf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_C99_BUILTIN (BUILT_IN_CONJL, "conjl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_C99_BUILTIN (BUILT_IN_CPOW, "cpow", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CPOWF, "cpowf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CPOWL, "cpowl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CPROJ, "cproj", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_C99_BUILTIN (BUILT_IN_CPROJF, "cprojf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_C99_BUILTIN (BUILT_IN_CPROJL, "cprojl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_C99_BUILTIN (BUILT_IN_CREAL, "creal", BT_FN_DOUBLE_COMPLEX_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_C99_BUILTIN (BUILT_IN_CREALF, "crealf", BT_FN_FLOAT_COMPLEX_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_C99_BUILTIN (BUILT_IN_CREALL, "creall", BT_FN_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_C99_BUILTIN (BUILT_IN_CSIN, "csin", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CSINF, "csinf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CSINH, "csinh", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CSINHF, "csinhf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CSINHL, "csinhl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CSINL, "csinl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CSQRT, "csqrt", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CSQRTF, "csqrtf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CSQRTL, "csqrtl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CTAN, "ctan", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CTANF, "ctanf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CTANH, "ctanh", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CTANHF, "ctanhf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CTANHL, "ctanhl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) -DEF_C99_BUILTIN (BUILT_IN_CTANL, "ctanl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CONJ, "conj", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CONJF, "conjf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CONJL, "conjl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CPOW, "cpow", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CPOWF, "cpowf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CPOWL, "cpowl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CPROJ, "cproj", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CPROJF, "cprojf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CPROJL, "cprojl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CREAL, "creal", BT_FN_DOUBLE_COMPLEX_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CREALF, "crealf", BT_FN_FLOAT_COMPLEX_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CREALL, "creall", BT_FN_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CSIN, "csin", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CSINF, "csinf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CSINH, "csinh", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CSINHF, "csinhf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CSINHL, "csinhl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CSINL, "csinl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CSQRT, "csqrt", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CSQRTF, "csqrtf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CSQRTL, "csqrtl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CTAN, "ctan", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CTANF, "ctanf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CTANH, "ctanh", BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CTANHF, "ctanhf", BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CTANHL, "ctanhl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) +DEF_C99_COMPL_BUILTIN (BUILT_IN_CTANL, "ctanl", BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING) /* Category: string/memory builtins. */ /* bcmp, bcopy and bzero have traditionally accepted NULL pointers diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h index 8856874..82ba454 100644 --- a/gcc/config/alpha/linux.h +++ b/gcc/config/alpha/linux.h @@ -64,12 +64,10 @@ along with GCC; see the file COPYING3. If not see #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) #endif -/* Determine whether the entire c99 runtime is present in the - runtime library. */ -#define TARGET_C99_FUNCTIONS (OPTION_GLIBC) - -/* Whether we have sincos that follows the GNU extension. */ -#define TARGET_HAS_SINCOS (OPTION_GLIBC) +/* Determine what functions are present at the runtime; + this includes full c99 runtime and sincos. */ +#undef TARGET_LIBC_HAS_FUNCTION +#define TARGET_LIBC_HAS_FUNCTION linux_libc_has_function #define TARGET_POSIX_IO diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 3a99670..3b25d71 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -875,10 +875,6 @@ void add_framework_path (char *); #define TARGET_POSIX_IO -/* All new versions of Darwin have C99 functions. */ - -#define TARGET_C99_FUNCTIONS 1 - #define WINT_TYPE "int" /* Every program on darwin links against libSystem which contains the pthread diff --git a/gcc/config/darwin10.h b/gcc/config/darwin10.h index fd664c3..68f33b2 100644 --- a/gcc/config/darwin10.h +++ b/gcc/config/darwin10.h @@ -32,3 +32,6 @@ along with GCC; see the file COPYING3. If not see #undef DEF_MIN_OSX_VERSION #define DEF_MIN_OSX_VERSION "10.6" + +#undef TARGET_LIBC_HAS_FUNCTION +#define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function diff --git a/gcc/config/darwin9.h b/gcc/config/darwin9.h index 92429ca..11d13e1 100644 --- a/gcc/config/darwin9.h +++ b/gcc/config/darwin9.h @@ -63,3 +63,6 @@ along with GCC; see the file COPYING3. If not see #undef STACK_CHECK_STATIC_BUILTIN #define STACK_CHECK_STATIC_BUILTIN 1 + +#undef TARGET_LIBC_HAS_FUNCTION +#define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function diff --git a/gcc/config/elfos.h b/gcc/config/elfos.h index 4c74883..26e5180 100644 --- a/gcc/config/elfos.h +++ b/gcc/config/elfos.h @@ -434,3 +434,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \ default_elf_asm_output_external (FILE, DECL, NAME) #endif + +#undef TARGET_LIBC_HAS_FUNCTION +#define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function diff --git a/gcc/config/freebsd.h b/gcc/config/freebsd.h index f9a4713..0ba766a 100644 --- a/gcc/config/freebsd.h +++ b/gcc/config/freebsd.h @@ -53,6 +53,9 @@ along with GCC; see the file COPYING3. If not see #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all:-lssp_nonshared}" #endif +#undef TARGET_LIBC_HAS_FUNCTION +#define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function + /* Use --as-needed -lgcc_s for eh support. */ #ifdef HAVE_LD_AS_NEEDED #define USE_LD_AS_NEEDED 1 diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h index 8c4bbc6..f8e24cc 100644 --- a/gcc/config/gnu-user.h +++ b/gcc/config/gnu-user.h @@ -96,8 +96,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define TARGET_POSIX_IO -#define TARGET_C99_FUNCTIONS 1 -#define TARGET_HAS_SINCOS 1 +#undef TARGET_LIBC_HAS_FUNCTION +#define TARGET_LIBC_HAS_FUNCTION gnu_libc_has_function /* Additional libraries needed by -static-libasan. */ #undef STATIC_LIBASAN_LIBS diff --git a/gcc/config/host-linux.c b/gcc/config/host-linux.c index b535758..8188a31 100644 --- a/gcc/config/host-linux.c +++ b/gcc/config/host-linux.c @@ -22,6 +22,7 @@ #include "coretypes.h" #include "hosthooks.h" #include "hosthooks-def.h" +#include "tm.h" /* Linux has a feature called exec-shield-randomize that perturbs the @@ -222,5 +223,20 @@ linux_gt_pch_use_address (void *base, size_t size, int fd, size_t offset) return 1; } +bool +linux_libc_has_function (enum function_class fn_class, + const char *name ATTRIBUTE_UNUSED) +{ + if (OPTION_GLIBC) + return true; + if (OPTION_BIONIC) + if (fn_class == function_c94 + || fn_class == function_c99_misc + || fn_class == function_sincos) + return true; + + return false; +} + const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER; diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 4c23f57..51e6c05 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -173,6 +173,8 @@ extern int ix86_mode_after (int, int, rtx); extern int ix86_mode_entry (int); extern int ix86_mode_exit (int); +extern bool ix86_libc_has_function (enum function_class fn_class, const char *name); + #ifdef HARD_CONST extern void ix86_emit_mode_set (int, int, HARD_REG_SET); #endif diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index b466a4f..dfe066a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -5533,6 +5533,14 @@ ix86_function_type_abi (const_tree fntype) return ix86_abi; } +/* We add this as a workaround in order to use libc_has_function + hook in i386.md. */ +bool +ix86_libc_has_function (enum function_class fn_class, const char *name) +{ + return targetm.libc_has_function (fn_class, name); +} + static bool ix86_function_ms_hook_prologue (const_tree fn) { diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 95a52cd..52ead79 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -15230,7 +15230,7 @@ [(use (match_operand:SI 0 "register_operand")) (use (match_operand:XF 1 "register_operand"))] "TARGET_USE_FANCY_MATH_387 - && TARGET_C99_FUNCTIONS" + && ix86_libc_has_function (function_c99_misc, 0)" { rtx mask = GEN_INT (0x45); rtx val = GEN_INT (0x05); @@ -15256,7 +15256,7 @@ [(use (match_operand:SI 0 "register_operand")) (use (match_operand:MODEF 1 "nonimmediate_operand"))] "TARGET_USE_FANCY_MATH_387 - && TARGET_C99_FUNCTIONS + && ix86_libc_has_function (function_c99_misc, 0) && !(SSE_FLOAT_MODE_P (mode) && TARGET_SSE_MATH)" { rtx mask = GEN_INT (0x45); diff --git a/gcc/config/ia64/hpux.h b/gcc/config/ia64/hpux.h index d9ae109..238a75a 100644 --- a/gcc/config/ia64/hpux.h +++ b/gcc/config/ia64/hpux.h @@ -180,10 +180,6 @@ do { \ #undef TARGET_ASM_RELOC_RW_MASK #define TARGET_ASM_RELOC_RW_MASK ia64_hpux_reloc_rw_mask -/* ia64 HPUX has the float and long double forms of math functions. */ -#undef TARGET_C99_FUNCTIONS -#define TARGET_C99_FUNCTIONS 1 - #undef TARGET_INIT_LIBFUNCS #define TARGET_INIT_LIBFUNCS ia64_hpux_init_libfuncs diff --git a/gcc/config/linux.h b/gcc/config/linux.h index fb459e6..04a8b86 100644 --- a/gcc/config/linux.h +++ b/gcc/config/linux.h @@ -96,14 +96,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \ BIONIC_DYNAMIC_LINKERX32) -/* Determine whether the entire c99 runtime - is present in the runtime library. */ -#undef TARGET_C99_FUNCTIONS -#define TARGET_C99_FUNCTIONS (OPTION_GLIBC) - -/* Whether we have sincos that follows the GNU extension. */ -#undef TARGET_HAS_SINCOS -#define TARGET_HAS_SINCOS (OPTION_GLIBC || OPTION_BIONIC) +/* Determine what functions are present at the runtime; + this includes full c99 runtime and sincos. */ +#undef TARGET_LIBC_HAS_FUNCTION +#define TARGET_LIBC_HAS_FUNCTION linux_libc_has_function /* Whether we have Bionic libc runtime */ #undef TARGET_HAS_BIONIC diff --git a/gcc/config/netbsd.h b/gcc/config/netbsd.h index e9290c2..eff4afd 100644 --- a/gcc/config/netbsd.h +++ b/gcc/config/netbsd.h @@ -140,6 +140,9 @@ along with GCC; see the file COPYING3. If not see #undef LIBGCC_SPEC #define LIBGCC_SPEC NETBSD_LIBGCC_SPEC +#undef TARGET_LIBC_HAS_FUNCTION +#define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function + /* When building shared libraries, the initialization and finalization functions for the library are .init and .fini respectively. */ diff --git a/gcc/config/openbsd.h b/gcc/config/openbsd.h index 87c4ce2..c374811 100644 --- a/gcc/config/openbsd.h +++ b/gcc/config/openbsd.h @@ -146,9 +146,6 @@ while (0) #define TARGET_POSIX_IO -/* All new versions of OpenBSD have C99 functions. */ -#define TARGET_C99_FUNCTIONS 1 - /* Runtime target specification. */ diff --git a/gcc/config/rs6000/aix52.h b/gcc/config/rs6000/aix52.h index a37ce62..05528f6 100644 --- a/gcc/config/rs6000/aix52.h +++ b/gcc/config/rs6000/aix52.h @@ -166,10 +166,6 @@ do { \ #undef LD_INIT_SWITCH #define LD_INIT_SWITCH "-binitfini" -/* AIX 5.2 has the float and long double forms of math functions. */ -#undef TARGET_C99_FUNCTIONS -#define TARGET_C99_FUNCTIONS 1 - #ifndef _AIX52 extern long long int atoll(const char *); #endif diff --git a/gcc/config/rs6000/aix53.h b/gcc/config/rs6000/aix53.h index baafb51..1e64986 100644 --- a/gcc/config/rs6000/aix53.h +++ b/gcc/config/rs6000/aix53.h @@ -165,12 +165,8 @@ do { \ #undef LD_INIT_SWITCH #define LD_INIT_SWITCH "-binitfini" -/* AIX 5.2 has the float and long double forms of math functions. */ -#undef TARGET_C99_FUNCTIONS -#define TARGET_C99_FUNCTIONS 1 - #ifndef _AIX52 -extern long long int atoll(const char *); +extern long long int atoll(const char *); #endif /* This target uses the aix64.opt file. */ diff --git a/gcc/config/rs6000/aix61.h b/gcc/config/rs6000/aix61.h index 063cb26..dcca1f4 100644 --- a/gcc/config/rs6000/aix61.h +++ b/gcc/config/rs6000/aix61.h @@ -185,12 +185,8 @@ do { \ #undef LD_INIT_SWITCH #define LD_INIT_SWITCH "-binitfini" -/* AIX 5.2 has the float and long double forms of math functions. */ -#undef TARGET_C99_FUNCTIONS -#define TARGET_C99_FUNCTIONS 1 - #ifndef _AIX52 -extern long long int atoll(const char *); +extern long long int atoll(const char *); #endif /* This target uses the aix64.opt file. */ diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h index 48f9fcc..77bded1 100644 --- a/gcc/config/rs6000/darwin.h +++ b/gcc/config/rs6000/darwin.h @@ -384,12 +384,6 @@ extern int darwin_emit_branch_islands; /* This is the reserved ivar address Objective-C. */ #define OFFS_ASSIGNIVAR_FAST 0xFFFEFEC0 -/* Old versions of Mac OS/Darwin don't have C99 functions available. */ -#undef TARGET_C99_FUNCTIONS -#define TARGET_C99_FUNCTIONS \ - (TARGET_64BIT \ - || strverscmp (darwin_macosx_version_min, "10.3") >= 0) - /* When generating kernel code or kexts, we don't use Altivec by default, as kernel code doesn't save/restore those registers. */ #define OS_MISSING_ALTIVEC (flag_mkernel || flag_apple_kext) diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h index 02477df..f3aa2e8 100644 --- a/gcc/config/rs6000/linux.h +++ b/gcc/config/rs6000/linux.h @@ -33,13 +33,10 @@ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) #endif -/* glibc has float and long double forms of math functions. */ -#undef TARGET_C99_FUNCTIONS -#define TARGET_C99_FUNCTIONS (OPTION_GLIBC) - -/* Whether we have sincos that follows the GNU extension. */ -#undef TARGET_HAS_SINCOS -#define TARGET_HAS_SINCOS (OPTION_GLIBC) +/* Determine what functions are present at the runtime; + this includes full c99 runtime and sincos. */ +#undef TARGET_LIBC_HAS_FUNCTION +#define TARGET_LIBC_HAS_FUNCTION linux_libc_has_function #undef TARGET_OS_CPP_BUILTINS #define TARGET_OS_CPP_BUILTINS() \ diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h index 4d2c365..36a2075 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -300,13 +300,10 @@ extern int dot_symbols; #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) #endif -/* glibc has float and long double forms of math functions. */ -#undef TARGET_C99_FUNCTIONS -#define TARGET_C99_FUNCTIONS (OPTION_GLIBC) - -/* Whether we have sincos that follows the GNU extension. */ -#undef TARGET_HAS_SINCOS -#define TARGET_HAS_SINCOS (OPTION_GLIBC) +/* Determine what functions are present at the runtime; + this includes full c99 runtime and sincos. */ +#undef TARGET_LIBC_HAS_FUNCTION +#define TARGET_LIBC_HAS_FUNCTION linux_libc_has_function #undef TARGET_OS_CPP_BUILTINS #define TARGET_OS_CPP_BUILTINS() \ diff --git a/gcc/config/s390/tpf.h b/gcc/config/s390/tpf.h index 4727a29..570831e 100644 --- a/gcc/config/s390/tpf.h +++ b/gcc/config/s390/tpf.h @@ -95,9 +95,6 @@ along with GCC; see the file COPYING3. If not see #define ASM_SPEC "%{m31&m64}%{mesa&mzarch}%{march=*} \ -alshd=%b.lst" -#undef TARGET_C99_FUNCTIONS -#define TARGET_C99_FUNCTIONS 1 - #define ENTRY_SPEC "%{mmain:-entry=_start} \ %{!mmain:-entry=0}" diff --git a/gcc/config/sol2-10.h b/gcc/config/sol2-10.h index edea655..d926596 100644 --- a/gcc/config/sol2-10.h +++ b/gcc/config/sol2-10.h @@ -17,6 +17,3 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see . */ - -/* Solaris 10 has the float and long double forms of math functions. */ -#define TARGET_C99_FUNCTIONS 1 diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h index 4cbb308..8d31a54 100644 --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -281,6 +281,9 @@ along with GCC; see the file COPYING3. If not see #define TARGET_POSIX_IO +#undef TARGET_LIBC_HAS_FUNCTION +#define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function + extern GTY(()) tree solaris_pending_aligns; extern GTY(()) tree solaris_pending_inits; extern GTY(()) tree solaris_pending_finis; diff --git a/gcc/config/vxworks.h b/gcc/config/vxworks.h index 000de36..f141a23 100644 --- a/gcc/config/vxworks.h +++ b/gcc/config/vxworks.h @@ -115,6 +115,9 @@ extern void vxworks_asm_out_destructor (rtx symbol, int priority); #undef SIZE_TYPE #define SIZE_TYPE "unsigned int" +#undef TARGET_LIBC_HAS_FUNCTION +#define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function + /* Both kernels and RTPs have the facilities required by this macro. */ #define TARGET_POSIX_IO diff --git a/gcc/convert.c b/gcc/convert.c index 5e6b09e..983cf8c 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see #include "flags.h" #include "convert.h" #include "diagnostic-core.h" +#include "target.h" #include "langhooks.h" /* Convert EXPR to some pointer or reference type TYPE. @@ -387,7 +388,7 @@ convert_to_integer (tree type, tree expr) { CASE_FLT_FN (BUILT_IN_CEIL): /* Only convert in ISO C99 mode. */ - if (!TARGET_C99_FUNCTIONS) + if (!targetm.libc_has_function (function_c99_misc, "")) break; if (outprec < TYPE_PRECISION (integer_type_node) || (outprec == TYPE_PRECISION (integer_type_node) @@ -403,7 +404,7 @@ convert_to_integer (tree type, tree expr) CASE_FLT_FN (BUILT_IN_FLOOR): /* Only convert in ISO C99 mode. */ - if (!TARGET_C99_FUNCTIONS) + if (!targetm.libc_has_function (function_c99_misc, "")) break; if (outprec < TYPE_PRECISION (integer_type_node) || (outprec == TYPE_PRECISION (integer_type_node) @@ -419,7 +420,7 @@ convert_to_integer (tree type, tree expr) CASE_FLT_FN (BUILT_IN_ROUND): /* Only convert in ISO C99 mode. */ - if (!TARGET_C99_FUNCTIONS) + if (!targetm.libc_has_function (function_c99_misc, "")) break; if (outprec < TYPE_PRECISION (integer_type_node) || (outprec == TYPE_PRECISION (integer_type_node) @@ -440,7 +441,7 @@ convert_to_integer (tree type, tree expr) /* ... Fall through ... */ CASE_FLT_FN (BUILT_IN_RINT): /* Only convert in ISO C99 mode. */ - if (!TARGET_C99_FUNCTIONS) + if (!targetm.libc_has_function (function_c99_misc, "")) break; if (outprec < TYPE_PRECISION (integer_type_node) || (outprec == TYPE_PRECISION (integer_type_node) diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 4672877..eaa108e 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -182,6 +182,16 @@ union _dont_use_tree_here_; #endif +/* Classes of functions that compiler needs to check + whether they are present at the runtime or not. */ +enum function_class { + function_c94, + function_c99_misc, + function_c99_math_complex, + function_gnu, + function_sincos +}; + /* Memory model types for the __atomic* builtins. This must match the order in libstdc++-v3/include/bits/atomic_base.h. */ enum memmodel diff --git a/gcc/defaults.h b/gcc/defaults.h index 76909ab..0998a34 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -1042,18 +1042,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #endif /* old constraint mechanism in use */ -/* Determine whether the entire c99 runtime - is present in the runtime library. */ -#ifndef TARGET_C99_FUNCTIONS -#define TARGET_C99_FUNCTIONS 0 -#endif - -/* Determine whether the target runtime library has - a sincos implementation following the GNU extension. */ -#ifndef TARGET_HAS_SINCOS -#define TARGET_HAS_SINCOS 0 -#endif - /* Determin whether the target runtime library is Bionic */ #ifndef TARGET_HAS_BIONIC #define TARGET_HAS_BIONIC 0 diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 75aa867..df64624 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -5342,26 +5342,12 @@ refers to the global ``variable'' @code{errno}. (On certain systems, macro, a reasonable default is used. @end defmac -@cindex C99 math functions, implicit usage -@defmac TARGET_C99_FUNCTIONS -When this macro is nonzero, GCC will implicitly optimize @code{sin} calls into -@code{sinf} and similarly for other functions defined by C99 standard. The -default is zero because a number of existing systems lack support for these -functions in their runtime so this macro needs to be redefined to one on -systems that do support the C99 runtime. -@end defmac - -@cindex sincos math function, implicit usage -@defmac TARGET_HAS_SINCOS -When this macro is nonzero, GCC will implicitly optimize calls to @code{sin} -and @code{cos} with the same argument to a call to @code{sincos}. The -default is zero. The target has to provide the following functions: -@smallexample -void sincos(double x, double *sin, double *cos); -void sincosf(float x, float *sin, float *cos); -void sincosl(long double x, long double *sin, long double *cos); -@end smallexample -@end defmac +@deftypefn {Target Hook} bool TARGET_LIBC_HAS_FUNCTION (enum function_class @var{fn_class}, const char *@var{name}) +This hook determines whether a function with name @var{name} from a class +of functions @var{fn_class} is present at the runtime. If the @var{name} is +the empty string, then this hook will check whether the class of functions +@var{fn_class} is generally present at the runtime. +@end deftypefn @defmac NEXT_OBJC_RUNTIME Set this macro to 1 to use the "NeXT" Objective-C message sending conventions diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 95fab18..bf10dde 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -5258,26 +5258,7 @@ refers to the global ``variable'' @code{errno}. (On certain systems, macro, a reasonable default is used. @end defmac -@cindex C99 math functions, implicit usage -@defmac TARGET_C99_FUNCTIONS -When this macro is nonzero, GCC will implicitly optimize @code{sin} calls into -@code{sinf} and similarly for other functions defined by C99 standard. The -default is zero because a number of existing systems lack support for these -functions in their runtime so this macro needs to be redefined to one on -systems that do support the C99 runtime. -@end defmac - -@cindex sincos math function, implicit usage -@defmac TARGET_HAS_SINCOS -When this macro is nonzero, GCC will implicitly optimize calls to @code{sin} -and @code{cos} with the same argument to a call to @code{sincos}. The -default is zero. The target has to provide the following functions: -@smallexample -void sincos(double x, double *sin, double *cos); -void sincosf(float x, float *sin, float *cos); -void sincosl(long double x, long double *sin, long double *cos); -@end smallexample -@end defmac +@hook TARGET_LIBC_HAS_FUNCTION @defmac NEXT_OBJC_RUNTIME Set this macro to 1 to use the "NeXT" Objective-C message sending conventions diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c index be0d99f..546cfa0 100644 --- a/gcc/fortran/f95-lang.c +++ b/gcc/fortran/f95-lang.c @@ -828,7 +828,7 @@ gfc_init_builtin_functions (void) BUILT_IN_POWIF, "powif", ATTR_CONST_NOTHROW_LEAF_LIST); - if (TARGET_C99_FUNCTIONS) + if (targetm.libc_has_function (function_c99_math_complex, "")) { gfc_define_builtin ("__builtin_cbrtl", mfunc_longdouble[0], BUILT_IN_CBRTL, "cbrtl", @@ -850,7 +850,7 @@ gfc_init_builtin_functions (void) ATTR_CONST_NOTHROW_LEAF_LIST); } - if (TARGET_HAS_SINCOS) + if (targetm.libc_has_function (function_sincos, "")) { gfc_define_builtin ("__builtin_sincosl", func_longdouble_longdoublep_longdoublep, diff --git a/gcc/output.h b/gcc/output.h index 3fb743a..79df53c 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -595,7 +595,6 @@ extern void default_asm_declare_constant_name (FILE *, const char *, extern void default_file_start (void); extern void file_end_indicate_exec_stack (void); extern void file_end_indicate_split_stack (void); - extern void default_elf_asm_output_external (FILE *file, tree, const char *); extern void default_elf_asm_output_limited_string (FILE *, const char *); @@ -606,6 +605,11 @@ extern void default_elf_init_array_asm_out_constructor (rtx, int); extern void default_elf_fini_array_asm_out_destructor (rtx, int); extern int maybe_assemble_visibility (tree); +extern bool default_libc_has_function (enum function_class, const char *name); +extern bool no_c99_libc_has_function (enum function_class, const char *name); +extern bool gnu_libc_has_function (enum function_class, const char *name); +extern bool linux_libc_has_function (enum function_class, const char *name); + extern int default_address_cost (rtx, enum machine_mode, addr_space_t, bool); /* Output stack usage information. */ diff --git a/gcc/target.def b/gcc/target.def index bbda6c2..5d712b3 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -1373,6 +1373,15 @@ DEFHOOK unsigned int, (tree decl, const char *name, int reloc), default_section_type_flags) +DEFHOOK +(libc_has_function, + "This hook determines whether a function with name @var{name} from a class\n\ +of functions @var{fn_class} is present at the runtime. If the @var{name} is\n\ +the empty string, then this hook will check whether the class of functions\n\ +@var{fn_class} is generally present at the runtime.", + bool, (enum function_class fn_class, const char *name), + default_libc_has_function) + /* True if new jumps cannot be created, to replace existing ones or not, at the current point in the compilation. */ DEFHOOK diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 7a41cfe..f56cbcc 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -1409,7 +1409,8 @@ execute_cse_sincos (void) CASE_FLT_FN (BUILT_IN_SIN): CASE_FLT_FN (BUILT_IN_CEXPI): /* Make sure we have either sincos or cexp. */ - if (!TARGET_HAS_SINCOS && !TARGET_C99_FUNCTIONS) + if (!targetm.libc_has_function (function_c99_math_complex, "") + && !targetm.libc_has_function (function_sincos, "")) break; arg = gimple_call_arg (stmt, 0);