tcg: Make sparc_cpu_pc a TCGv

This commit is contained in:
Lioncash 2018-02-21 01:23:58 -05:00
parent e5a776b495
commit 6ccd4479d7
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
3 changed files with 12 additions and 14 deletions

View file

@ -307,12 +307,12 @@ static inline void gen_goto_tb(DisasContext *s, int tb_num,
!s->singlestep) {
/* jump to same page: we can use a direct jump */
tcg_gen_goto_tb(tcg_ctx, tb_num);
tcg_gen_movi_tl(tcg_ctx, *(TCGv *)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_exit_tb(tcg_ctx, (uintptr_t)tb + tb_num);
} else {
/* jump to another page: currently not optimized */
tcg_gen_movi_tl(tcg_ctx, *(TCGv *)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_exit_tb(tcg_ctx, 0);
}
@ -1043,7 +1043,7 @@ static void gen_branch_n(DisasContext *dc, target_ulong pc1)
} else {
TCGv t, z;
tcg_gen_mov_tl(tcg_ctx, *(TCGv *)tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc);
tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc);
tcg_gen_addi_tl(tcg_ctx, *(TCGv *)tcg_ctx->cpu_npc, *(TCGv *)tcg_ctx->cpu_npc, 4);
t = tcg_const_tl(tcg_ctx, pc1);
@ -1104,7 +1104,7 @@ static inline void update_psr(DisasContext *dc)
static inline void save_state(DisasContext *dc)
{
TCGContext *tcg_ctx = dc->uc->tcg_ctx;
tcg_gen_movi_tl(tcg_ctx, *(TCGv *)tcg_ctx->sparc_cpu_pc, dc->pc);
tcg_gen_movi_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, dc->pc);
save_npc(dc);
}
@ -1113,10 +1113,10 @@ static inline void gen_mov_pc_npc(DisasContext *dc)
TCGContext *tcg_ctx = dc->uc->tcg_ctx;
if (dc->npc == JUMP_PC) {
gen_generic_branch(dc);
tcg_gen_mov_tl(tcg_ctx, *(TCGv *)tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc);
tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc);
dc->pc = DYNAMIC_PC;
} else if (dc->npc == DYNAMIC_PC) {
tcg_gen_mov_tl(tcg_ctx, *(TCGv *)tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc);
tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc);
dc->pc = DYNAMIC_PC;
} else {
dc->pc = dc->npc;
@ -1126,7 +1126,7 @@ static inline void gen_mov_pc_npc(DisasContext *dc)
static inline void gen_op_next_insn(DisasContext *dc)
{
TCGContext *tcg_ctx = dc->uc->tcg_ctx;
tcg_gen_mov_tl(tcg_ctx, *(TCGv *)tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc);
tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc);
tcg_gen_addi_tl(tcg_ctx, *(TCGv *)tcg_ctx->cpu_npc, *(TCGv *)tcg_ctx->cpu_npc, 4);
}
@ -1492,7 +1492,7 @@ static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc)
} else {
dc->pc = dc->npc;
dc->npc = target;
tcg_gen_mov_tl(tcg_ctx, *(TCGv *)tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc);
tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc);
}
} else {
flush_cond(dc);
@ -1533,7 +1533,7 @@ static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc)
} else {
dc->pc = dc->npc;
dc->npc = target;
tcg_gen_mov_tl(tcg_ctx, *(TCGv *)tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc);
tcg_gen_mov_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, *(TCGv *)tcg_ctx->cpu_npc);
}
} else {
flush_cond(dc);
@ -5483,7 +5483,7 @@ void gen_intermediate_code(CPUSPARCState * env, TranslationBlock * tb)
gen_goto_tb(dc, 0, dc->pc, dc->npc);
} else {
if (dc->pc != DYNAMIC_PC) {
tcg_gen_movi_tl(tcg_ctx, *(TCGv *)tcg_ctx->sparc_cpu_pc, dc->pc);
tcg_gen_movi_tl(tcg_ctx, tcg_ctx->sparc_cpu_pc, dc->pc);
}
save_npc(dc);
tcg_gen_exit_tb(tcg_ctx, 0);
@ -5603,8 +5603,7 @@ void gen_intermediate_code_init(CPUSPARCState *env)
tcg_ctx->cpu_fsr = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUSPARCState, fsr),
"fsr");
tcg_ctx->sparc_cpu_pc = g_malloc0(sizeof(TCGv));
*(TCGv *)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");
tcg_ctx->cpu_npc = g_malloc0(sizeof(TCGv));

View file

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

View file

@ -833,7 +833,7 @@ struct TCGContext {
TCGv_i64 cpu_fpr[32]; // TARGET_DPREGS = 32 for Sparc64, 16 for Sparc
TCGv cpu_fsr;
void *sparc_cpu_pc;
TCGv sparc_cpu_pc;
void *cpu_npc;
void *cpu_regs_sparc[32];
TCGv cpu_y;