Remove ia32_l_Setcc and remove set creation callback from ir_lower_mode_b().
[libfirm] / ir / tv / tv.c
index d437c45..8b4f8fc 100644 (file)
@@ -47,7 +47,7 @@
 #include "irnode.h"
 #include "strcalc.h"
 #include "fltcalc.h"
-#include "irtools.h"
+#include "util.h"
 #include "xmalloc.h"
 #include "firm_common.h"
 #include "error.h"
@@ -64,6 +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
 
 /****************************************************************************
@@ -98,16 +101,16 @@ static tarval_int_overflow_mode_t int_overflow_mode = TV_OVERFLOW_WRAP;
 static int no_float = 0;
 
 /** IEEE-754r half precision */
-static const ieee_descriptor_t half_desc     = {  5,  10, 0, NORMAL };
+static const ieee_descriptor_t half_desc     = {  5,  10, 0, FC_NORMAL };
 /** IEEE-754 single precision */
-static const ieee_descriptor_t single_desc   = {  8,  23, 0, NORMAL };
+static const ieee_descriptor_t single_desc   = {  8,  23, 0, FC_NORMAL };
 /** IEEE-754 double precision */
-static const ieee_descriptor_t double_desc   = { 11,  52, 0, NORMAL };
+static const ieee_descriptor_t double_desc   = { 11,  52, 0, FC_NORMAL };
 /** Intel x87 extended precision */
-static const ieee_descriptor_t extended_desc = { 15,  63, 1, NORMAL };
+static const ieee_descriptor_t extended_desc = { 15,  63, 1, FC_NORMAL };
 
 /** IEEE-754r quad precision */
-static const ieee_descriptor_t quad_desc     = { 15, 112, 0, NORMAL };
+static const ieee_descriptor_t quad_desc     = { 15, 112, 0, FC_NORMAL };
 
 /****************************************************************************
  *   private functions
@@ -123,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);
@@ -251,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);
@@ -265,7 +269,13 @@ static ir_tarval *get_tarval_overflow(const void *value, size_t length, ir_mode
                break;
 
        case irms_float_number:
-#ifdef SWITCH_NODENORMALS
+#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
+#if SWITCH_NODENORMALS
                if (fc_is_subnormal((const fp_value*) value)) {
                        /* clip denormals to zero */
                        return get_mode_null(mode);
@@ -307,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()");
        }
 }
@@ -954,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:
@@ -967,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:
@@ -1590,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) {