X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftv%2Ffltcalc.c;h=d6105a8972817303daeca99dd561e5a82658d86e;hb=0f234e2d94155d13c0e4727871125beda0eaa66d;hp=a11c6f811206b9a285fa30b71485435d8404c79c;hpb=14c762ccfb8fa5f2ac8ebea5d4ab2c8dc37e79f3;p=libfirm diff --git a/ir/tv/fltcalc.c b/ir/tv/fltcalc.c index a11c6f811..d6105a897 100644 --- a/ir/tv/fltcalc.c +++ b/ir/tv/fltcalc.c @@ -24,21 +24,18 @@ * @author Mathias Heil * @version $Id$ */ - #include "config.h" #include "fltcalc.h" #include "strcalc.h" -#include /* need isnan() and isinf() (will be changed)*/ +#include /* undef some reused constants defined by math.h */ #ifdef NAN # undef NAN #endif -#ifdef HAVE_INTTYPES_H -# include -#endif +#include #include #include #include @@ -1228,6 +1225,12 @@ fp_value *fc_cast(const fp_value *value, const ieee_descriptor_t *desc, fp_value else return fc_get_snan(desc, result); } + else if(value->desc.clss == INF) { + if (value->sign == 0) + return fc_get_plusinf(desc, result); + else + return fc_get_minusinf(desc, result); + } /* set the descriptor of the new value */ result->desc.exponent_size = desc->exponent_size; @@ -1329,7 +1332,10 @@ fp_value *fc_get_qnan(const ieee_descriptor_t *desc, fp_value *result) { return result; } -fp_value *fc_get_plusinf(const ieee_descriptor_t *desc, fp_value *result) { +fp_value *fc_get_plusinf(const ieee_descriptor_t *desc, fp_value *result) +{ + char *mant; + if (result == NULL) result = calc_buffer; result->desc.exponent_size = desc->exponent_size; @@ -1341,7 +1347,11 @@ fp_value *fc_get_plusinf(const ieee_descriptor_t *desc, fp_value *result) { sc_val_from_ulong((1 << desc->exponent_size) - 1, _exp(result)); - sc_val_from_ulong(0, _mant(result)); + mant = _mant(result); + sc_val_from_ulong(0, mant); + if (desc->explicit_one) { + sc_set_bit_at(mant, result->desc.mantissa_size + ROUNDING_BITS); + } return result; }