********/
static long double value;
-#define CAST_IN(val) (*((long double *)((val))))
+#define CAST_IN(val) ({ long double xxx = *(long double *)(val); printf("CAST to %Lg\n", xxx); xxx; })
+
+//#define CAST_IN(val) (*((long double *)((val))))
#define CAST_OUT(val) ((void *)&(val))
#define CLEAR_BUFFER() memset((char*)&value, 0, sizeof(long double))
void fc_val_from_str(const char *str, unsigned int len)
{
+ extern long double strtold(const char *str, char **end);
+
+ printf("-> %s\n", str);
CLEAR_BUFFER();
value = strtold(str, NULL);
}
break;
case FC_NEG:
value = -CAST_IN(a);
+ printf("-> NEG %Lg\n", value);
+ break;
}
}
{
ANNOUNCE();
assert(mode);
- assert(get_mode_sort(mode) == float_number);
- fc_get_nan();
- return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
+ if (get_mode_sort(mode) == float_number) {
+ fc_get_nan();
+ return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
+ }
+ else {
+ assert(0 && "tarval is not floating point");
+ return tarval_bad;
+ }
}
tarval *get_tarval_inf(ir_mode *mode)
{
ANNOUNCE();
assert(mode);
- assert(get_mode_sort(mode) == float_number);
- fc_get_inf();
- return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
+ if (get_mode_sort(mode) == float_number) {
+ fc_get_inf();
+ return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
+ }
+ else {
+ assert(0 && "tarval is not floating point");
+ return tarval_bad;
+ }
}
/*
default:
assert(0 && "not implemented");
+ return 0;
}
}
assert(mode_is_num(a->mode)); /* negation only for numerical values */
assert(mode_is_signed(a->mode)); /* negation is difficult without negative numbers, isn't it */
+printf("NEG\n");
switch (get_mode_sort(a->mode))
{
case int_number:
return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
case float_number:
+printf("FP NEG\n");
fc_neg(a->value);
return get_tarval(fc_get_buffer(), fc_get_buffer_length(), a->mode);
* Because this is the bit representation of the target machine, only the following
* operations are legal on the result:
*
- * - concatenation (be aware of the endieness)
- * - bitwise logical operations to selct/mask bits
+ * - concatenation (endian dependance MUST be handled by the CALLER)
+ * - bitwise logical operations to select/mask bits
*
* @param tv the tarval
* @param byte_ofs the byte offset