OSDN Git Service

* mathbuiltins.def: Do not defined huge_val built-in.
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 11 Sep 2010 16:34:20 +0000 (16:34 +0000)
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 11 Sep 2010 16:34:20 +0000 (16:34 +0000)
* 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

gcc/fortran/ChangeLog
gcc/fortran/f95-lang.c
gcc/fortran/mathbuiltins.def
gcc/fortran/trans-const.c
gcc/fortran/trans-const.h
gcc/fortran/trans-intrinsic.c

index a2916af..e7f79bd 100644 (file)
@@ -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.
index 8c957d2..d00b7f0 100644 (file)
@@ -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); 
index 660fee8..b3c5299 100644 (file)
@@ -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)
index 51bc020..3d8d4ef 100644 (file)
@@ -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
index 6cc71c5..8f56711 100644 (file)
@@ -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.  */
index f3aac9c..6e9bfaf 100644 (file)
@@ -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);