diff options
-rw-r--r-- | target-mips/translate.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/target-mips/translate.c b/target-mips/translate.c index 0e2443a032..a91e5037f5 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -10531,14 +10531,25 @@ static void gen_rdhwr(DisasContext *ctx, int rt, int rd) tcg_temp_free(t0); } +static inline void clear_branch_hflags(DisasContext *ctx) +{ + ctx->hflags &= ~MIPS_HFLAG_BMASK; + if (ctx->bstate == BS_NONE) { + save_cpu_state(ctx, 0); + } else { + /* it is not safe to save ctx->hflags as hflags may be changed + in execution time by the instruction in delay / forbidden slot. */ + tcg_gen_andi_i32(hflags, hflags, ~MIPS_HFLAG_BMASK); + } +} + static void gen_branch(DisasContext *ctx, int insn_bytes) { if (ctx->hflags & MIPS_HFLAG_BMASK) { int proc_hflags = ctx->hflags & MIPS_HFLAG_BMASK; /* Branches completion */ - ctx->hflags &= ~MIPS_HFLAG_BMASK; + clear_branch_hflags(ctx); ctx->bstate = BS_BRANCH; - save_cpu_state(ctx, 0); /* FIXME: Need to clear can_do_io. */ switch (proc_hflags & MIPS_HFLAG_BMASK_BASE) { case MIPS_HFLAG_FBNSLOT: @@ -10596,8 +10607,8 @@ static void gen_branch(DisasContext *ctx, int insn_bytes) tcg_gen_exit_tb(0); break; default: - MIPS_DEBUG("unknown branch"); - break; + fprintf(stderr, "unknown branch 0x%x\n", proc_hflags); + abort(); } } } |