summaryrefslogtreecommitdiffhomepage
path: root/ir/tv
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-10-18 11:45:38 +0200
committerMatthias Braun <matze@braunis.de>2015-10-18 11:45:38 +0200
commit9b02a9db4b918caaab631ab1784f6aef222da7c3 (patch)
tree015aea54c0bb3b88fd528771b3494c7c3e6290f7 /ir/tv
parentd013e55796cb01d63f92a6866e9e956466aec462 (diff)
tv: Remove mode parameter from tarval_sub
We can get a proper mode for pointer-pointer from get_reference_offset_mode().
Diffstat (limited to 'ir/tv')
-rw-r--r--ir/tv/tv.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/ir/tv/tv.c b/ir/tv/tv.c
index acede80..fa3dc1e 100644
--- a/ir/tv/tv.c
+++ b/ir/tv/tv.c
@@ -769,30 +769,37 @@ ir_tarval *tarval_add(ir_tarval *a, ir_tarval *b)
panic("invalid mode sort");
}
-ir_tarval *tarval_sub(ir_tarval *a, ir_tarval *b, ir_mode *dst_mode)
+ir_tarval *tarval_sub(ir_tarval *a, ir_tarval *b)
{
- if (dst_mode != NULL) {
- if (a->mode != dst_mode)
+ ir_mode *dst_mode;
+ if (mode_is_reference(a->mode)) {
+ if (mode_is_reference(b->mode)) {
+ dst_mode = get_reference_offset_mode(a->mode);
+ assert(get_reference_offset_mode(b->mode) == dst_mode);
a = tarval_convert_to(a, dst_mode);
- if (b->mode != dst_mode)
- b = tarval_convert_to(b, dst_mode);
+ } else {
+ dst_mode = a->mode;
+ }
+ b = tarval_convert_to(b, dst_mode);
+ } else {
+ assert(a->mode == b->mode);
+ dst_mode = a->mode;
}
- assert(a->mode == b->mode);
- switch (get_mode_sort(a->mode)) {
+ switch (get_mode_sort(dst_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 */
sc_word *buffer = ALLOCAN(sc_word, sc_value_length);
sc_sub(a->value, b->value, buffer);
- return get_int_tarval_overflow(buffer, a->mode);
+ return get_int_tarval_overflow(buffer, dst_mode);
}
case irms_float_number: {
fp_value *buffer = (fp_value*)ALLOCAN(char, fp_value_size);
fc_sub((const fp_value*)a->value, (const fp_value*)b->value, buffer);
- return get_fp_tarval(buffer, a->mode);
+ return get_fp_tarval(buffer, dst_mode);
}
case irms_auxiliary: