summaryrefslogtreecommitdiffhomepage
path: root/ir/tv
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2014-12-31 00:28:11 +0100
committerMatthias Braun <matze@braunis.de>2014-12-31 06:53:59 +0100
commitf227793ff63f47a3ed760de309b37a8e58e894c0 (patch)
tree6b655aefb3c938a2e5253cdbe3c365322d978435 /ir/tv
parentbf20bdf86ae141d53c11a25da65c609a755e79fb (diff)
strcalc: change sc_inc to always work in-place
Diffstat (limited to 'ir/tv')
-rw-r--r--ir/tv/fltcalc.c8
-rw-r--r--ir/tv/strcalc.c12
-rw-r--r--ir/tv/strcalc.h4
3 files changed, 10 insertions, 14 deletions
diff --git a/ir/tv/fltcalc.c b/ir/tv/fltcalc.c
index 4c26727..96759da 100644
--- a/ir/tv/fltcalc.c
+++ b/ir/tv/fltcalc.c
@@ -213,7 +213,7 @@ static bool normalize(const fp_value *in_val, fp_value *out_val, bool sticky)
} else if ((out_val->clss == FC_SUBNORMAL) && (hsb == -1)) {
/* overflow caused the mantissa to be normal again,
* so adapt the exponent accordingly */
- sc_inc(_exp(out_val), _exp(out_val));
+ sc_inc(_exp(out_val));
out_val->clss = FC_NORMAL;
}
@@ -373,7 +373,7 @@ static void _fadd(const fp_value *a, const fp_value *b, fp_value *result)
* little more than the represented value to a negative value this, in
* addition to the still set sticky bit, takes account of the
* 'little more' */
- sc_inc(temp, temp);
+ sc_inc(temp);
}
if (sign) {
@@ -461,7 +461,7 @@ static void _fmul(const fp_value *a, const fp_value *b, fp_value *result)
/* mixed normal, subnormal values introduce an error of 1, correct it */
if ((a->clss == FC_SUBNORMAL) ^ (b->clss == FC_SUBNORMAL)) {
- sc_inc(_exp(result), _exp(result));
+ sc_inc(_exp(result));
}
sc_mul(_mant(a), _mant(b), _mant(result));
@@ -547,7 +547,7 @@ static void _fdiv(const fp_value *a, const fp_value *b, fp_value *result)
/* mixed normal, subnormal values introduce an error of 1, correct it */
if ((a->clss == FC_SUBNORMAL) ^ (b->clss == FC_SUBNORMAL)) {
- sc_inc(_exp(result), _exp(result));
+ sc_inc(_exp(result));
}
/* mant(res) = mant(a) / 1/2mant(b) */
diff --git a/ir/tv/strcalc.c b/ir/tv/strcalc.c
index 66c91c9..6fc0bc5 100644
--- a/ir/tv/strcalc.c
+++ b/ir/tv/strcalc.c
@@ -85,16 +85,12 @@ void sc_andnot(const sc_word *val1, const sc_word *val2, sc_word *buffer)
buffer[counter] = val1[counter] & (SC_MASK ^ val2[counter]);
}
-void sc_inc(const sc_word *val, sc_word *buffer)
+void sc_inc(sc_word *buffer)
{
for (unsigned counter = 0; counter < calc_buffer_size; ++counter) {
- sc_word v = val[counter];
+ sc_word v = buffer[counter];
if (v < SC_MASK) {
buffer[counter] = v+1;
- /* copy the rest of the buffer if necessary */
- if (buffer != val)
- memcpy(&buffer[counter+1], &val[counter+1],
- calc_buffer_size-(counter+1));
break;
}
buffer[counter] = 0;
@@ -104,7 +100,7 @@ void sc_inc(const sc_word *val, sc_word *buffer)
void sc_neg(const sc_word *val, sc_word *buffer)
{
sc_not(val, buffer);
- sc_inc(buffer, buffer);
+ sc_inc(buffer);
}
void sc_add(const sc_word *val1, const sc_word *val2, sc_word *buffer)
@@ -400,7 +396,7 @@ void sc_val_from_long(long value, sc_word *buffer)
if (sign) {
if (is_minlong)
- sc_inc(buffer, buffer);
+ sc_inc(buffer);
sc_neg(buffer, buffer);
}
diff --git a/ir/tv/strcalc.h b/ir/tv/strcalc.h
index 4afbb3c..b8d27ce 100644
--- a/ir/tv/strcalc.h
+++ b/ir/tv/strcalc.h
@@ -37,9 +37,9 @@ enum base_t {
void sc_add(const sc_word *value1, const sc_word *value2, sc_word *buffer);
/**
- * buffer = value1 + 1
+ * buffer = buffer + 1
*/
-void sc_inc(const sc_word *value1, sc_word *buffer);
+void sc_inc(sc_word *buffer);
/**
* buffer = value1 - value2