This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH]: Add __builtin_fpclassify()
On Fri, 23 May 2008, Paolo Carlini wrote:
> Hi Kaveh,
> > Okay, here's what I installed after retesting:
> >
> First, many thanks. Not a substantive issue, but, when I put to use your
> work in the library, I found a little misleading the repeated mention of
> FP_INF, whereas the C99 macro is called FP_INFINITE, maybe you want to
> adjust some comments...
> Thank again,
> Paolo.
Oh blurg. Obvious patch below will be installed after testing. Thanks
for catching that.
--Kaveh
2008-05-23 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* builtins.c (fold_builtin_fpclassify): Fix spelling of FP_INFINITE.
* doc/extend.texi: Likewise.
testsuite:
* gcc.dg/tg-tests.h: Fix spelling of FP_INFINITE.
diff -rup orig/egcc-SVN20080523/gcc/builtins.c egcc-SVN20080523/gcc/builtins.c
--- orig/egcc-SVN20080523/gcc/builtins.c 2008-05-23 18:11:06.000000000 +0200
+++ egcc-SVN20080523/gcc/builtins.c 2008-05-23 18:14:29.000000000 +0200
@@ -9748,14 +9748,15 @@ fold_builtin_classify (tree fndecl, tree
This builtin will generate code to return the appropriate floating
point classification depending on the value of the floating point
number passed in. The possible return values must be supplied as
- int arguments to the call in the following order: FP_NAN, FP_INF,
+ int arguments to the call in the following order: FP_NAN, FP_INFINITE,
FP_NORMAL, FP_SUBNORMAL and FP_ZERO. The ellipses is for exactly
one floating point argument which is "type generic". */
static tree
fold_builtin_fpclassify (tree exp)
{
- tree fp_nan, fp_inf, fp_normal, fp_subnormal, fp_zero, arg, type, res, tmp;
+ tree fp_nan, fp_infinite, fp_normal, fp_subnormal, fp_zero,
+ arg, type, res, tmp;
enum machine_mode mode;
REAL_VALUE_TYPE r;
char buf[128];
@@ -9767,7 +9768,7 @@ fold_builtin_fpclassify (tree exp)
return NULL_TREE;
fp_nan = CALL_EXPR_ARG (exp, 0);
- fp_inf = CALL_EXPR_ARG (exp, 1);
+ fp_infinite = CALL_EXPR_ARG (exp, 1);
fp_normal = CALL_EXPR_ARG (exp, 2);
fp_subnormal = CALL_EXPR_ARG (exp, 3);
fp_zero = CALL_EXPR_ARG (exp, 4);
@@ -9778,7 +9779,7 @@ fold_builtin_fpclassify (tree exp)
/* fpclassify(x) ->
isnan(x) ? FP_NAN :
- (fabs(x) == Inf ? FP_INF :
+ (fabs(x) == Inf ? FP_INFINITE :
(fabs(x) >= DBL_MIN ? FP_NORMAL :
(x == 0 ? FP_ZERO : FP_SUBNORMAL))). */
@@ -9796,7 +9797,7 @@ fold_builtin_fpclassify (tree exp)
real_inf (&r);
tmp = fold_build2 (EQ_EXPR, integer_type_node, arg,
build_real (type, r));
- res = fold_build3 (COND_EXPR, integer_type_node, tmp, fp_inf, res);
+ res = fold_build3 (COND_EXPR, integer_type_node, tmp, fp_infinite, res);
}
if (HONOR_NANS (mode))
diff -rup orig/egcc-SVN20080523/gcc/doc/extend.texi egcc-SVN20080523/gcc/doc/extend.texi
--- orig/egcc-SVN20080523/gcc/doc/extend.texi 2008-05-23 18:11:04.000000000 +0200
+++ egcc-SVN20080523/gcc/doc/extend.texi 2008-05-23 18:16:47.000000000 +0200
@@ -6561,7 +6561,7 @@ This built-in implements the C99 fpclass
five int arguments should be the target library's notion of the
possible FP classes and are used for return values. They must be
constant values and they must appear in this order: @code{FP_NAN},
-@code{FP_INF}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
+@code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
@code{FP_ZERO}. The ellipsis is for exactly one floating point value
to classify. GCC treats the last argument as type-generic, which
means it does not do default promotion from float to double.
diff -rup orig/egcc-SVN20080523/gcc/testsuite/gcc.dg/tg-tests.h egcc-SVN20080523/gcc/testsuite/gcc.dg/tg-tests.h
--- orig/egcc-SVN20080523/gcc/testsuite/gcc.dg/tg-tests.h 2008-05-23 18:11:05.000000000 +0200
+++ egcc-SVN20080523/gcc/testsuite/gcc.dg/tg-tests.h 2008-05-23 18:15:50.000000000 +0200
@@ -1,11 +1,11 @@
/* Test various type-generic builtins by calling "main_tests()". */
#define FP_NAN 1
-#define FP_INF 2
+#define FP_INFINITE 2
#define FP_NORMAL 3
#define FP_SUBNORMAL 4
#define FP_ZERO 5
-#define fpclassify(X) __builtin_fpclassify(FP_NAN, FP_INF, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (X))
+#define fpclassify(X) __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (X))
void __attribute__ ((__noinline__))
foo_1 (float f, double d, long double ld,
@@ -118,7 +118,7 @@ main_tests (void)
/* Test infinity. */
f = __builtin_inff(); d = __builtin_inf(); ld = __builtin_infl();
- foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 1, /*isfin=*/ 0, /*isnorm=*/ 0, FP_INF);
+ foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 1, /*isfin=*/ 0, /*isnorm=*/ 0, FP_INFINITE);
/* Test zero. */
f = 0; d = 0; ld = 0;
@@ -142,7 +142,7 @@ main_tests (void)
/* Test overflow values. */
f = __FLT_MAX__*2; d = __DBL_MAX__*2; ld = __LDBL_MAX__*2;
- foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 1, /*isfin=*/ 0, /*isnorm=*/ 0, FP_INF);
+ foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 1, /*isfin=*/ 0, /*isnorm=*/ 0, FP_INFINITE);
return 0;
}