diff options
author | Dragan Mladjenovic | 2022-05-04 13:04:00 +0200 |
---|---|---|
committer | Philippe Mathieu-Daudé | 2022-06-11 11:35:48 +0200 |
commit | 14668cfaaf4d6f818d9e6b58dd44b75842654e2a (patch) | |
tree | e5bec46f33323072f5aa23628d3839e66105bf3d /target/mips | |
parent | target/mips: Fix emulation of nanoMIPS BPOSGE32C instruction (diff) | |
download | qemu-14668cfaaf4d6f818d9e6b58dd44b75842654e2a.tar.gz qemu-14668cfaaf4d6f818d9e6b58dd44b75842654e2a.tar.xz qemu-14668cfaaf4d6f818d9e6b58dd44b75842654e2a.zip |
target/mips: Fix emulation of nanoMIPS BNEC[32] instruction
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>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20220504110403.613168-5-stefan.pejic@syrmia.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Diffstat (limited to 'target/mips')
-rw-r--r-- | target/mips/tcg/nanomips_translate.c.inc | 7 |
1 files changed, 6 insertions, 1 deletions
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) { |