Skip to contentSkip to conversation

m68k: allows bfins to manage correctly width = 32

PATCH In review Bryce Lanham 1 participant 1 message Aug 17, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 88/111 m68k: allows bfins to manage correctly width = 32

From: Laurent Vivier <[email protected]>

tcg_gen_shl_i32() doesn't manage a shift of 32.

As 32 >= width >= 1, we use two tcg_gen_shl_i32():
tcg_gen_shl_i32(1) and tcg_gen_shl_i32(width - 1)

seen with gcc testsuite, gcc-4.1.2/gcc/testsuite/gcc.c-torture/execute/991118-1.c

---
 target-m68k/translate.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
target-m68k/translate.c +5 -1
index 96ea93f..52df274 100644
@@ -3215,7 +3215,11 @@ static void gen_bitfield_ins(TCGv offset, TCGv width, TCGv src,
 
     /* tmp = (1u << width) - 1; */
 
-    tcg_gen_shl_i32(tmp, tcg_const_i32(1), width);
+    /* width is between 1 and 32
+     * tcg_gen_shl_i32() cannot manage value 32
+     */
+    tcg_gen_subi_i32(tmp, width, 1);
+    tcg_gen_shl_i32(tmp, tcg_const_i32(2), tmp);
     tcg_gen_subi_i32(tmp, tmp, 1);
 
     /* tmp = tmp & src; */
Signature · 1 line
1.7.2.3