From 6ccd4479d72ab35338105ad76a8d1bbef298d317 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Feb 2018 01:23:58 -0500 Subject: [PATCH] tcg: Make sparc_cpu_pc a TCGv --- qemu/target-sparc/translate.c | 23 +++++++++++------------ qemu/target-sparc/unicorn.c | 1 - qemu/tcg/tcg.h | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/qemu/target-sparc/translate.c b/qemu/target-sparc/translate.c index 79e71b00..5657f6d1 100644 --- a/qemu/target-sparc/translate.c +++ b/qemu/target-sparc/translate.c @@ -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)); diff --git a/qemu/target-sparc/unicorn.c b/qemu/target-sparc/unicorn.c index f79a0b1e..9cea1a29 100644 --- a/qemu/target-sparc/unicorn.c +++ b/qemu/target-sparc/unicorn.c @@ -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++) { diff --git a/qemu/tcg/tcg.h b/qemu/tcg/tcg.h index 974c71af..a75630ea 100644 --- a/qemu/tcg/tcg.h +++ b/qemu/tcg/tcg.h @@ -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;