summaryrefslogtreecommitdiff
path: root/gcc/real.c
diff options
context:
space:
mode:
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2008-08-18 16:17:16 +0000
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2008-08-18 16:17:16 +0000
commit7910b2fb1b5a8fe594afe4094e3ebea9921d05c0 (patch)
treeb26d4ffa1048ebe26a04ba70bd16218610cb5cdc /gcc/real.c
parentfb715874822ac83ba6ee763c5e4af3751cc40db4 (diff)
downloadgcc-7910b2fb1b5a8fe594afe4094e3ebea9921d05c0.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139202 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/real.c')
-rw-r--r--gcc/real.c77
1 files changed, 46 insertions, 31 deletions
diff --git a/gcc/real.c b/gcc/real.c
index da311c8f67f..886f8b4ae2c 100644
--- a/gcc/real.c
+++ b/gcc/real.c
@@ -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. */