[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/7] target/mips: Fix emulation of nanoMips BNEC[32] instruction
From: |
Stefan Pejic |
Subject: |
[PATCH 4/7] target/mips: Fix emulation of nanoMips BNEC[32] instruction |
Date: |
Wed, 4 May 2022 13:04:00 +0200 |
From: Dragan Mladjenovic <dragan.mladjenovic@syrmia.com>
If both rs and rt are the same register, the nanoMips instruction
BNEC[32] rs, rt, address is equivalent to NOP (branch is not taken and
there is no delay slot). This commit provides such behavior. Without
this commit, this scenario results in an incorrect behavior.
Signed-off-by: Dragan Mladjenovic <dragan.mladjenovic@syrmia.com>
Signed-off-by: Stefan Pejic <stefan.pejic@syrmia.com>
---
target/mips/tcg/nanomips_translate.c.inc | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/target/mips/tcg/nanomips_translate.c.inc
b/target/mips/tcg/nanomips_translate.c.inc
index 941cfaa6bb..1ee5c8c8d4 100644
--- a/target/mips/tcg/nanomips_translate.c.inc
+++ b/target/mips/tcg/nanomips_translate.c.inc
@@ -4528,7 +4528,12 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env,
DisasContext *ctx)
switch (extract32(ctx->opcode, 14, 2)) {
case NM_BNEC:
check_nms(ctx);
- gen_compute_branch_nm(ctx, OPC_BNE, 4, rs, rt, s);
+ if (rs == rt) {
+ /* NOP */
+ ctx->hflags |= MIPS_HFLAG_FBNSLOT;
+ } else {
+ gen_compute_branch_nm(ctx, OPC_BNE, 4, rs, rt, s);
+ }
break;
case NM_BLTC:
if (rs != 0 && rt != 0 && rs == rt) {
--
2.25.1
- [PATCH 0/7] Undeprecate nanoMIPS and fix multiple bugs, Stefan Pejic, 2022/05/04
- [PATCH 4/7] target/mips: Fix emulation of nanoMips BNEC[32] instruction,
Stefan Pejic <=
- [PATCH 5/7] target/mips: Fix handling of unaligned memory access for nanoMips ISA, Stefan Pejic, 2022/05/04
- [PATCH 1/7] target/mips: Fix emulation of nanoMips MTHLIP instruction, Stefan Pejic, 2022/05/04
- [PATCH 3/7] target/mips: Fix emulation of nanoMips BPOSGE32C instruction, Stefan Pejic, 2022/05/04
- [PATCH 2/7] target/mips: Fix emulation of nanoMips EXTRV_S.H instruction, Stefan Pejic, 2022/05/04
- [PATCH 6/7] target/mips: Add missing default cases for some nanoMips pools, Stefan Pejic, 2022/05/04