tcg: Pass data argument to restore_state_to_opc

The gen_opc_* arrays are already redundant with the data stored in
the insn_start arguments.  Transition restore_state_to_opc to use
data from the latter.

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
Richard Henderson 2015-09-01 15:51:12 -07:00
parent 190ce7fbc7
commit bad729e272
22 changed files with 79 additions and 66 deletions

View File

@ -75,7 +75,7 @@ typedef struct TranslationBlock TranslationBlock;
void gen_intermediate_code(CPUArchState *env, struct TranslationBlock *tb); void gen_intermediate_code(CPUArchState *env, struct TranslationBlock *tb);
void gen_intermediate_code_pc(CPUArchState *env, struct TranslationBlock *tb); void gen_intermediate_code_pc(CPUArchState *env, struct TranslationBlock *tb);
void restore_state_to_opc(CPUArchState *env, struct TranslationBlock *tb, void restore_state_to_opc(CPUArchState *env, struct TranslationBlock *tb,
int pc_pos); target_ulong *data);
void cpu_gen_init(void); void cpu_gen_init(void);
bool cpu_restore_state(CPUState *cpu, uintptr_t searched_pc); bool cpu_restore_state(CPUState *cpu, uintptr_t searched_pc);

View File

@ -3023,7 +3023,8 @@ void gen_intermediate_code_pc (CPUAlphaState *env, struct TranslationBlock *tb)
gen_intermediate_code_internal(alpha_env_get_cpu(env), tb, true); gen_intermediate_code_internal(alpha_env_get_cpu(env), tb, true);
} }
void restore_state_to_opc(CPUAlphaState *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUAlphaState *env, TranslationBlock *tb,
target_ulong *data)
{ {
env->pc = tcg_ctx.gen_opc_pc[pc_pos]; env->pc = data[0];
} }

View File

@ -11612,13 +11612,14 @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
} }
} }
void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb,
target_ulong *data)
{ {
if (is_a64(env)) { if (is_a64(env)) {
env->pc = tcg_ctx.gen_opc_pc[pc_pos]; env->pc = data[0];
env->condexec_bits = 0; env->condexec_bits = 0;
} else { } else {
env->regs[15] = tcg_ctx.gen_opc_pc[pc_pos]; env->regs[15] = data[0];
env->condexec_bits = gen_opc_condexec_bits[pc_pos]; env->condexec_bits = data[1];
} }
} }

View File

@ -3433,7 +3433,8 @@ void cris_initialize_tcg(void)
} }
} }
void restore_state_to_opc(CPUCRISState *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUCRISState *env, TranslationBlock *tb,
target_ulong *data)
{ {
env->pc = tcg_ctx.gen_opc_pc[pc_pos]; env->pc = data[0];
} }

View File

@ -8055,26 +8055,12 @@ void gen_intermediate_code_pc(CPUX86State *env, TranslationBlock *tb)
gen_intermediate_code_internal(x86_env_get_cpu(env), tb, true); gen_intermediate_code_internal(x86_env_get_cpu(env), tb, true);
} }
void restore_state_to_opc(CPUX86State *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUX86State *env, TranslationBlock *tb,
target_ulong *data)
{ {
int cc_op; int cc_op = data[1];
#ifdef DEBUG_DISAS env->eip = data[0] - tb->cs_base;
if (qemu_loglevel_mask(CPU_LOG_TB_OP)) { if (cc_op != CC_OP_DYNAMIC) {
int i;
qemu_log("RESTORE:\n");
for(i = 0;i <= pc_pos; i++) {
if (tcg_ctx.gen_opc_instr_start[i]) {
qemu_log("0x%04x: " TARGET_FMT_lx "\n", i,
tcg_ctx.gen_opc_pc[i]);
}
}
qemu_log("pc_pos=0x%x eip=" TARGET_FMT_lx " cs_base=%x\n",
pc_pos, tcg_ctx.gen_opc_pc[pc_pos] - tb->cs_base,
(uint32_t)tb->cs_base);
}
#endif
env->eip = tcg_ctx.gen_opc_pc[pc_pos] - tb->cs_base;
cc_op = gen_opc_cc_op[pc_pos];
if (cc_op != CC_OP_DYNAMIC)
env->cc_op = cc_op; env->cc_op = cc_op;
}
} }

View File

@ -1207,9 +1207,10 @@ void lm32_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
cpu_fprintf(f, "\n\n"); cpu_fprintf(f, "\n\n");
} }
void restore_state_to_opc(CPULM32State *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPULM32State *env, TranslationBlock *tb,
target_ulong *data)
{ {
env->pc = tcg_ctx.gen_opc_pc[pc_pos]; env->pc = data[0];
} }
void lm32_translate_init(void) void lm32_translate_init(void)

View File

@ -3118,7 +3118,8 @@ void m68k_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
cpu_fprintf (f, "FPRESULT = %12g\n", *(double *)&env->fp_result); cpu_fprintf (f, "FPRESULT = %12g\n", *(double *)&env->fp_result);
} }
void restore_state_to_opc(CPUM68KState *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUM68KState *env, TranslationBlock *tb,
target_ulong *data)
{ {
env->pc = tcg_ctx.gen_opc_pc[pc_pos]; env->pc = data[0];
} }

