aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/f95-lang.c
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2014-10-09 09:47:25 +0000
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2014-10-09 09:47:25 +0000
commit3b7ea188c0457b2e70bdefc8cb53a790e7e9b296 (patch)
tree50e92902ab44fae4fa8b683d332d148d1627916f /gcc/fortran/f95-lang.c
parentf9d29866b5bdf7d42d974dc3f91fb2bd834354db (diff)
downloadgcc-3b7ea188c0457b2e70bdefc8cb53a790e7e9b296.zip
gcc-3b7ea188c0457b2e70bdefc8cb53a790e7e9b296.tar.gz
gcc-3b7ea188c0457b2e70bdefc8cb53a790e7e9b296.tar.bz2
f95-lang.c (gfc_init_builtin_functions): Add more floating-point built-ins.
* f95-lang.c (gfc_init_builtin_functions): Add more floating-point built-ins. * mathbuiltins.def (OTHER_BUILTIN): Define built-ins for logb, remainder, rint and signbit. * trans-decl.c (save_fp_state, restore_fp_state): Move to trans-intrinsic.c (gfc_generate_function_code): Use new names for these two functions. * trans-expr.c (gfc_conv_function_expr): Catch IEEE functions to emit code from the front-end. * trans-intrinsic.c (gfc_save_fp_state, gfc_restore_fp_state, conv_ieee_function_args, conv_intrinsic_ieee_builtin, conv_intrinsic_ieee_is_normal, conv_intrinsic_ieee_is_negative, conv_intrinsic_ieee_logb_rint, conv_intrinsic_ieee_rem, conv_intrinsic_ieee_next_after, conv_intrinsic_ieee_scalb, conv_intrinsic_ieee_copy_sign, gfc_conv_ieee_arithmetic_function): New functions. * trans.h (gfc_conv_ieee_arithmetic_function, gfc_save_fp_state, gfc_restore_fp_state): New prototypes. * ieee/ieee_helper.c (ieee_is_finite_*, ieee_is_nan_*, ieee_is_negative_*, ieee_is_normal_*, ieee_copy_sign_*, ieee_unordered_*, ieee_logb_*, ieee_rint_*, ieee_scalb_*, ieee_rem_*, ieee_next_after_*): Remove functions. * gfortran.map (GFORTRAN_1.5): Remove corresponding symbols. From-SVN: r216036
Diffstat (limited to 'gcc/fortran/f95-lang.c')
-rw-r--r--gcc/fortran/f95-lang.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c
index 8e8591a..66cd3a3 100644
--- a/gcc/fortran/f95-lang.c
+++ b/gcc/fortran/f95-lang.c
@@ -563,6 +563,7 @@ gfc_builtin_function (tree decl)
#define ATTR_NOTHROW_LEAF_LIST (ECF_NOTHROW | ECF_LEAF)
#define ATTR_NOTHROW_LEAF_MALLOC_LIST (ECF_NOTHROW | ECF_LEAF | ECF_MALLOC)
#define ATTR_CONST_NOTHROW_LEAF_LIST (ECF_NOTHROW | ECF_LEAF | ECF_CONST)
+#define ATTR_PURE_NOTHROW_LEAF_LIST (ECF_NOTHROW | ECF_LEAF | ECF_PURE)
#define ATTR_NOTHROW_LIST (ECF_NOTHROW)
#define ATTR_CONST_NOTHROW_LIST (ECF_NOTHROW | ECF_CONST)
@@ -683,6 +684,8 @@ gfc_init_builtin_functions (void)
tree ftype, ptype;
tree builtin_types[(int) BT_LAST + 1];
+ int attr;
+
build_builtin_fntypes (mfunc_float, float_type_node);
build_builtin_fntypes (mfunc_double, double_type_node);
build_builtin_fntypes (mfunc_longdouble, long_double_type_node);
@@ -770,6 +773,32 @@ gfc_init_builtin_functions (void)
BUILT_IN_NEXTAFTERF, "nextafterf",
ATTR_CONST_NOTHROW_LEAF_LIST);
+ /* Some built-ins depend on rounding mode. Depending on compilation options, they
+ will be "pure" or "const". */
+ attr = flag_rounding_math ? ATTR_PURE_NOTHROW_LEAF_LIST : ATTR_CONST_NOTHROW_LEAF_LIST;
+
+ gfc_define_builtin ("__builtin_rintl", mfunc_longdouble[0],
+ BUILT_IN_RINTL, "rintl", attr);
+ gfc_define_builtin ("__builtin_rint", mfunc_double[0],
+ BUILT_IN_RINT, "rint", attr);
+ gfc_define_builtin ("__builtin_rintf", mfunc_float[0],
+ BUILT_IN_RINTF, "rintf", attr);
+
+ gfc_define_builtin ("__builtin_remainderl", mfunc_longdouble[1],
+ BUILT_IN_REMAINDERL, "remainderl", attr);
+ gfc_define_builtin ("__builtin_remainder", mfunc_double[1],
+ BUILT_IN_REMAINDER, "remainder", attr);
+ gfc_define_builtin ("__builtin_remainderf", mfunc_float[1],
+ BUILT_IN_REMAINDERF, "remainderf", attr);
+
+ gfc_define_builtin ("__builtin_logbl", mfunc_longdouble[0],
+ BUILT_IN_LOGBL, "logbl", ATTR_CONST_NOTHROW_LEAF_LIST);
+ gfc_define_builtin ("__builtin_logb", mfunc_double[0],
+ BUILT_IN_LOGB, "logb", ATTR_CONST_NOTHROW_LEAF_LIST);
+ gfc_define_builtin ("__builtin_logbf", mfunc_float[0],
+ BUILT_IN_LOGBF, "logbf", ATTR_CONST_NOTHROW_LEAF_LIST);
+
+
gfc_define_builtin ("__builtin_frexpl", mfunc_longdouble[4],
BUILT_IN_FREXPL, "frexpl", ATTR_NOTHROW_LEAF_LIST);
gfc_define_builtin ("__builtin_frexp", mfunc_double[4],
@@ -960,6 +989,34 @@ gfc_init_builtin_functions (void)
void_type_node, NULL_TREE);
gfc_define_builtin ("__builtin_isnan", ftype, BUILT_IN_ISNAN,
"__builtin_isnan", ATTR_CONST_NOTHROW_LEAF_LIST);
+ gfc_define_builtin ("__builtin_isfinite", ftype, BUILT_IN_ISFINITE,
+ "__builtin_isfinite", ATTR_CONST_NOTHROW_LEAF_LIST);
+ gfc_define_builtin ("__builtin_isnormal", ftype, BUILT_IN_ISNORMAL,
+ "__builtin_isnormal", ATTR_CONST_NOTHROW_LEAF_LIST);
+
+ ftype = build_function_type_list (integer_type_node, void_type_node,
+ void_type_node, NULL_TREE);
+ gfc_define_builtin ("__builtin_isunordered", ftype, BUILT_IN_ISUNORDERED,
+ "__builtin_isunordered", ATTR_CONST_NOTHROW_LEAF_LIST);
+ gfc_define_builtin ("__builtin_islessequal", ftype, BUILT_IN_ISLESSEQUAL,
+ "__builtin_islessequal", ATTR_CONST_NOTHROW_LEAF_LIST);
+ gfc_define_builtin ("__builtin_isgreaterequal", ftype,
+ BUILT_IN_ISGREATEREQUAL, "__builtin_isgreaterequal",
+ ATTR_CONST_NOTHROW_LEAF_LIST);
+
+ ftype = build_function_type_list (integer_type_node,
+ float_type_node, NULL_TREE);
+ gfc_define_builtin("__builtin_signbitf", ftype, BUILT_IN_SIGNBITF,
+ "signbitf", ATTR_CONST_NOTHROW_LEAF_LIST);
+ ftype = build_function_type_list (integer_type_node,
+ double_type_node, NULL_TREE);
+ gfc_define_builtin("__builtin_signbit", ftype, BUILT_IN_SIGNBIT,
+ "signbit", ATTR_CONST_NOTHROW_LEAF_LIST);
+ ftype = build_function_type_list (integer_type_node,
+ long_double_type_node, NULL_TREE);
+ gfc_define_builtin("__builtin_signbitl", ftype, BUILT_IN_SIGNBITL,
+ "signbitl", ATTR_CONST_NOTHROW_LEAF_LIST);
+
#define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \
builtin_types[(int) ENUM] = VALUE;