X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftv%2Ftv.c;h=9e38147b9cbe802c810aea7f938dfdaeb24dc2ef;hb=1553e92153d3b718a7f5575dcbbe8abbffc579c0;hp=0394b2b80e058a451fddb70aa89a8f04a5fc571a;hpb=1a3b7d363474ab544c13093a2f0b578718d37c7a;p=libfirm diff --git a/ir/tv/tv.c b/ir/tv/tv.c index 0394b2b80..9e38147b9 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -36,10 +36,8 @@ #include #include #include -#ifdef HAVE_STRINGS_H -#include -#endif #include +#include #include "bitfiddle.h" #include "tv_t.h" @@ -66,7 +64,9 @@ typedef enum float_to_int_mode { static float_to_int_mode current_float_to_int_mode = TRUNCATE; +/* set this to true if infinity should be clipped to +/- MAX_FLOAT */ #define SWITCH_NOINFINITY 0 +/* set this to true if denormals should be clipped to zero */ #define SWITCH_NODENORMALS 0 /**************************************************************************** @@ -126,11 +126,12 @@ static void _fail_verify(ir_tarval *tv, const char* file, int line) else panic("%s:%d: Invalid tarval (null)", file, line); } + +inline static #ifdef __GNUC__ -inline static void tarval_verify(ir_tarval *tv) __attribute__ ((unused)); + __attribute__((unused)) #endif - -inline static void tarval_verify(ir_tarval *tv) +void tarval_verify(ir_tarval *tv) { assert(tv); assert(tv->mode); @@ -254,7 +255,7 @@ static ir_tarval *get_tarval_overflow(const void *value, size_t length, ir_mode case TV_OVERFLOW_SATURATE: return get_mode_min(mode); case TV_OVERFLOW_WRAP: { - char *temp = (char*) alloca(sc_get_buffer_length()); + temp = (char*) alloca(sc_get_buffer_length()); memcpy(temp, value, sc_get_buffer_length()); sc_truncate(get_mode_size_bits(mode), temp); return get_tarval(temp, length, mode); @@ -268,14 +269,13 @@ static ir_tarval *get_tarval_overflow(const void *value, size_t length, ir_mode break; case irms_float_number: -#ifdef SWITCH_NOINFINITY +#if SWITCH_NOINFINITY if (fc_is_inf((const fp_value*) value)) { /* clip infinity to maximum value */ return fc_is_negative((const fp_value*) value) ? get_mode_min(mode) : get_mode_max(mode); } #endif - -#ifdef SWITCH_NODENORMALS +#if SWITCH_NODENORMALS if (fc_is_subnormal((const fp_value*) value)) { /* clip denormals to zero */ return get_mode_null(mode); @@ -317,6 +317,7 @@ static const ieee_descriptor_t *get_descriptor(const ir_mode *mode) real payload */ /* case 128: return &quad_desc; */ default: + (void) quad_desc; panic("Unsupported mode in get_descriptor()"); } } @@ -964,10 +965,10 @@ ir_tarval *tarval_convert_to(ir_tarval *src, ir_mode *dst_mode) return get_tarval(buffer, sc_get_buffer_length(), dst_mode); default: - /* the rest can't be converted */ - return tarval_bad; + break; } - break; + /* the rest can't be converted */ + return tarval_bad; /* cast int/characters to something */ case irms_int_number: @@ -977,7 +978,6 @@ ir_tarval *tarval_convert_to(ir_tarval *src, ir_mode *dst_mode) case irms_int_number: buffer = (char*) alloca(sc_get_buffer_length()); memcpy(buffer, src->value, sc_get_buffer_length()); - sign_extend(buffer, dst_mode); return get_tarval_overflow(buffer, src->length, dst_mode); case irms_internal_boolean: @@ -1600,7 +1600,6 @@ int tarval_snprintf(char *buf, size_t len, ir_tarval *tv) default: return snprintf(buf, len, "%s%s%s", prefix, fc_print((const fp_value*) tv->value, tv_buf, sizeof(tv_buf), FC_DEC), suffix); } - break; case irms_internal_boolean: switch (mode_info->mode_output) {