@@ -44,7 +44,7 @@ struct TCGCPUOps {
* state which are tracked insn-by-insn in the target-specific
* arguments to start_insn, passed as @data.
*/
- void (*restore_state_to_opc)(CPUState *cpu, const TranslationBlock *tb,
+ void (*restore_state_to_opc)(CPUArchState *env, const TranslationBlock *tb,
const uint64_t *data);
/** @cpu_exec_enter: Callback for cpu_exec preparation */
@@ -362,7 +362,7 @@ void arm_cpu_register_gdb_commands(ARMCPU *cpu);
void aarch64_cpu_register_gdb_commands(ARMCPU *cpu, GString *,
GPtrArray *, GPtrArray *);
-void arm_restore_state_to_opc(CPUState *cs,
+void arm_restore_state_to_opc(CPUARMState *env,
const TranslationBlock *tb,
const uint64_t *data);
@@ -21,7 +21,7 @@ void mips_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb);
G_NORETURN void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
MMUAccessType access_type, int mmu_idx,
uintptr_t retaddr);
-void mips_restore_state_to_opc(CPUState *cs,
+void mips_restore_state_to_opc(CPUMIPSState *env,
const TranslationBlock *tb,
const uint64_t *data);
@@ -399,7 +399,7 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3,
/* translate.c */
void s390x_translate_init(void);
-void s390x_restore_state_to_opc(CPUState *cs,
+void s390x_restore_state_to_opc(CPUS390XState *env,
const TranslationBlock *tb,
const uint64_t *data);
@@ -218,7 +218,7 @@ void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
cpu->neg.icount_decr.u16.low += insns_left;
}
- cpu->cc->tcg_ops->restore_state_to_opc(cpu, tb, data);
+ cpu->cc->tcg_ops->restore_state_to_opc(cpu_env(cpu), tb, data);
}
bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc)
@@ -47,12 +47,10 @@ static void alpha_cpu_synchronize_from_tb(CPUState *cs,
}
}
-static void alpha_restore_state_to_opc(CPUState *cs,
+static void alpha_restore_state_to_opc(CPUAlphaState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- CPUAlphaState *env = cpu_env(cs);
-
if (tb_cflags(tb) & CF_PCREL) {
env->pc = (env->pc & TARGET_PAGE_MASK) | data[0];
} else {
@@ -90,12 +90,10 @@ void arm_cpu_synchronize_from_tb(CPUState *cs,
}
}
-void arm_restore_state_to_opc(CPUState *cs,
+void arm_restore_state_to_opc(CPUARMState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- CPUARMState *env = cpu_env(cs);
-
if (is_a64(env)) {
if (tb_cflags(tb) & CF_PCREL) {
env->pc = (env->pc & TARGET_PAGE_MASK) | data[0];
@@ -55,11 +55,11 @@ static void avr_cpu_synchronize_from_tb(CPUState *cs,
cpu_env(cs)->pc_w = tb->pc / 2; /* internally PC points to words */
}
-static void avr_restore_state_to_opc(CPUState *cs,
+static void avr_restore_state_to_opc(CPUAVRState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- cpu_env(cs)->pc_w = data[0];
+ env->pc_w = data[0];
}
static void avr_cpu_reset_hold(Object *obj, ResetType type)
@@ -267,11 +267,11 @@ static bool hexagon_cpu_has_work(CPUState *cs)
return true;
}
-static void hexagon_restore_state_to_opc(CPUState *cs,
+static void hexagon_restore_state_to_opc(CPUHexagonState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- cpu_env(cs)->gpr[HEX_REG_PC] = data[0];
+ env->gpr[HEX_REG_PC] = data[0];
}
static void hexagon_cpu_reset_hold(Object *obj, ResetType type)
@@ -101,12 +101,10 @@ static void hppa_cpu_synchronize_from_tb(CPUState *cs,
cpu->env.psw_xb = tb->flags & (PSW_X | PSW_B);
}
-static void hppa_restore_state_to_opc(CPUState *cs,
+static void hppa_restore_state_to_opc(CPUHPPAState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- CPUHPPAState *env = cpu_env(cs);
-
env->iaoq_f = (env->iaoq_f & TARGET_PAGE_MASK) | data[0];
if (data[1] != INT32_MIN) {
env->iaoq_b = env->iaoq_f + data[1];
@@ -61,12 +61,10 @@ static void x86_cpu_synchronize_from_tb(CPUState *cs,
}
}
-static void x86_restore_state_to_opc(CPUState *cs,
+static void x86_restore_state_to_opc(CPUX86State *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- X86CPU *cpu = X86_CPU(cs);
- CPUX86State *env = &cpu->env;
int cc_op = data[1];
uint64_t new_pc;
@@ -340,11 +340,11 @@ static void loongarch_cpu_synchronize_from_tb(CPUState *cs,
set_pc(cpu_env(cs), tb->pc);
}
-static void loongarch_restore_state_to_opc(CPUState *cs,
+static void loongarch_restore_state_to_opc(CPULoongArchState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- set_pc(cpu_env(cs), data[0]);
+ set_pc(env, data[0]);
}
#endif /* CONFIG_TCG */
@@ -34,16 +34,15 @@ static vaddr m68k_cpu_get_pc(CPUM68KState *env)
return env->pc;
}
-static void m68k_restore_state_to_opc(CPUState *cs,
+static void m68k_restore_state_to_opc(CPUM68KState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- M68kCPU *cpu = M68K_CPU(cs);
int cc_op = data[1];
- cpu->env.pc = data[0];
+ env->pc = data[0];
if (cc_op != CC_OP_DYNAMIC) {
- cpu->env.cc_op = cc_op;
+ env->cc_op = cc_op;
}
}
@@ -100,14 +100,12 @@ static void mb_cpu_synchronize_from_tb(CPUState *cs,
cpu->env.iflags = tb->flags & IFLAGS_TB_MASK;
}
-static void mb_restore_state_to_opc(CPUState *cs,
+static void mb_restore_state_to_opc(CPUMBState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);
-
- cpu->env.pc = data[0];
- cpu->env.iflags = data[1];
+ env->pc = data[0];
+ env->iflags = data[1];
}
static bool mb_cpu_has_work(CPUState *cs)
@@ -15302,12 +15302,10 @@ void mips_tcg_init(void)
}
}
-void mips_restore_state_to_opc(CPUState *cs,
+void mips_restore_state_to_opc(CPUMIPSState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- CPUMIPSState *env = cpu_env(cs);
-
env->active_tc.PC = data[0];
env->hflags &= ~MIPS_HFLAG_BMASK;
env->hflags |= data[1];
@@ -45,16 +45,14 @@ static void openrisc_cpu_synchronize_from_tb(CPUState *cs,
cpu->env.pc = tb->pc;
}
-static void openrisc_restore_state_to_opc(CPUState *cs,
+static void openrisc_restore_state_to_opc(CPUOpenRISCState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- OpenRISCCPU *cpu = OPENRISC_CPU(cs);
-
- cpu->env.pc = data[0];
- cpu->env.dflag = data[1] & 1;
+ env->pc = data[0];
+ env->dflag = data[1] & 1;
if (data[1] & 2) {
- cpu->env.ppc = cpu->env.pc - 4;
+ env->ppc = env->pc - 4;
}
}
@@ -7163,13 +7163,11 @@ static vaddr ppc_cpu_get_pc(CPUPPCState *env)
}
#ifdef CONFIG_TCG
-static void ppc_restore_state_to_opc(CPUState *cs,
+static void ppc_restore_state_to_opc(CPUPPCState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- PowerPCCPU *cpu = POWERPC_CPU(cs);
-
- cpu->env.nip = data[0];
+ env->nip = data[0];
}
#endif /* CONFIG_TCG */
@@ -108,12 +108,10 @@ static void riscv_cpu_synchronize_from_tb(CPUState *cs,
}
}
-static void riscv_restore_state_to_opc(CPUState *cs,
+static void riscv_restore_state_to_opc(CPURISCVState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- RISCVCPU *cpu = RISCV_CPU(cs);
- CPURISCVState *env = &cpu->env;
RISCVMXL xl = FIELD_EX32(tb->flags, TB_FLAGS, XL);
target_ulong pc;
@@ -46,13 +46,11 @@ static void rx_cpu_synchronize_from_tb(CPUState *cs,
cpu->env.pc = tb->pc;
}
-static void rx_restore_state_to_opc(CPUState *cs,
+static void rx_restore_state_to_opc(CPURXState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- RXCPU *cpu = RX_CPU(cs);
-
- cpu->env.pc = data[0];
+ env->pc = data[0];
}
static bool rx_cpu_has_work(CPUState *cs)
@@ -6488,11 +6488,10 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
translator_loop(cs, tb, max_insns, pc, host_pc, &s390x_tr_ops, &dc.base);
}
-void s390x_restore_state_to_opc(CPUState *cs,
+void s390x_restore_state_to_opc(CPUS390XState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- CPUS390XState *env = cpu_env(cs);
int cc_op = data[1];
env->psw.addr = data[0];
@@ -48,14 +48,12 @@ static void superh_cpu_synchronize_from_tb(CPUState *cs,
cpu->env.flags = tb->flags & TB_FLAG_ENVFLAGS_MASK;
}
-static void superh_restore_state_to_opc(CPUState *cs,
+static void superh_restore_state_to_opc(CPUSH4State *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- SuperHCPU *cpu = SUPERH_CPU(cs);
-
- cpu->env.pc = data[0];
- cpu->env.flags = data[1];
+ env->pc = data[0];
+ env->flags = data[1];
/*
* Theoretically delayed_pc should also be restored. In practice the
* branch instruction is re-executed after exception, so the delayed
@@ -709,11 +709,10 @@ static void sparc_cpu_synchronize_from_tb(CPUState *cs,
cpu->env.npc = tb->cs_base;
}
-static void sparc_restore_state_to_opc(CPUState *cs,
+static void sparc_restore_state_to_opc(CPUSPARCState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- CPUSPARCState *env = cpu_env(cs);
target_ulong pc = data[0];
target_ulong npc = data[1];
@@ -51,11 +51,11 @@ static void tricore_cpu_synchronize_from_tb(CPUState *cs,
cpu_env(cs)->PC = tb->pc;
}
-static void tricore_restore_state_to_opc(CPUState *cs,
+static void tricore_restore_state_to_opc(CPUTriCoreState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- cpu_env(cs)->PC = data[0];
+ env->PC = data[0];
}
static void tricore_cpu_reset_hold(Object *obj, ResetType type)
@@ -50,13 +50,11 @@ static vaddr xtensa_cpu_get_pc(CPUXtensaState *env)
return env->pc;
}
-static void xtensa_restore_state_to_opc(CPUState *cs,
+static void xtensa_restore_state_to_opc(CPUXtensaState *env,
const TranslationBlock *tb,
const uint64_t *data)
{
- XtensaCPU *cpu = XTENSA_CPU(cs);
-
- cpu->env.pc = data[0];
+ env->pc = data[0];
}
static bool xtensa_cpu_has_work(CPUState *cs)
CPUClass::restore_state_to_opc() handler is target specific. Rather than passing a generic CPUState and forcing QOM casts, we can directly pass the target CPUArchState, simplifying. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- include/hw/core/tcg-cpu-ops.h | 2 +- target/arm/internals.h | 2 +- target/mips/tcg/tcg-internal.h | 2 +- target/s390x/s390x-internal.h | 2 +- accel/tcg/translate-all.c | 2 +- target/alpha/cpu.c | 4 +--- target/arm/cpu.c | 4 +--- target/avr/cpu.c | 4 ++-- target/hexagon/cpu.c | 4 ++-- target/hppa/cpu.c | 4 +--- target/i386/tcg/tcg-cpu.c | 4 +--- target/loongarch/cpu.c | 4 ++-- target/m68k/cpu.c | 7 +++---- target/microblaze/cpu.c | 8 +++----- target/mips/tcg/translate.c | 4 +--- target/openrisc/cpu.c | 10 ++++------ target/ppc/cpu_init.c | 6 ++---- target/riscv/tcg/tcg-cpu.c | 4 +--- target/rx/cpu.c | 6 ++---- target/s390x/tcg/translate.c | 3 +-- target/sh4/cpu.c | 8 +++----- target/sparc/cpu.c | 3 +-- target/tricore/cpu.c | 4 ++-- target/xtensa/cpu.c | 6 ++---- 24 files changed, 40 insertions(+), 67 deletions(-)