tcg: Make cpu_npc a TCGv

This commit is contained in:
Lioncash 2018-02-21 01:25:40 -05:00
parent 6ccd4479d7
commit e5401deb09
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
3 changed files with 18 additions and 20 deletions

View file

@ -308,12 +308,12 @@ static inline void gen_goto_tb(DisasContext *s, int tb_num,
/* jump to same page: we can use a direct jump */ /* jump to same page: we can use a direct jump */
tcg_gen_goto_tb(tcg_ctx, tb_num); tcg_gen_goto_tb(tcg_ctx, tb_num);
tcg_gen_movi_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, pc); tcg_gen_movi_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, pc);
tcg_gen_movi_tl(tcg_ctx, *(TCGv *)tcg_ctx->cpu_npc, npc); tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_npc, npc);
tcg_gen_exit_tb(tcg_ctx, (uintptr_t)tb + tb_num); tcg_gen_exit_tb(tcg_ctx, (uintptr_t)tb + tb_num);
} else { } else {
/* jump to another page: currently not optimized */ /* jump to another page: currently not optimized */
tcg_gen_movi_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, pc); tcg_gen_movi_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, pc);
tcg_gen_movi_tl(tcg_ctx, *(TCGv *)tcg_ctx->cpu_npc, npc); tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_npc, npc);
tcg_gen_exit_tb(tcg_ctx, 0); tcg_gen_exit_tb(tcg_ctx, 0);
} }
} }
@ -1043,12 +1043,12 @@ static void gen_branch_n(DisasContext *dc, target_ulong pc1)
} else { } else {
TCGv t, z; TCGv t, z;
tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc); tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, tcg_ctx->cpu_npc);
tcg_gen_addi_tl(tcg_ctx, *(TCGv *)tcg_ctx->cpu_npc, *(TCGv *)tcg_ctx->cpu_npc, 4); tcg_gen_addi_tl(tcg_ctx, tcg_ctx->cpu_npc, tcg_ctx->cpu_npc, 4);
t = tcg_const_tl(tcg_ctx, pc1); t = tcg_const_tl(tcg_ctx, pc1);
z = tcg_const_tl(tcg_ctx, 0); z = tcg_const_tl(tcg_ctx, 0);
tcg_gen_movcond_tl(tcg_ctx, TCG_COND_NE, *(TCGv *)tcg_ctx->cpu_npc, tcg_ctx->cpu_cond, z, t, *(TCGv *)tcg_ctx->cpu_npc); tcg_gen_movcond_tl(tcg_ctx, TCG_COND_NE, tcg_ctx->cpu_npc, tcg_ctx->cpu_cond, z, t, tcg_ctx->cpu_npc);
tcg_temp_free(tcg_ctx, t); tcg_temp_free(tcg_ctx, t);
tcg_temp_free(tcg_ctx, z); tcg_temp_free(tcg_ctx, z);
@ -1064,7 +1064,7 @@ static inline void gen_generic_branch(DisasContext *dc)
TCGv npc1 = tcg_const_tl(tcg_ctx, dc->jump_pc[1]); TCGv npc1 = tcg_const_tl(tcg_ctx, dc->jump_pc[1]);
TCGv zero = tcg_const_tl(tcg_ctx, 0); TCGv zero = tcg_const_tl(tcg_ctx, 0);
tcg_gen_movcond_tl(tcg_ctx, TCG_COND_NE, *(TCGv *)tcg_ctx->cpu_npc, tcg_ctx->cpu_cond, zero, npc0, npc1); tcg_gen_movcond_tl(tcg_ctx, TCG_COND_NE, tcg_ctx->cpu_npc, tcg_ctx->cpu_cond, zero, npc0, npc1);
tcg_temp_free(tcg_ctx, npc0); tcg_temp_free(tcg_ctx, npc0);
tcg_temp_free(tcg_ctx, npc1); tcg_temp_free(tcg_ctx, npc1);
@ -1088,7 +1088,7 @@ static inline void save_npc(DisasContext *dc)
gen_generic_branch(dc); gen_generic_branch(dc);
dc->npc = DYNAMIC_PC; dc->npc = DYNAMIC_PC;
} else if (dc->npc != DYNAMIC_PC) { } else if (dc->npc != DYNAMIC_PC) {
tcg_gen_movi_tl(tcg_ctx, *(TCGv *)tcg_ctx->cpu_npc, dc->npc); tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_npc, dc->npc);
} }
} }
@ -1113,10 +1113,10 @@ static inline void gen_mov_pc_npc(DisasContext *dc)
TCGContext *tcg_ctx = dc->uc->tcg_ctx; TCGContext *tcg_ctx = dc->uc->tcg_ctx;
if (dc->npc == JUMP_PC) { if (dc->npc == JUMP_PC) {
gen_generic_branch(dc); gen_generic_branch(dc);
tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc); tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, tcg_ctx->cpu_npc);
dc->pc = DYNAMIC_PC; dc->pc = DYNAMIC_PC;
} else if (dc->npc == DYNAMIC_PC) { } else if (dc->npc == DYNAMIC_PC) {
tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc); tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, tcg_ctx->cpu_npc);
dc->pc = DYNAMIC_PC; dc->pc = DYNAMIC_PC;
} else { } else {
dc->pc = dc->npc; dc->pc = dc->npc;
@ -1126,8 +1126,8 @@ static inline void gen_mov_pc_npc(DisasContext *dc)
static inline void gen_op_next_insn(DisasContext *dc) static inline void gen_op_next_insn(DisasContext *dc)
{ {
TCGContext *tcg_ctx = dc->uc->tcg_ctx; TCGContext *tcg_ctx = dc->uc->tcg_ctx;
tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc); tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, tcg_ctx->cpu_npc);
tcg_gen_addi_tl(tcg_ctx, *(TCGv *)tcg_ctx->cpu_npc, *(TCGv *)tcg_ctx->cpu_npc, 4); tcg_gen_addi_tl(tcg_ctx, tcg_ctx->cpu_npc, tcg_ctx->cpu_npc, 4);
} }
static void free_compare(TCGContext *tcg_ctx, DisasCompare *cmp) static void free_compare(TCGContext *tcg_ctx, DisasCompare *cmp)
@ -1492,7 +1492,7 @@ static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc)
} else { } else {
dc->pc = dc->npc; dc->pc = dc->npc;
dc->npc = target; dc->npc = target;
tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc); tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, tcg_ctx->cpu_npc);
} }
} else { } else {
flush_cond(dc); flush_cond(dc);
@ -1533,7 +1533,7 @@ static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc)
} else { } else {
dc->pc = dc->npc; dc->pc = dc->npc;
dc->npc = target; dc->npc = target;
tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc); tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, tcg_ctx->cpu_npc);
} }
} else { } else {
flush_cond(dc); flush_cond(dc);
@ -4631,7 +4631,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn, bool hook_ins
r_const = tcg_const_i32(tcg_ctx, 3); r_const = tcg_const_i32(tcg_ctx, 3);
gen_helper_check_align(tcg_ctx, tcg_ctx->cpu_env, cpu_tmp0, r_const); gen_helper_check_align(tcg_ctx, tcg_ctx->cpu_env, cpu_tmp0, r_const);
tcg_temp_free_i32(tcg_ctx, r_const); tcg_temp_free_i32(tcg_ctx, r_const);
tcg_gen_mov_tl(tcg_ctx, *(TCGv *)tcg_ctx->cpu_npc, cpu_tmp0); tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_npc, cpu_tmp0);
dc->npc = DYNAMIC_PC; dc->npc = DYNAMIC_PC;
goto jmp_insn; goto jmp_insn;
#endif #endif
@ -4664,7 +4664,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn, bool hook_ins
gen_helper_check_align(tcg_ctx, tcg_ctx->cpu_env, cpu_tmp0, r_const); gen_helper_check_align(tcg_ctx, tcg_ctx->cpu_env, cpu_tmp0, r_const);
tcg_temp_free_i32(tcg_ctx, r_const); tcg_temp_free_i32(tcg_ctx, r_const);
gen_address_mask(dc, cpu_tmp0); gen_address_mask(dc, cpu_tmp0);
tcg_gen_mov_tl(tcg_ctx, *(TCGv *)tcg_ctx->cpu_npc, cpu_tmp0); tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_npc, cpu_tmp0);
dc->npc = DYNAMIC_PC; dc->npc = DYNAMIC_PC;
} }
goto jmp_insn; goto jmp_insn;
@ -4679,7 +4679,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn, bool hook_ins
r_const = tcg_const_i32(tcg_ctx, 3); r_const = tcg_const_i32(tcg_ctx, 3);
gen_helper_check_align(tcg_ctx, tcg_ctx->cpu_env, cpu_tmp0, r_const); gen_helper_check_align(tcg_ctx, tcg_ctx->cpu_env, cpu_tmp0, r_const);
tcg_temp_free_i32(tcg_ctx, r_const); tcg_temp_free_i32(tcg_ctx, r_const);
tcg_gen_mov_tl(tcg_ctx, *(TCGv *)tcg_ctx->cpu_npc, cpu_tmp0); tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_npc, cpu_tmp0);
dc->npc = DYNAMIC_PC; dc->npc = DYNAMIC_PC;
gen_helper_rett(tcg_ctx, tcg_ctx->cpu_env); gen_helper_rett(tcg_ctx, tcg_ctx->cpu_env);
} }
@ -5606,8 +5606,7 @@ void gen_intermediate_code_init(CPUSPARCState *env)
tcg_ctx->sparc_cpu_pc = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUSPARCState, pc), tcg_ctx->sparc_cpu_pc = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUSPARCState, pc),
"pc"); "pc");
tcg_ctx->cpu_npc = g_malloc0(sizeof(TCGv)); tcg_ctx->cpu_npc = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUSPARCState, npc),
*(TCGv *)tcg_ctx->cpu_npc = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUSPARCState, npc),
"npc"); "npc");
tcg_ctx->cpu_y = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUSPARCState, y), "y"); tcg_ctx->cpu_y = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUSPARCState, y), "y");

View file

@ -38,7 +38,6 @@ void sparc_release(void *ctx)
g_free(tcg_ctx->cpu_cc_src); g_free(tcg_ctx->cpu_cc_src);
g_free(tcg_ctx->cpu_cc_src2); g_free(tcg_ctx->cpu_cc_src2);
g_free(tcg_ctx->cpu_cc_dst); g_free(tcg_ctx->cpu_cc_dst);
g_free(tcg_ctx->cpu_npc);
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
g_free(tcg_ctx->cpu_regs_sparc[i]); g_free(tcg_ctx->cpu_regs_sparc[i]);

View file

@ -834,7 +834,7 @@ struct TCGContext {
TCGv cpu_fsr; TCGv cpu_fsr;
TCGv sparc_cpu_pc; TCGv sparc_cpu_pc;
void *cpu_npc; TCGv cpu_npc;
void *cpu_regs_sparc[32]; void *cpu_regs_sparc[32];
TCGv cpu_y; TCGv cpu_y;
TCGv cpu_tbr; TCGv cpu_tbr;