ir_tarval *tv = value_of(b);
if (tv != tarval_bad) {
- int rem = tarval_fp_ops_enabled();
-
- /*
- * Floating point constant folding might be disabled here to
- * prevent rounding.
- * However, as we check for exact result, doing it is safe.
- * Switch it on.
- */
- tarval_enable_fp_ops(1);
tv = tarval_div(get_mode_one(mode), tv);
- tarval_enable_fp_ops(rem);
/* Do the transformation if the result is either exact or we are
not using strict rules. */
/** The integer overflow mode. */
static tarval_int_overflow_mode_t int_overflow_mode = TV_OVERFLOW_WRAP;
-/** if this is set non-zero, the constant folding for floating point is OFF */
-static int no_float = 0;
-
/****************************************************************************
* private functions
****************************************************************************/
return get_tarval_overflow(buffer, a->length, a->mode);
case irms_float_number:
- /* it should be safe to enable this even if other arithmetic is disabled */
- /*if (no_float)
- return tarval_bad;*/
-
fc_neg((const fp_value*) a->value, NULL);
return get_tarval_overflow(fc_get_buffer(), fc_get_buffer_length(), a->mode);
return get_tarval_overflow(buffer, a->length, a->mode);
case irms_float_number:
- if (no_float)
- return tarval_bad;
-
fc_add((const fp_value*) a->value, (const fp_value*) b->value, NULL);
return get_tarval_overflow(fc_get_buffer(), fc_get_buffer_length(), a->mode);
return get_tarval_overflow(buffer, a->length, a->mode);
case irms_float_number:
- if (no_float)
- return tarval_bad;
-
fc_sub((const fp_value*) a->value, (const fp_value*) b->value, NULL);
return get_tarval_overflow(fc_get_buffer(), fc_get_buffer_length(), a->mode);
return get_tarval_overflow(buffer, a->length, a->mode);
case irms_float_number:
- if (no_float)
- return tarval_bad;
-
fc_mul((const fp_value*) a->value, (const fp_value*) b->value, NULL);
return get_tarval_overflow(fc_get_buffer(), fc_get_buffer_length(), a->mode);
return a;
case irms_float_number:
- /* it should be safe to enable this even if other arithmetic is disabled */
- /*if (no_float)
- return tarval_bad;*/
-
if (fc_comp((const fp_value*) a->value,
(const fp_value*) get_mode_null(a->mode)->value) == -1) {
fc_neg((const fp_value*) a->value, NULL);
return int_overflow_mode;
}
-/* Enable/Disable floating point constant folding. */
-void tarval_enable_fp_ops(int enable)
-{
- no_float = !enable;
-}
-
-int tarval_fp_ops_enabled(void)
-{
- return !no_float;
-}
-
/**
* default mode_info for output as HEX
*/