#include <assert.h>
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
#include <stdlib.h>
+#include <strings.h>
#include "bitfiddle.h"
#include "tv_t.h"
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
/****************************************************************************
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);
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);
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);
real payload */
/* case 128: return &quad_desc; */
default:
+ (void) quad_desc;
panic("Unsupported mode in get_descriptor()");
}
}
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:
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:
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) {