]> gcc.gnu.org Git - gcc.git/commitdiff
builtin-types.def (BT_FN_FLOAT): New.
authorRichard Henderson <rth@redhat.com>
Wed, 4 Sep 2002 23:21:28 +0000 (16:21 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Wed, 4 Sep 2002 23:21:28 +0000 (16:21 -0700)
        * builtin-types.def (BT_FN_FLOAT): New.
        (BT_FN_DOUBLE, BT_FN_LONG_DOUBLE): New.
        * builtins.def (BUILT_IN_INF, BUILT_IN_INFF, BUILT_IN_INFL,
        BUILT_IN_HUGE_VAL, BUILT_IN_HUGE_VALF, BUILT_IN_HUGE_VALL): New.
        * builtins.c (fold_builtin_inf): New.
        (fold_builtin): Call it.
        * real.c (ereal_inf): New.
        * real.h: Declare it.
        * doc/extend.texi: Document new builtins.

From-SVN: r56820

gcc/ChangeLog
gcc/builtin-types.def
gcc/builtins.c
gcc/builtins.def
gcc/doc/extend.texi
gcc/real.c
gcc/real.h

index d2d03983631ee971e10e1c44deb5ed44c276f628..02e70570894cd9a98b98ba3e3f4a040b3fe2e085 100644 (file)
@@ -1,3 +1,15 @@
+2002-09-04  Richard Henderson  <rth@redhat.com>
+
+       * builtin-types.def (BT_FN_FLOAT): New.
+       (BT_FN_DOUBLE, BT_FN_LONG_DOUBLE): New.
+       * builtins.def (BUILT_IN_INF, BUILT_IN_INFF, BUILT_IN_INFL,
+       BUILT_IN_HUGE_VAL, BUILT_IN_HUGE_VALF, BUILT_IN_HUGE_VALL): New.
+       * builtins.c (fold_builtin_inf): New.
+       (fold_builtin): Call it.
+       * real.c (ereal_inf): New.
+       * real.h: Declare it.
+       * doc/extend.texi: Document new builtins.
+
 2002-09-04  Richard Henderson  <rth@redhat.com>
 
        * cse.c (cse_insn): Avoid subreg games if the equivalence
index 7a33ffd78945b1592216a605082313c0efabdcf6..89bd500b84cb8baf6356cf8d0ae66c61f4222e6b 100644 (file)
@@ -84,6 +84,9 @@ DEF_PRIMITIVE_TYPE (BT_VALIST_ARG, va_list_arg_type_node)
 DEF_FUNCTION_TYPE_0 (BT_FN_VOID, BT_VOID)
 DEF_FUNCTION_TYPE_0 (BT_FN_PTR, BT_PTR)
 DEF_FUNCTION_TYPE_0 (BT_FN_UNSIGNED, BT_UNSIGNED)
+DEF_FUNCTION_TYPE_0 (BT_FN_FLOAT, BT_FLOAT)
+DEF_FUNCTION_TYPE_0 (BT_FN_DOUBLE, BT_DOUBLE)
+DEF_FUNCTION_TYPE_0 (BT_FN_LONG_DOUBLE, BT_LONG_DOUBLE)
 
 DEF_FUNCTION_TYPE_1 (BT_FN_LONG_LONG, BT_LONG, BT_LONG)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONGLONG_LONGLONG, BT_LONGLONG, BT_LONGLONG)
index b2ad5375b77101c08b84e79bed813801dc45ab35..7b2841bcae9ca3401804f0a25eaabdbf7254d615 100644 (file)
@@ -148,6 +148,7 @@ static tree stabilize_va_list               PARAMS ((tree, int));
 static rtx expand_builtin_expect       PARAMS ((tree, rtx));
 static tree fold_builtin_constant_p    PARAMS ((tree));
 static tree fold_builtin_classify_type PARAMS ((tree));
+static tree fold_builtin_inf           PARAMS ((tree, int));
 static tree build_function_call_expr   PARAMS ((tree, tree));
 static int validate_arglist            PARAMS ((tree, ...));
 
@@ -4132,6 +4133,19 @@ fold_builtin_classify_type (arglist)
   return build_int_2 (type_to_class (TREE_TYPE (TREE_VALUE (arglist))), 0);
 }
 
+/* Fold a call to __builtin_inf or __builtin_huge_val.  */
+
+static tree
+fold_builtin_inf (type, warn)
+     tree type;
+     int warn;
+{
+  if (!MODE_HAS_INFINITIES (TYPE_MODE (type)) && warn)
+    warning ("target format does not support infinity");
+
+  return build_real (type, ereal_inf (TYPE_MODE (type)));
+}
+
 /* Used by constant folding to eliminate some builtin calls early.  EXP is
    the CALL_EXPR of a call to a builtin function.  */
 
@@ -4163,6 +4177,16 @@ fold_builtin (exp)
        }
       break;
 
+    case BUILT_IN_INF:
+    case BUILT_IN_INFF:
+    case BUILT_IN_INFL:
+      return fold_builtin_inf (TREE_TYPE (TREE_TYPE (fndecl)), true);
+
+    case BUILT_IN_HUGE_VAL:
+    case BUILT_IN_HUGE_VALF:
+    case BUILT_IN_HUGE_VALL:
+      return fold_builtin_inf (TREE_TYPE (TREE_TYPE (fndecl)), false);
+
     default:
       break;
     }
index 978b4a70d55b2e78525ee47d110c1212e6185913..25ea430fd9ea9f9acab0e69b1f8aa981c1e840a4 100644 (file)
@@ -401,6 +401,32 @@ DEF_LIB_BUILTIN(BUILT_IN_LOGL,
                                   ? ATTR_CONST_NOTHROW_LIST
                                   : ATTR_PURE_NOTHROW_LIST))
 
