diff options
author | Richard Henderson <rth@redhat.com> | 2002-09-16 18:28:50 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2002-09-16 18:28:50 -0700 |
commit | 1472e41cb31db005533692d13c807503f39f1408 (patch) | |
tree | 13b37fe93a02d7ab652503bcdc4b3b55cdb5e3d6 /gcc/builtins.c | |
parent | f354b82835d441a9430484561f45ad2cfff6d0bc (diff) | |
download | gcc-1472e41cb31db005533692d13c807503f39f1408.zip gcc-1472e41cb31db005533692d13c807503f39f1408.tar.gz gcc-1472e41cb31db005533692d13c807503f39f1408.tar.bz2 |
builtin-types.def (BT_FN_FLOAT_CONST_STRING): New.
gcc/
* builtin-types.def (BT_FN_FLOAT_CONST_STRING): New.
(BT_FN_DOUBLE_CONST_STRING, BT_FN_LONG_DOUBLE_CONST_STRING): New.
* builtins.def (__builtin_nan, __builtin_nanf, __builtin_nanl): New.
(__builtin_nans, __builtin_nansf, __builtin_nansl): New.
* builtins.c (fold_builtin_nan): New.
(fold_builtin): Call it.
* real.c (real_nan): Parse a non-empty string.
(round_for_format): Fix NaN significand truncation.
* real.h (real_nan): Return bool.
* doc/extend.texi: Document new builtins.
libstdc++/
* include/std/std_limits.h (__glibcpp_f32_QNaN_bytes,
__glibcpp_f32_has_QNaN, __glibcpp_f32_SNaN_bytes,
__glibcpp_f32_has_SNaN, __glibcpp_f64_QNaN_bytes,
__glibcpp_f64_has_QNaN, __glibcpp_f64_SNaN_bytes,
__glibcpp_f64_has_SNaN, __glibcpp_f80_QNaN_bytes,
__glibcpp_f80_has_QNaN, __glibcpp_f80_SNaN_bytes,
__glibcpp_f80_has_SNaN, __glibcpp_f96_QNaN_bytes,
__glibcpp_f96_has_QNaN, __glibcpp_f96_SNaN_bytes,
__glibcpp_f96_has_SNaN, __glibcpp_f128_QNaN_bytes,
__glibcpp_f128_has_QNaN, __glibcpp_f128_SNaN_bytes,
__glibcpp_f128_has_SNaN, __glibcpp_float_QNaN_bytes,
__glibcpp_float_has_QNaN, __glibcpp_float_SNaN_bytes,
__glibcpp_float_has_SNaN, __glibcpp_double_QNaN_bytes,
__glibcpp_double_has_QNaN, __glibcpp_double_SNaN_bytes,
__glibcpp_double_has_SNaN, __glibcpp_long_double_QNaN_bytes,
__glibcpp_long_double_has_QNaN, __glibcpp_long_double_SNaN_bytes,
__glibcpp_long_double_has_SNaN): Remove.
(__glibcpp_f128_is_iec559): True if IEEE.
(__glibcpp_float_QNaN, __glibcpp_float_SNaN): Remove.
(__glibcpp_double_QNaN, __glibcpp_double_SNaN): Remove.
(__glibcpp_long_double_QNaN, __glibcpp_long_double_SNaN): Remove.
(std::numeric_limits<float>::has_quiet_NaN): Use __builtin_nanf.
(std::numeric_limits<float>::has_signaling_NaN): Mirror has_quiet_NaN.
(std::numeric_limits<float>::quiet_NaN): Use __builtin_nanf.
(std::numeric_limits<float>::signaling_NaN): Use __builtin_nansf.
(std::numeric_limits<double>): Similarly.
(std::numeric_limits<long double>): Similarly.
* src/limits.cc (__glibcpp_float_QNaN, __glibcpp_float_SNaN): Remove.
(__glibcpp_double_QNaN, __glibcpp_double_SNaN): Remove.
(__glibcpp_long_double_QNaN, __glibcpp_long_double_SNaN): Remove.
* testsuite/18_support/numeric_limits.cc (test_infinity): New.
(test_denorm_min, test_qnan, test_is_iec559): New.
From-SVN: r57221
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 2e7cd53..25fadab 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -149,6 +149,7 @@ 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 fold_builtin_nan PARAMS ((tree, tree, int)); static tree build_function_call_expr PARAMS ((tree, tree)); static int validate_arglist PARAMS ((tree, ...)); @@ -4149,6 +4150,28 @@ fold_builtin_inf (type, warn) return build_real (type, real); } +/* Fold a call to __builtin_nan or __builtin_nans. */ + +static tree +fold_builtin_nan (arglist, type, quiet) + tree arglist, type; + int quiet; +{ + REAL_VALUE_TYPE real; + const char *str; + + if (!validate_arglist (arglist, POINTER_TYPE, VOID_TYPE)) + return 0; + str = c_getstr (TREE_VALUE (arglist)); + if (!str) + return 0; + + if (!real_nan (&real, str, quiet, TYPE_MODE (type))) + return 0; + + return build_real (type, real); +} + /* Used by constant folding to eliminate some builtin calls early. EXP is the CALL_EXPR of a call to a builtin function. */ @@ -4190,6 +4213,16 @@ fold_builtin (exp) case BUILT_IN_HUGE_VALL: return fold_builtin_inf (TREE_TYPE (TREE_TYPE (fndecl)), false); + case BUILT_IN_NAN: + case BUILT_IN_NANF: + case BUILT_IN_NANL: + return fold_builtin_nan (arglist, TREE_TYPE (TREE_TYPE (fndecl)), true); + + case BUILT_IN_NANS: + case BUILT_IN_NANSF: + case BUILT_IN_NANSL: + return fold_builtin_nan (arglist, TREE_TYPE (TREE_TYPE (fndecl)), false); + default: break; } |