Skip to contentSkip to conversation

target-mips: Fix incorrect code and test for INSV

PATCH Applied Petar Jovanovic 3 participants 3 messages Nov 26, 2012 – Dec 6, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-mips: Fix incorrect code and test for INSV

From: Petar Jovanovic <[email protected]>

Content of register rs should be shifted for pos before applying a mask. This change contains both fix for the instruction and to the existing test.

---
 target-mips/dsp_helper.c         |    2 +-
 tests/tcg/mips/mips32-dsp/insv.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
target-mips/dsp_helper.c +1 -1
index e7949c2..fda5f04 100644
@@ -3152,7 +3152,7 @@ target_ulong helper_##name(CPUMIPSState *env, target_ulong rs,  \
                                                                 \
     filter = ((int32_t)0x01 << size) - 1;                       \
     filter = filter << pos;                                     \
-    temprs = rs & filter;                                       \
+    temprs = (rs << pos) & filter;                              \
     temprt = rt & ~filter;                                      \
     temp = temprs | temprt;                                     \
                                                                 \
tests/tcg/mips/mips32-dsp/insv.c +1 -1
index 7e3b047..243b007 100644
@@ -10,7 +10,7 @@ int main()
     dsp    = 0x305;
     rt     = 0x12345678;
     rs     = 0x87654321;
-    result = 0x12345338;
+    result = 0x12345438;
     __asm
         ("wrdsp %2, 0x03\n\t"
          "insv  %0, %1\n\t"
Signature · 1 line
1.7.5.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 50 lines

-----Original Message-----
From: [email protected] [mailto:qemu-devel- [email protected]] On Behalf Of Petar Jovanovic
Sent: Monday, November 26, 2012 7:13 AM
To: [email protected]
Cc: Jovanovic, Petar; [email protected]
Subject: [Qemu-devel] [PATCH] target-mips: Fix incorrect code and test for INSV

From: Petar Jovanovic <[email protected]>

Content of register rs should be shifted for pos before applying a mask. This change contains both fix for the instruction and to the existing test.

---
 target-mips/dsp_helper.c         |    2 +-
 tests/tcg/mips/mips32-dsp/insv.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
target-mips/dsp_helper.c +1 -1
index e7949c2..fda5f04 100644
@@ -3152,7 +3152,7 @@ target_ulong helper_##name(CPUMIPSState *env,
 target_ulong rs,  \
                                                                 \
     filter = ((int32_t)0x01 << size) - 1;                       \
     filter = filter << pos;                                     \
-    temprs = rs & filter;                                       \
+    temprs = (rs << pos) & filter;                              \
     temprt = rt & ~filter;                                      \
     temp = temprs | temprt;                                     \
                                                                 \
tests/tcg/mips/mips32- renamed from tests/tcg/mips/mips32-dsp/insv.c +0 -0

dsp/insv.c
index 7e3b047..243b007 100644

tests/tcg/mips/mips32-dsp/insv.c +1 -2
@@ -10,7 +10,7 @@ int main()
     dsp    = 0x305;
     rt     = 0x12345678;
     rs     = 0x87654321;
-    result = 0x12345338;
+    result = 0x12345438;
     __asm
         ("wrdsp %2, 0x03\n\t"
          "insv  %0, %1\n\t"
--
Quoted 2 lines

1.7.5.4

#2 lore raw
In reply to Petar Jovanovic
Quoted 29 lines · Petar Jovanovic

From: Petar Jovanovic <[email protected]>

Content of register rs should be shifted for pos before applying a mask. This change contains both fix for the instruction and to the existing test.

---
 target-mips/dsp_helper.c         |    2 +-
 tests/tcg/mips/mips32-dsp/insv.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
target-mips/dsp_helper.c +1 -1
index e7949c2..fda5f04 100644
@@ -3152,7 +3152,7 @@ target_ulong helper_##name(CPUMIPSState *env, target_ulong rs,  \
                                                                 \
     filter = ((int32_t)0x01 << size) - 1;                       \
     filter = filter << pos;                                     \
-    temprs = rs & filter;                                       \
+    temprs = (rs << pos) & filter;                              \
     temprt = rt & ~filter;                                      \
     temp = temprs | temprt;                                     \
                                                                 \
tests/tcg/mips/mips32-dsp/insv.c +0 -0
index 7e3b047..243b007 100644

tests/tcg/mips/mips32-dsp/insv.c int main() · line 16

Quoted 8 lines
tests/tcg/mips/mips32-dsp/insv.c +1 -1
@@ -10,7 +10,7 @@ int main()
     dsp    = 0x305;
     rt     = 0x12345678;
     rs     = 0x87654321;
-    result = 0x12345338;
+    result = 0x12345438;
     __asm
         ("wrdsp %2, 0x03\n\t"
          "insv  %0, %1\n\t"

Thanks, applied. I added a CC: to [email protected], as it is definitely stable material.

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net