+DEF_GCC_BUILTIN(BUILT_IN_INF,
+               "__builtin_inf",
+               BT_FN_DOUBLE,
+               ATTR_PURE_NOTHROW_LIST)
+DEF_GCC_BUILTIN(BUILT_IN_INFF,
+               "__builtin_inff",
+               BT_FN_FLOAT,
+               ATTR_PURE_NOTHROW_LIST)
+DEF_GCC_BUILTIN(BUILT_IN_INFL,
+               "__builtin_infl",
+               BT_FN_LONG_DOUBLE,
+               ATTR_PURE_NOTHROW_LIST)
+
+DEF_GCC_BUILTIN(BUILT_IN_HUGE_VAL,
+               "__builtin_huge_val",
+               BT_FN_DOUBLE,
+               ATTR_PURE_NOTHROW_LIST)
+DEF_GCC_BUILTIN(BUILT_IN_HUGE_VALF,
+               "__builtin_huge_valf",
+               BT_FN_FLOAT,
+               ATTR_PURE_NOTHROW_LIST)
+DEF_GCC_BUILTIN(BUILT_IN_HUGE_VALL,
+               "__builtin_huge_vall",
+               BT_FN_LONG_DOUBLE,
+               ATTR_PURE_NOTHROW_LIST)
+
 DEF_UNUSED_BUILTIN(BUILT_IN_GETEXP)
 DEF_UNUSED_BUILTIN(BUILT_IN_GETMAN)
 
index 631ed9f663f327f49191591ac82134f4eb29e740..ec33daa020bc1045060d80d31b03573cc62c0622 100644 (file)
@@ -4833,6 +4833,36 @@ is evaluated if it includes side effects but no other code is generated
 and GCC does not issue a warning.
 @end deftypefn
 
+@deftypefn {Built-in Function} double __builtin_huge_val (void)
+Returns a positive infinity, if supported by the floating-point format,
+else @code{DBL_MAX}.  This function is suitable for implementing the
+ISO C macro @code{HUGE_VAL}.
+@end deftypefn
+
+@deftypefn {Built-in Function} float __builtin_huge_valf (void)
+Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
+@end deftypefn
+
+@deftypefn {Built-in Function} long double __builtin_huge_vall (void)
+Similar to @code{__builtin_huge_val}, except the return
+type is @code{long double}.
+@end deftypefn
+
+@deftypefn {Built-in Function} double __builtin_inf (void)
+Similar to @code{__builtin_huge_val}, except a warning is generated
+if the target floating-point format does not support infinities.
+This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
+@end deftypefn
+
+@deftypefn {Built-in Function} float __builtin_inff (void)
+Similar to @code{__builtin_inf}, except the return type is @code{float}.
+@end deftypefn
+
+@deftypefn {Built-in Function} long double __builtin_infl (void)
+Similar to @code{__builtin_inf}, except the return
+type is @code{long double}.
+@end deftypefn
+
 @node Target Builtins
 @section Built-in Functions Specific to Particular Target Machines
 
index 019821df4085dd8022f951168ef8168696fc6e7b..077e313f3490a2e2823f4da1e57b2f008b383e6f 100644 (file)
@@ -1818,8 +1818,8 @@ eisnan (x)
   return (0);
 }
 
-/*  Fill e-type number X with infinity pattern (IEEE)
-    or largest possible number (non-IEEE).  */
+/* Fill e-type number X with infinity pattern (IEEE)
+   or largest possible number (non-IEEE).  */
 
 static void
 einfin (x)
@@ -1860,6 +1860,49 @@ einfin (x)
 #endif
 }
 
+/* Similar, except return it as a REAL_VALUE_TYPE.  */
+
+REAL_VALUE_TYPE
+ereal_inf (mode)
+     enum machine_mode mode;
+{
+  REAL_VALUE_TYPE r;
+  UEMUSHORT e[NE];
+  int prec, rndsav;
+
+  switch (mode)
+    {
+    case QFmode:
+    case SFmode:
+      prec = 24;
+      break;
+    case HFmode:
+    case DFmode:
+      prec = 53;
+      break;
+    case TFmode:
+      if (!INTEL_EXTENDED_IEEE_FORMAT)
+       {
+         prec = 113;
+         break;
+       }
+      /* FALLTHRU */
+    case XFmode:
+      prec = 64;
+      break;
+    default:
+      abort ();
+    }
+
+  rndsav = rndprc;
+  rndprc = prec;
+  einfin (e);
+  rndprc = rndsav;
+
+  PUT_REAL (e, &r);
+  return r;
+}
+
 /* Output an e-type NaN.
    This generates Intel's quiet NaN pattern for extended real.
    The exponent is 7fff, the leading mantissa word is c000.  */
index cf5fdf21aebeaf5621a8377dc7182653ab992b92..f4265826ce952dc0327d557895f526f1e3858f7b 100644 (file)
@@ -292,6 +292,7 @@ extern int target_isinf             PARAMS ((REAL_VALUE_TYPE));
 extern int target_negative     PARAMS ((REAL_VALUE_TYPE));
 extern void debug_real         PARAMS ((REAL_VALUE_TYPE));
 extern REAL_VALUE_TYPE ereal_atof PARAMS ((const char *, enum machine_mode));
+extern REAL_VALUE_TYPE ereal_inf PARAMS ((enum machine_mode));
 
 /* In tree.c: wrap up a REAL_VALUE_TYPE in a tree node.  */
 extern tree build_real                 PARAMS ((tree, REAL_VALUE_TYPE));
This page took 0.108895 seconds and 5 git commands to generate.