mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
target/mips: Extract trap code into env->error_code
Simplify cpu_loop by doing all of the decode in translate. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220107213243.212806-18-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
parent
6f3533dd1b
commit
0a3336f6fd
4 changed files with 25 additions and 48 deletions
|
@ -4733,7 +4733,7 @@ static void gen_loongson_lsdc2(DisasContext *ctx, int rt,
|
|||
|
||||
/* Traps */
|
||||
static void gen_trap(DisasContext *ctx, uint32_t opc,
|
||||
int rs, int rt, int16_t imm)
|
||||
int rs, int rt, int16_t imm, int code)
|
||||
{
|
||||
int cond;
|
||||
TCGv t0 = tcg_temp_new();
|
||||
|
@ -4778,6 +4778,11 @@ static void gen_trap(DisasContext *ctx, uint32_t opc,
|
|||
case OPC_TGEU: /* rs >= rs unsigned */
|
||||
case OPC_TGEIU: /* r0 >= 0 unsigned */
|
||||
/* Always trap */
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
/* Pass the break code along to cpu_loop. */
|
||||
tcg_gen_st_i32(tcg_constant_i32(code), cpu_env,
|
||||
offsetof(CPUMIPSState, error_code));
|
||||
#endif
|
||||
generate_exception_end(ctx, EXCP_TRAP);
|
||||
break;
|
||||
case OPC_TLT: /* rs < rs */
|
||||
|
@ -4818,6 +4823,18 @@ static void gen_trap(DisasContext *ctx, uint32_t opc,
|
|||
tcg_gen_brcond_tl(TCG_COND_EQ, t0, t1, l1);
|
||||
break;
|
||||
}
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
/* Pass the break code along to cpu_loop. */
|
||||
tcg_gen_st_i32(tcg_constant_i32(code), cpu_env,
|
||||
offsetof(CPUMIPSState, error_code));
|
||||
#endif
|
||||
/* Like save_cpu_state, only don't update saved values. */
|
||||
if (ctx->base.pc_next != ctx->saved_pc) {
|
||||
gen_save_pc(ctx->base.pc_next);
|
||||
}
|
||||
if (ctx->hflags != ctx->saved_hflags) {
|
||||
tcg_gen_movi_i32(hflags, ctx->hflags);
|
||||
}
|
||||
generate_exception(ctx, EXCP_TRAP);
|
||||
gen_set_label(l1);
|
||||
}
|
||||
|
@ -14155,7 +14172,7 @@ static void decode_opc_special(CPUMIPSState *env, DisasContext *ctx)
|
|||
case OPC_TEQ:
|
||||
case OPC_TNE:
|
||||
check_insn(ctx, ISA_MIPS2);
|
||||
gen_trap(ctx, op1, rs, rt, -1);
|
||||
gen_trap(ctx, op1, rs, rt, -1, extract32(ctx->opcode, 6, 10));
|
||||
break;
|
||||
case OPC_PMON:
|
||||
/* Pmon entry point, also R4010 selsl */
|
||||
|
@ -15289,11 +15306,10 @@ static bool decode_opc_legacy(CPUMIPSState *env, DisasContext *ctx)
|
|||
case OPC_TLTI:
|
||||
case OPC_TLTIU:
|
||||
case OPC_TEQI:
|
||||
|
||||
case OPC_TNEI:
|
||||
check_insn(ctx, ISA_MIPS2);
|
||||
check_insn_opc_removed(ctx, ISA_MIPS_R6);
|
||||
gen_trap(ctx, op1, rs, -1, imm);
|
||||
gen_trap(ctx, op1, rs, -1, imm, 0);
|
||||
break;
|
||||
case OPC_SIGRIE:
|
||||
check_insn(ctx, ISA_MIPS_R6);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue