summaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-11 16:34:20 +0000
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-11 16:34:20 +0000
commit729e6db2a99db15d9918b49ec10f32472957c83f (patch)
tree615287f513f3d8f71931077bb3135b6eaeffadc3 /gcc/fortran
parent0ed2724e7288ffd5f86615389965c5b233069448 (diff)
downloadgcc-729e6db2a99db15d9918b49ec10f32472957c83f.tar.gz
* mathbuiltins.def: Do not defined huge_val built-in.
* trans-const.c (gfc_build_inf_or_huge): New function. * trans-const.h (gfc_build_inf_or_huge): New prototype. * f95-lang.c (gfc_init_builtin_functions): Don't defined huge_val built-ins. * trans-intrinsic.c (gfc_build_intrinsic_lib_fndecls): We don't have functions of type (*) (void) anymore. (gfc_conv_intrinsic_minmaxloc): Call gfc_build_inf_or_huge. (gfc_conv_intrinsic_nearest): Call gfc_build_inf_or_huge instead of generating a call to huge_val(). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164216 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog13
-rw-r--r--gcc/fortran/f95-lang.c7
-rw-r--r--gcc/fortran/mathbuiltins.def1
-rw-r--r--gcc/fortran/trans-const.c20
-rw-r--r--gcc/fortran/trans-const.h4
-rw-r--r--gcc/fortran/trans-intrinsic.c22
6 files changed, 43 insertions, 24 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index a2916af1aba..e7f79bdedae 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,16 @@
+2010-09-11 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ * mathbuiltins.def: Do not defined huge_val built-in.
+ * trans-const.c (gfc_build_inf_or_huge): New function.
+ * trans-const.h (gfc_build_inf_or_huge): New prototype.
+ * f95-lang.c (gfc_init_builtin_functions): Don't defined
+ huge_val built-ins.
+ * trans-intrinsic.c (gfc_build_intrinsic_lib_fndecls): We don't
+ have functions of type (*) (void) anymore.
+ (gfc_conv_intrinsic_minmaxloc): Call gfc_build_inf_or_huge.
+ (gfc_conv_intrinsic_nearest): Call gfc_build_inf_or_huge instead
+ of generating a call to huge_val().
+
2010-09-11 Mikael Morin <mikael@gcc.gnu.org>
* gfortran.h (gfc_expr): Remove inline_noncopying_intrinsic attribute.
diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c
index 8c957d2d141..d00b7f0df50 100644
--- a/gcc/fortran/f95-lang.c
+++ b/gcc/fortran/f95-lang.c
@@ -856,13 +856,6 @@ gfc_init_builtin_functions (void)
gfc_define_builtin ("__builtin_fmodf", mfunc_float[1],
BUILT_IN_FMODF, "fmodf", true);
- gfc_define_builtin ("__builtin_huge_vall", mfunc_longdouble[3],
- BUILT_IN_HUGE_VALL, "__builtin_huge_vall", true);
- gfc_define_builtin ("__builtin_huge_val", mfunc_double[3],
- BUILT_IN_HUGE_VAL, "__builtin_huge_val", true);
- gfc_define_builtin ("__builtin_huge_valf", mfunc_float[3],
- BUILT_IN_HUGE_VALF, "__builtin_huge_valf", true);
-
/* lround{f,,l} and llround{f,,l} */
ftype = build_function_type_list (long_integer_type_node,
float_type_node, NULL_TREE);
diff --git a/gcc/fortran/mathbuiltins.def b/gcc/fortran/mathbuiltins.def
index 660fee8ec37..b3c52997a7f 100644
--- a/gcc/fortran/mathbuiltins.def
+++ b/gcc/fortran/mathbuiltins.def
@@ -62,7 +62,6 @@ OTHER_BUILTIN (CPOW, "cpow", cpow, true)
OTHER_BUILTIN (FABS, "fabs", 1, true)
OTHER_BUILTIN (FMOD, "fmod", 2, true)
OTHER_BUILTIN (FREXP, "frexp", frexp, false)
-OTHER_BUILTIN (HUGE_VAL, "huge_val", 0, true)
OTHER_BUILTIN (LLROUND, "llround", llround, true)
OTHER_BUILTIN (LROUND, "lround", lround, true)
OTHER_BUILTIN (NEXTAFTER, "nextafter", 2, true)
diff --git a/gcc/fortran/trans-const.c b/gcc/fortran/trans-const.c
index 51bc0201118..3d8d4ef8e7d 100644
--- a/gcc/fortran/trans-const.c
+++ b/gcc/fortran/trans-const.c
@@ -235,6 +235,26 @@ gfc_conv_mpfr_to_tree (mpfr_t f, int kind, int is_snan)
return build_real (type, real);
}
+/* Returns a real constant that is +Infinity if the target
+ supports infinities for this floating-point mode, and
+ +HUGE_VAL otherwise (the largest representable number). */
+
+tree
+gfc_build_inf_or_huge (tree type, int kind)
+{
+ if (HONOR_INFINITIES (TYPE_MODE (type)))
+ {
+ REAL_VALUE_TYPE real;
+ real_inf (&real);
+ return build_real (type, real);
+ }
+ else
+ {
+ int k = gfc_validate_kind (BT_REAL, kind, false);
+ return gfc_conv_mpfr_to_tree (gfc_real_kinds[k].huge, kind, 0);
+ }
+}
+
/* Converts a backend tree into a real constant. */
void
diff --git a/gcc/fortran/trans-const.h b/gcc/fortran/trans-const.h
index 6cc71c5faad..8f567116ee3 100644
--- a/gcc/fortran/trans-const.h
+++ b/gcc/fortran/trans-const.h
@@ -27,6 +27,10 @@ void gfc_conv_tree_to_mpz (mpz_t, tree);
tree gfc_conv_mpfr_to_tree (mpfr_t, int, int);
void gfc_conv_tree_to_mpfr (mpfr_ptr, tree);
+/* Build a tree containing a real infinity (or HUGE if infinities are
+ not supported for the given type. */
+tree gfc_build_inf_or_huge (tree, int);
+
/* Build a tree for a constant. Must be an EXPR_CONSTANT gfc_expr.
For CHARACTER literal constants, the caller still has to set the
string length as a separate operation. */
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index f3aac9c7529..6e9bfaf8b36 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -621,13 +621,11 @@ gfc_build_intrinsic_lib_fndecls (void)
C99-like library functions. For now, we only handle __float128
q-suffixed functions. */
- tree tmp, func_0, func_1, func_2, func_cabs, func_frexp;
+ tree tmp, func_1, func_2, func_cabs, func_frexp;
tree func_lround, func_llround, func_scalbn, func_cpow;
memset (quad_decls, 0, sizeof(tree) * (END_BUILTINS + 1));
- /* type (*) (void) */
- func_0 = build_function_type (float128_type_node, void_list_node);
/* type (*) (type) */
tmp = tree_cons (NULL_TREE, float128_type_node, void_list_node);
func_1 = build_function_type (float128_type_node, tmp);
@@ -2490,22 +2488,14 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op)
}
limit = gfc_create_var (gfc_typenode_for_spec (&arrayexpr->ts), "limit");
- n = gfc_validate_kind (arrayexpr->ts.type, arrayexpr->ts.kind, false);
switch (arrayexpr->ts.type)
{
case BT_REAL:
- if (HONOR_INFINITIES (DECL_MODE (limit)))
- {
- REAL_VALUE_TYPE real;
- real_inf (&real);
- tmp = build_real (TREE_TYPE (limit), real);
- }
- else
- tmp = gfc_conv_mpfr_to_tree (gfc_real_kinds[n].huge,
- arrayexpr->ts.kind, 0);
+ tmp = gfc_build_inf_or_huge (TREE_TYPE (limit), arrayexpr->ts.kind);
break;
case BT_INTEGER:
+ n = gfc_validate_kind (arrayexpr->ts.type, arrayexpr->ts.kind, false);
tmp = gfc_conv_mpz_to_tree (gfc_integer_kinds[n].huge,
arrayexpr->ts.kind);
break;
@@ -4242,12 +4232,12 @@ gfc_conv_intrinsic_nearest (gfc_se * se, gfc_expr * expr)
nextafter = gfc_builtin_decl_for_float_kind (BUILT_IN_NEXTAFTER, expr->ts.kind);
copysign = gfc_builtin_decl_for_float_kind (BUILT_IN_COPYSIGN, expr->ts.kind);
- huge_val = gfc_builtin_decl_for_float_kind (BUILT_IN_HUGE_VAL, expr->ts.kind);
type = gfc_typenode_for_spec (&expr->ts);
gfc_conv_intrinsic_function_args (se, expr, args, 2);
- tmp = build_call_expr_loc (input_location, copysign, 2,
- build_call_expr_loc (input_location, huge_val, 0),
+
+ huge_val = gfc_build_inf_or_huge (type, expr->ts.kind);
+ tmp = build_call_expr_loc (input_location, copysign, 2, huge_val,
fold_convert (type, args[1]));
se->expr = build_call_expr_loc (input_location, nextafter, 2,
fold_convert (type, args[0]), tmp);