View File

@ -1928,7 +1928,8 @@ void mb_tcg_init(void)
} }
} }
void restore_state_to_opc(CPUMBState *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUMBState *env, TranslationBlock *tb,
target_ulong *data)
{ {
env->sregs[SR_PC] = tcg_ctx.gen_opc_pc[pc_pos]; env->sregs[SR_PC] = data[0];
} }

View File

@ -20061,18 +20061,19 @@ void cpu_state_reset(CPUMIPSState *env)
} }
} }
void restore_state_to_opc(CPUMIPSState *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUMIPSState *env, TranslationBlock *tb,
target_ulong *data)
{ {
env->active_tc.PC = tcg_ctx.gen_opc_pc[pc_pos]; env->active_tc.PC = data[0];
env->hflags &= ~MIPS_HFLAG_BMASK; env->hflags &= ~MIPS_HFLAG_BMASK;
env->hflags |= gen_opc_hflags[pc_pos]; env->hflags |= data[1];
switch (env->hflags & MIPS_HFLAG_BMASK_BASE) { switch (env->hflags & MIPS_HFLAG_BMASK_BASE) {
case MIPS_HFLAG_BR: case MIPS_HFLAG_BR:
break; break;
case MIPS_HFLAG_BC: case MIPS_HFLAG_BC:
case MIPS_HFLAG_BL: case MIPS_HFLAG_BL:
case MIPS_HFLAG_B: case MIPS_HFLAG_B:
env->btarget = gen_opc_btarget[pc_pos]; env->btarget = data[2];
break; break;
} }
} }

View File

@ -922,7 +922,8 @@ void gen_intermediate_code_pc(CPUMoxieState *env, struct TranslationBlock *tb)
gen_intermediate_code_internal(moxie_env_get_cpu(env), tb, true); gen_intermediate_code_internal(moxie_env_get_cpu(env), tb, true);
} }
void restore_state_to_opc(CPUMoxieState *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUMoxieState *env, TranslationBlock *tb,
target_ulong *data)
{ {
env->pc = tcg_ctx.gen_opc_pc[pc_pos]; env->pc = data[0];
} }

View File

@ -1794,7 +1794,7 @@ void openrisc_cpu_dump_state(CPUState *cs, FILE *f,
} }
void restore_state_to_opc(CPUOpenRISCState *env, TranslationBlock *tb, void restore_state_to_opc(CPUOpenRISCState *env, TranslationBlock *tb,
int pc_pos) target_ulong *data)
{ {
env->pc = tcg_ctx.gen_opc_pc[pc_pos]; env->pc = data[0];
} }

View File

@ -11629,7 +11629,8 @@ void gen_intermediate_code_pc (CPUPPCState *env, struct TranslationBlock *tb)
gen_intermediate_code_internal(ppc_env_get_cpu(env), tb, true); gen_intermediate_code_internal(ppc_env_get_cpu(env), tb, true);
} }
void restore_state_to_opc(CPUPPCState *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUPPCState *env, TranslationBlock *tb,
target_ulong *data)
{ {
env->nip = tcg_ctx.gen_opc_pc[pc_pos]; env->nip = data[0];
} }

View File

@ -5460,11 +5460,11 @@ void gen_intermediate_code_pc (CPUS390XState *env, struct TranslationBlock *tb)
gen_intermediate_code_internal(s390_env_get_cpu(env), tb, true); gen_intermediate_code_internal(s390_env_get_cpu(env), tb, true);
} }
void restore_state_to_opc(CPUS390XState *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUS390XState *env, TranslationBlock *tb,
target_ulong *data)
{ {
int cc_op; int cc_op = data[1];
env->psw.addr = tcg_ctx.gen_opc_pc[pc_pos]; env->psw.addr = data[0];
cc_op = gen_opc_cc_op[pc_pos];
if ((cc_op != CC_OP_DYNAMIC) && (cc_op != CC_OP_STATIC)) { if ((cc_op != CC_OP_DYNAMIC) && (cc_op != CC_OP_STATIC)) {
env->cc_op = cc_op; env->cc_op = cc_op;
} }

View File

@ -1950,8 +1950,9 @@ void gen_intermediate_code_pc(CPUSH4State * env, struct TranslationBlock *tb)
gen_intermediate_code_internal(sh_env_get_cpu(env), tb, true); gen_intermediate_code_internal(sh_env_get_cpu(env), tb, true);
} }
void restore_state_to_opc(CPUSH4State *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUSH4State *env, TranslationBlock *tb,
target_ulong *data)
{ {
env->pc = tcg_ctx.gen_opc_pc[pc_pos]; env->pc = data[0];
env->flags = gen_opc_hflags[pc_pos]; env->flags = data[1];
} }

View File

