dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0047-target-xtensa-fix-extui-shift-amount.patch

5544c1
From 1c596a9498830485a1b2f4a4445643a149179b99 Mon Sep 17 00:00:00 2001
5544c1
From: Max Filippov <jcmvbkbc@gmail.com>
5544c1
Date: Fri, 21 Sep 2012 02:59:49 +0400
5544c1
Subject: [PATCH] target-xtensa: fix extui shift amount
5544c1
5544c1
extui opcode only uses lowermost op1 bit for sa4.
5544c1
5544c1
Reported-by: malc <av1474@comtv.ru>
5544c1
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
5544c1
Cc: qemu-stable <qemu-stable@nongnu.org>
5544c1
Signed-off-by: malc <av1474@comtv.ru>
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1
---
5544c1
 target-xtensa/translate.c | 24 +++++++++++++++++++++---
5544c1
 1 file changed, 21 insertions(+), 3 deletions(-)
5544c1
5544c1
diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c
5544c1
index 1900bd5..7a1c528 100644
5544c1
--- a/target-xtensa/translate.c
5544c1
+++ b/target-xtensa/translate.c
5544c1
@@ -1778,12 +1778,30 @@ static void disas_xtensa_insn(DisasContext *dc)
5544c1
         case 5:
5544c1
             gen_window_check2(dc, RRR_R, RRR_T);
5544c1
             {
5544c1
-                int shiftimm = RRR_S | (OP1 << 4);
5544c1
+                int shiftimm = RRR_S | ((OP1 & 1) << 4);
5544c1
                 int maskimm = (1 << (OP2 + 1)) - 1;
5544c1
 
5544c1
                 TCGv_i32 tmp = tcg_temp_new_i32();
5544c1
-                tcg_gen_shri_i32(tmp, cpu_R[RRR_T], shiftimm);
5544c1
-                tcg_gen_andi_i32(cpu_R[RRR_R], tmp, maskimm);
5544c1
+
5544c1
+                if (shiftimm) {
5544c1
+                    tcg_gen_shri_i32(tmp, cpu_R[RRR_T], shiftimm);
5544c1
+                } else {
5544c1
+                    tcg_gen_mov_i32(tmp, cpu_R[RRR_T]);
5544c1
+                }
5544c1
+
5544c1
+                switch (maskimm) {
5544c1
+                case 0xff:
5544c1
+                    tcg_gen_ext8u_i32(cpu_R[RRR_R], tmp);
5544c1
+                    break;
5544c1
+
5544c1
+                case 0xffff:
5544c1
+                    tcg_gen_ext16u_i32(cpu_R[RRR_R], tmp);
5544c1
+                    break;
5544c1
+
5544c1
+                default:
5544c1
+                    tcg_gen_andi_i32(cpu_R[RRR_R], tmp, maskimm);
5544c1
+                    break;
5544c1
+                }
5544c1
                 tcg_temp_free(tmp);
5544c1
             }
5544c1
             break;
5544c1
-- 
5544c1
1.7.12.1
5544c1