more tarval cleanup
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sun, 24 Aug 2008 00:19:59 +0000 (00:19 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sun, 24 Aug 2008 00:19:59 +0000 (00:19 +0000)
[r21396]

ir/common/firm.c
ir/tv/fltcalc.c
ir/tv/tv.c
ir/tv/tv_t.h

index 7ebdf3e..97edf99 100644 (file)
@@ -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 */
index 8938cdc..7d20bab 100644 (file)
@@ -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);
 
index a0762b6..0ebef23 100644 (file)
@@ -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);
 }
 
 /*
index aa6ea2c..d029f30 100644 (file)
@@ -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.