diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2008-08-18 16:17:16 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2008-08-18 16:17:16 +0000 |
commit | 9c02cf684cc13bf6b9e88a5a55b02bc2ccac7a7a (patch) | |
tree | b26d4ffa1048ebe26a04ba70bd16218610cb5cdc /gcc/real.c | |
parent | e46587281e54e3a8f1eedd70bc322b53cb1fbdcd (diff) | |
download | gcc-9c02cf684cc13bf6b9e88a5a55b02bc2ccac7a7a.zip gcc-9c02cf684cc13bf6b9e88a5a55b02bc2ccac7a7a.tar.gz gcc-9c02cf684cc13bf6b9e88a5a55b02bc2ccac7a7a.tar.bz2 |
real.h (dconst_e, [...]): Declare.
2008-08-18 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
* real.h (dconst_e, dconst_third, dconst_sqrt2, dconst_e_ptr,
dconst_third_ptr, dconst_sqrt2_ptr): Declare.
(enum real_value_const): Delete.
(get_real_const): Delete.
* real.c (get_real_const): Delete.
(dconst_e_ptr): Define.
(dconst_third_ptr): Define.
(dconst_sqrt2_ptr): Define.
* builtins.c: Update all callers.
From-SVN: r139202
Diffstat (limited to 'gcc/real.c')
-rw-r--r-- | gcc/real.c | 77 |
1 files changed, 46 insertions, 31 deletions
@@ -2225,47 +2225,62 @@ times_pten (REAL_VALUE_TYPE *r, int exp) do_divide (r, r, &pten); } -/* Returns the special REAL_VALUE_TYPE enumerated by E. */ +/* Returns the special REAL_VALUE_TYPE corresponding to 'e'. */ const REAL_VALUE_TYPE * -get_real_const (enum real_value_const e) +dconst_e_ptr (void) { - static REAL_VALUE_TYPE value[rv_max]; + static REAL_VALUE_TYPE value; - gcc_assert (e < rv_max); + /* Initialize mathematical constants for constant folding builtins. + These constants need to be given to at least 160 bits precision. */ + if (value.cl == rvc_zero) + { + mpfr_t m; + mpfr_init2 (m, SIGNIFICAND_BITS); + mpfr_set_ui (m, 1, GMP_RNDN); + mpfr_exp (m, m, GMP_RNDN); + real_from_mpfr (&value, m, NULL_TREE, GMP_RNDN); + mpfr_clear (m); + + } + return &value; +} + +/* Returns the special REAL_VALUE_TYPE corresponding to 1/3. */ + +const REAL_VALUE_TYPE * +dconst_third_ptr (void) +{ + static REAL_VALUE_TYPE value; /* Initialize mathematical constants for constant folding builtins. These constants need to be given to at least 160 bits precision. */ - if (value[e].cl == rvc_zero) - switch (e) + if (value.cl == rvc_zero) { - case rv_e: - { - mpfr_t m; - mpfr_init2 (m, SIGNIFICAND_BITS); - mpfr_set_ui (m, 1, GMP_RNDN); - mpfr_exp (m, m, GMP_RNDN); - real_from_mpfr (&value[e], m, NULL_TREE, GMP_RNDN); - mpfr_clear (m); - } - break; - case rv_third: - real_arithmetic (&value[e], RDIV_EXPR, &dconst1, real_digit (3)); - break; - case rv_sqrt2: - { - mpfr_t m; - mpfr_init2 (m, SIGNIFICAND_BITS); - mpfr_sqrt_ui (m, 2, GMP_RNDN); - real_from_mpfr (&value[e], m, NULL_TREE, GMP_RNDN); - mpfr_clear (m); - } - break; - default: - gcc_unreachable(); + real_arithmetic (&value, RDIV_EXPR, &dconst1, real_digit (3)); } + return &value; +} + +/* Returns the special REAL_VALUE_TYPE corresponding to sqrt(2). */ - return &value[e]; +const REAL_VALUE_TYPE * +dconst_sqrt2_ptr (void) +{ + static REAL_VALUE_TYPE value; + + /* Initialize mathematical constants for constant folding builtins. + These constants need to be given to at least 160 bits precision. */ + if (value.cl == rvc_zero) + { + mpfr_t m; + mpfr_init2 (m, SIGNIFICAND_BITS); + mpfr_sqrt_ui (m, 2, GMP_RNDN); + real_from_mpfr (&value, m, NULL_TREE, GMP_RNDN); + mpfr_clear (m); + } + return &value; } /* Fills R with +Inf. */ |