summaryrefslogtreecommitdiffhomepage
path: root/ir/tv
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2014-12-30 02:28:12 +0100
committerMatthias Braun <matze@braunis.de>2014-12-30 11:09:08 +0100
commita7cbe6236d87c11f3aaa906df550ff899361a644 (patch)
tree271fde6a1e397ac1fe16321ede92a5e3ccacd748 /ir/tv
parent1cf9a9fd980f883987b53341ca3669ccff9f8e85 (diff)
tv: remove endianess paramter from new_tarval_from_bytes()
Most inputs are little endian anyway and the few remaining users can easily swap the bytes themselfes instead of having the function swap them.
Diffstat (limited to 'ir/tv')
-rw-r--r--ir/tv/strcalc.c13
-rw-r--r--ir/tv/strcalc.h8
-rw-r--r--ir/tv/tv.c14
3 files changed, 9 insertions, 26 deletions
diff --git a/ir/tv/strcalc.c b/ir/tv/strcalc.c
index b5b652b..66c91c9 100644
--- a/ir/tv/strcalc.c
+++ b/ir/tv/strcalc.c
@@ -599,21 +599,14 @@ unsigned sc_popcount(const sc_word *value, unsigned bits)
}
void sc_val_from_bytes(unsigned char const *const bytes, size_t n_bytes,
- bool big_endian, sc_word *buffer)
+ sc_word *buffer)
{
assert(n_bytes*CHAR_BIT <= (size_t)calc_buffer_size*SC_BITS);
sc_word *p = buffer;
assert(SC_BITS == CHAR_BIT);
- if (big_endian) {
- for (unsigned char const *bp = bytes+n_bytes; bp-- > bytes; ) {
- *p++ = (sc_word)*bp;
- }
- } else {
- memcpy(p, bytes, n_bytes);
- p += n_bytes;
- }
- memset(p, 0, buffer+calc_buffer_size-p);
+ memcpy(p, bytes, n_bytes);
+ memset(p+n_bytes, 0, buffer+calc_buffer_size-p);
}
void sc_val_to_bytes(const sc_word *buffer, unsigned char *const dest,
diff --git a/ir/tv/strcalc.h b/ir/tv/strcalc.h
index 6420e0c..4afbb3c 100644
--- a/ir/tv/strcalc.h
+++ b/ir/tv/strcalc.h
@@ -169,16 +169,14 @@ void sc_val_from_long(long l, sc_word *buffer);
void sc_val_from_ulong(unsigned long l, sc_word *buffer);
/**
- * Construct a strcalc value form a sequence of bytes in two complement big
- * or little endian format.
+ * Construct a strcalc value form a sequence of bytes in two complement little
+ * endian format.
* @param bytes pointer to array of bytes
* @param n_bytes number of bytes in the sequence
- * @param big_endian interpret bytes as big_endian format if true, else
- * little endian
* @param buffer destination buffer (calc_buffer if used if NULL)
*/
void sc_val_from_bytes(unsigned char const *bytes, size_t n_bytes,
- bool big_endian, sc_word *buffer);
+ sc_word *buffer);
/**
* Construct a strcalc value from a sequence of bytes in a little endian
diff --git a/ir/tv/tv.c b/ir/tv/tv.c
index aefaaec..f328c09 100644
--- a/ir/tv/tv.c
+++ b/ir/tv/tv.c
@@ -256,26 +256,18 @@ ir_tarval *new_tarval_from_long(long l, ir_mode *mode)
}
ir_tarval *new_tarval_from_bytes(unsigned char const *buf,
- ir_mode *mode, int big_endian)
+ ir_mode *mode)
{
switch (get_mode_arithmetic(mode)) {
case irma_twos_complement: {
unsigned bits = get_mode_size_bits(mode);
unsigned n_bytes = bits/CHAR_BIT + (bits%CHAR_BIT != 0);
sc_word *dest = ALLOCAN(sc_word, sc_value_length);
- sc_val_from_bytes(buf, n_bytes, big_endian, dest);
+ sc_val_from_bytes(buf, n_bytes, dest);
return get_tarval(dest, sc_value_length, mode);
}
case irma_ieee754:
case irma_x86_extended_float: {
- if (big_endian) {
- unsigned size = get_mode_size_bytes(mode);
- unsigned char *temp = ALLOCAN(unsigned char, size);
- for (unsigned i = 0; i < size; ++i) {
- temp[i] = buf[size-i-1];
- }
- buf = temp;
- }
fc_val_from_bytes(NULL, buf, get_descriptor(mode));
return get_tarval_from_fp_value(fc_get_buffer(), mode);
}
@@ -695,7 +687,7 @@ ir_tarval *tarval_bitcast(ir_tarval *src, ir_mode *dst_mode)
panic("unexpected arithmetic mode in tarval_bitcast");
}
- return new_tarval_from_bytes(buffer, dst_mode, false);
+ return new_tarval_from_bytes(buffer, dst_mode);
}
ir_tarval *tarval_not(ir_tarval *a)