target/mips: nanoMIPS: Fix branch handling

Fix nanoMIPS branch handling.

Backports commit 697b7b6bc570c0fe4e32d079930fea6cd4cace6b from qemu
This commit is contained in:
Stefan Markovic 2019-01-25 12:50:15 -05:00 committed by Lioncash
parent dbeb82e424
commit 9a064bafe3
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -19884,6 +19884,10 @@ static void gen_compute_imm_branch(DisasContext *ctx, uint32_t opc,
goto out;
}
/* branch completion */
clear_branch_hflags(ctx);
ctx->base.is_jmp = DISAS_NORETURN;
if (bcond_compute == 0) {
/* Uncoditional compact branch */
gen_goto_tb(ctx, 0, ctx->btarget);
@ -19925,6 +19929,10 @@ static void gen_compute_nanomips_pbalrsc_branch(DisasContext *ctx, int rs,
tcg_gen_movi_tl(tcg_ctx, t1, ctx->base.pc_next + 4);
gen_op_addr_add(ctx, tcg_ctx->btarget, t1, t0);
/* branch completion */
clear_branch_hflags(ctx);
ctx->base.is_jmp = DISAS_NORETURN;
/* unconditional branch to register */
tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_PC, tcg_ctx->btarget);
tcg_gen_lookup_and_goto_ptr(tcg_ctx);
@ -20064,6 +20072,10 @@ static void gen_compute_compact_branch_nm(DisasContext *ctx, uint32_t opc,
goto out;
}
/* branch completion */
clear_branch_hflags(ctx);
ctx->base.is_jmp = DISAS_NORETURN;
/* Generating branch here as compact branches don't have delay slot */
gen_goto_tb(ctx, 1, ctx->btarget);
gen_set_label(tcg_ctx, fs);