From 354ec538057abddc8b757c5b0ba8e3c15115438b Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Sun, 24 Aug 2008 00:19:59 +0000 Subject: [PATCH] more tarval cleanup [r21396] --- ir/common/firm.c | 2 +- ir/tv/fltcalc.c | 8 ++++---- ir/tv/tv.c | 8 +++----- ir/tv/tv_t.h | 7 +++++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ir/common/firm.c b/ir/common/firm.c index 7ebdf3ee0..97edf99ab 100644 --- a/ir/common/firm.c +++ b/ir/common/firm.c @@ -114,7 +114,7 @@ void init_firm(const firm_parameter_t *param) /* create the type kinds. */ init_tpop(); /* create an obstack and put all tarvals in a pdeq */ - init_tarval_1(0l); + init_tarval_1(0l, /* support_quad_precision */0); /* Builds a basic program representation, so modes can be added. */ init_irprog_1(); /* initialize all modes an ir node can consist of */ diff --git a/ir/tv/fltcalc.c b/ir/tv/fltcalc.c index 8938cdc47..7d20bab5b 100644 --- a/ir/tv/fltcalc.c +++ b/ir/tv/fltcalc.c @@ -52,7 +52,7 @@ #include "xmalloc.h" -/** The number of extra precesion rounding bits */ +/** The number of extra precision rounding bits */ #define ROUNDING_BITS 2 typedef uint32_t UINT32; @@ -1531,11 +1531,11 @@ void init_fltcalc(int precision) { /* does nothing if already init */ if (precision == 0) precision = FC_DEFAULT_PRECISION; - init_strcalc(precision + 4); + init_strcalc(precision + 2 + ROUNDING_BITS); - /* needs additionally two bits to round, a bit as explicit 1., and one for + /* needs additionally rounding bits, one bit as explicit 1., and one for * addition overflow */ - max_precision = sc_get_precision() - 4; + max_precision = sc_get_precision() - (2 + ROUNDING_BITS); if (max_precision < precision) printf("WARNING: not enough precision available, using %d\n", max_precision); diff --git a/ir/tv/tv.c b/ir/tv/tv.c index a0762b6c6..0ebef2373 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -1756,7 +1756,7 @@ static const tarval_mode_info hex_output = { /* * Initialization of the tarval module: called before init_mode() */ -void init_tarval_1(long null_value) { +void init_tarval_1(long null_value, int support_quad_precision) { /* if these assertion fail, tarval_is_constant() will follow ... */ assert(tarval_b_false == &reserved_tv[0] && "b_false MUST be the first reserved tarval!"); assert(tarval_b_true == &reserved_tv[1] && "b_true MUST be the second reserved tarval!"); @@ -1767,10 +1767,8 @@ void init_tarval_1(long null_value) { * an initial size, which is the expected number of constants */ tarvals = new_set(cmp_tv, N_CONSTANTS); values = new_set(memcmp, N_CONSTANTS); - /* init strcalc with precision of 68 to support floating point values with 64 - * bit mantissa (needs extra bits for rounding and overflow) */ - init_strcalc(68); - init_fltcalc(0); + /* calls init_strcalc() with needed size */ + init_fltcalc(support_quad_precision ? 112 : 64); } /* diff --git a/ir/tv/tv_t.h b/ir/tv/tv_t.h index aa6ea2c90..d029f3042 100644 --- a/ir/tv/tv_t.h +++ b/ir/tv/tv_t.h @@ -50,9 +50,12 @@ enum reserved_id { * * Call before init_mode(). * - * @param null_value The reference mode NULL value, typical 0l + * @param null_value + * The reference mode NULL value, typical 0l + * @param support_quad_precision + * If non-zero, activate support for quad precision */ -void init_tarval_1(long null_value); +void init_tarval_1(long null_value, int support_quad_precision); /** * Initialization of the tarval module. -- 2.20.1