@ -5459,11 +5459,13 @@ void gen_intermediate_code_init(CPUSPARCState *env)
} }
} }
void restore_state_to_opc(CPUSPARCState *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUSPARCState *env, TranslationBlock *tb,
target_ulong *data)
{ {
target_ulong pc, npc; target_ulong pc = data[0];
env->pc = pc = tcg_ctx.gen_opc_pc[pc_pos]; target_ulong npc = data[1];
npc = gen_opc_npc[pc_pos];
env->pc = pc;
if (npc == DYNAMIC_PC) { if (npc == DYNAMIC_PC) {
/* dynamic NPC: already stored */ /* dynamic NPC: already stored */
} else if (npc & JUMP_PC) { } else if (npc & JUMP_PC) {

View File

@ -2144,9 +2144,10 @@ void gen_intermediate_code_pc(CPUTLGState *env, struct TranslationBlock *tb)
gen_intermediate_code_internal(tilegx_env_get_cpu(env), tb, true); gen_intermediate_code_internal(tilegx_env_get_cpu(env), tb, true);
} }
void restore_state_to_opc(CPUTLGState *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUTLGState *env, TranslationBlock *tb,
target_ulong *data)
{ {
env->pc = tcg_ctx.gen_opc_pc[pc_pos]; env->pc = data[0];
} }
void tilegx_tcg_init(void) void tilegx_tcg_init(void)

View File

@ -8350,9 +8350,10 @@ gen_intermediate_code_pc(CPUTriCoreState *env, struct TranslationBlock *tb)
} }
void void
restore_state_to_opc(CPUTriCoreState *env, TranslationBlock *tb, int pc_pos) restore_state_to_opc(CPUTriCoreState *env, TranslationBlock *tb,
target_ulong *data)
{ {
env->PC = tcg_ctx.gen_opc_pc[pc_pos]; env->PC = data[0];
} }
/* /*
* *

View File

@ -2129,7 +2129,8 @@ void uc32_cpu_dump_state(CPUState *cs, FILE *f,
cpu_dump_state_ucf64(env, f, cpu_fprintf, flags); cpu_dump_state_ucf64(env, f, cpu_fprintf, flags);
} }
void restore_state_to_opc(CPUUniCore32State *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUUniCore32State *env, TranslationBlock *tb,
target_ulong *data)
{ {
env->regs[31] = tcg_ctx.gen_opc_pc[pc_pos]; env->regs[31] = data[0];
} }

View File

@ -3202,7 +3202,8 @@ void xtensa_cpu_dump_state(CPUState *cs, FILE *f,
} }
} }
void restore_state_to_opc(CPUXtensaState *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUXtensaState *env, TranslationBlock *tb,
target_ulong *data)
{ {
env->pc = tcg_ctx.gen_opc_pc[pc_pos]; env->pc = data[0];
} }

View File

@ -2294,7 +2294,7 @@ static inline int tcg_gen_code_common(TCGContext *s,
tcg_insn_unit *gen_code_buf, tcg_insn_unit *gen_code_buf,
long search_pc) long search_pc)
{ {
int oi, oi_next; int i, oi, oi_next;
#ifdef DEBUG_DISAS #ifdef DEBUG_DISAS
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP))) { if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP))) {
@ -2361,6 +2361,15 @@ static inline int tcg_gen_code_common(TCGContext *s,
tcg_reg_alloc_movi(s, args, dead_args, sync_args); tcg_reg_alloc_movi(s, args, dead_args, sync_args);
break; break;
case INDEX_op_insn_start: case INDEX_op_insn_start:
for (i = 0; i < TARGET_INSN_START_WORDS; ++i) {
target_ulong a;
#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
a = ((target_ulong)args[i * 2 + 1] << 32) | args[i * 2];
#else
a = args[i];
#endif
s->gen_opc_data[i] = a;
}
break; break;
case INDEX_op_discard: case INDEX_op_discard:
temp_dead(s, args[0]); temp_dead(s, args[0]);

View File

@ -580,6 +580,8 @@ struct TCGContext {
target_ulong gen_opc_pc[OPC_BUF_SIZE]; target_ulong gen_opc_pc[OPC_BUF_SIZE];
uint16_t gen_opc_icount[OPC_BUF_SIZE]; uint16_t gen_opc_icount[OPC_BUF_SIZE];
uint8_t gen_opc_instr_start[OPC_BUF_SIZE]; uint8_t gen_opc_instr_start[OPC_BUF_SIZE];
target_ulong gen_opc_data[TARGET_INSN_START_WORDS];
}; };
extern TCGContext tcg_ctx; extern TCGContext tcg_ctx;

View File

@ -218,7 +218,7 @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
} }
cpu->icount_decr.u16.low -= s->gen_opc_icount[j]; cpu->icount_decr.u16.low -= s->gen_opc_icount[j];
restore_state_to_opc(env, tb, j); restore_state_to_opc(env, tb, s->gen_opc_data);
#ifdef CONFIG_PROFILER #ifdef CONFIG_PROFILER
s->restore_time += profile_getclock() - ti; s->restore_time += profile_getclock() - ti;