Commit 3fb6c756 authored by Michael Beck's avatar Michael Beck
Browse files

- fixed tarval_add() and tarval_sub() support for arithmetic with reference modes

[r22019]
parent a68dfa0a
......@@ -1027,7 +1027,6 @@ tarval *tarval_neg(tarval *a) {
tarval *tarval_add(tarval *a, tarval *b) {
tarval *res;
char *buffer;
ir_mode *imm_mode, *dst_mode = NULL;
assert(a);
assert(b);
......@@ -1037,51 +1036,32 @@ tarval *tarval_add(tarval *a, tarval *b) {
return tarval_bad;
}
if (mode_is_reference(a->mode)) {
dst_mode = a->mode;
imm_mode = find_unsigned_mode(a->mode);
if (imm_mode == NULL)
return tarval_bad;
a = tarval_convert_to(a, imm_mode);
b = tarval_convert_to(b, imm_mode);
}
if (mode_is_reference(b->mode)) {
dst_mode = b->mode;
imm_mode = find_unsigned_mode(b->mode);
if (imm_mode == 0)
return tarval_bad;
a = tarval_convert_to(a, imm_mode);
b = tarval_convert_to(b, imm_mode);
if (mode_is_reference(a->mode) && a->mode != b->mode) {
b = tarval_convert_to(b, a->mode);
} else if (mode_is_reference(b->mode) && b->mode != a->mode) {
a = tarval_convert_to(a, b->mode);
}
assert(a->mode == b->mode);
switch (get_mode_sort(a->mode)) {
case irms_reference:
case irms_int_number:
/* modes of a,b are equal, so result has mode of a as this might be the character */
buffer = alloca(sc_get_buffer_length());
sc_add(a->value, b->value, buffer);
res = get_tarval_overflow(buffer, a->length, a->mode);
break;
return get_tarval_overflow(buffer, a->length, a->mode);
case irms_float_number:
if (no_float)
return tarval_bad;
fc_add(a->value, b->value, NULL);
res = get_tarval_overflow(fc_get_buffer(), fc_get_buffer_length(), a->mode);
break;
return get_tarval_overflow(fc_get_buffer(), fc_get_buffer_length(), a->mode);
default:
return tarval_bad;
}
if (dst_mode != NULL)
return tarval_convert_to(res, dst_mode);
return res;
}
/*
......@@ -1099,17 +1079,15 @@ tarval *tarval_sub(tarval *a, tarval *b, ir_mode *dst_mode) {
}
if (dst_mode != NULL) {
if (mode_is_reference(a->mode)) {
if (a->mode != dst_mode)
a = tarval_convert_to(a, dst_mode);
}
if (mode_is_reference(b->mode)) {
if (b->mode != dst_mode)
b = tarval_convert_to(b, dst_mode);
}
assert(a->mode == dst_mode);
}
assert(a->mode == b->mode);
switch (get_mode_sort(a->mode)) {
case irms_reference:
case irms_int_number:
/* modes of a,b are equal, so result has mode of a as this might be the character */
buffer = alloca(sc_get_buffer_length());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment