From d84666be75c3287090ab48ab342b39afeaa4de55 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Sat, 12 Apr 2025 23:58:09 -0400 Subject: [PATCH] fix(ppc): avoid using static TCG variables --- qemu/include/tcg/tcg.h | 21 +- qemu/target/ppc/helper_regs.h | 5 +- qemu/target/ppc/translate.c | 1408 +++++++++++----------- qemu/target/ppc/translate/dfp-impl.inc.c | 6 +- qemu/target/ppc/translate/fp-impl.inc.c | 76 +- qemu/target/ppc/translate/spe-impl.inc.c | 267 ++-- qemu/target/ppc/translate/vmx-impl.inc.c | 8 +- qemu/target/ppc/translate/vsx-impl.inc.c | 32 +- qemu/target/ppc/translate_init.inc.c | 192 +-- qemu/target/ppc/unicorn.c | 6 - 10 files changed, 1019 insertions(+), 1002 deletions(-) diff --git a/qemu/include/tcg/tcg.h b/qemu/include/tcg/tcg.h index e3b02c1a11..ab55b1bcc3 100644 --- a/qemu/include/tcg/tcg.h +++ b/qemu/include/tcg/tcg.h @@ -720,7 +720,7 @@ struct TCGContext { void *tb_ret_addr; /* target/riscv/translate.c */ - TCGv cpu_gpr[32], cpu_pc; // also target/mips/translate.c + TCGv cpu_gpr[32], cpu_pc; // also target/mips/translate.c, target/ppc/translate.c TCGv_i64 cpu_fpr[32]; /* assume F and D extensions */ TCGv load_res; TCGv load_val; @@ -803,6 +803,22 @@ struct TCGContext { // Used to store the start of current instrution. uint64_t pc_start; + // target/ppc/translate.c + TCGv cpu_gprh[32]; + TCGv_i32 cpu_crf[8]; + TCGv cpu_nip; + TCGv cpu_msr; + TCGv cpu_ctr; + TCGv cpu_lr; +#if defined(TARGET_PPC64) + TCGv cpu_cfar; +#endif + TCGv cpu_xer, cpu_so, cpu_ov, cpu_ca, cpu_ov32, cpu_ca32; + TCGv cpu_reserve; + TCGv cpu_reserve_val; + TCGv cpu_fpscr; + TCGv_i32 cpu_access_type; + // target/s390x/translate.c TCGv_i64 psw_addr; TCGv_i64 psw_mask; @@ -813,6 +829,9 @@ struct TCGContext { TCGv_i64 cc_dst; TCGv_i64 cc_vr; + char ppc_cpu_reg_names[10 * 3 + 22 * 4 /* GPR */ + + 10 * 4 + 22 * 5 /* SPE GPRh */ + + 8 * 5 /* CRF */]; char s390x_cpu_reg_names[16][4]; // renamed from original cpu_reg_names[][] to avoid name clash with m68k TCGv_i64 regs[16]; }; diff --git a/qemu/target/ppc/helper_regs.h b/qemu/target/ppc/helper_regs.h index e931eb6148..1d374fd5fb 100644 --- a/qemu/target/ppc/helper_regs.h +++ b/qemu/target/ppc/helper_regs.h @@ -90,8 +90,9 @@ static inline void hreg_compute_hflags(CPUPPCState *env) /* We 'forget' FE0 & FE1: we'll never generate imprecise exceptions */ hflags_mask = (1 << MSR_VR) | (1 << MSR_AP) | (1 << MSR_SA) | - (1 << MSR_PR) | (1 << MSR_FP) | (1 << MSR_SE) | (1 << MSR_BE) | - (1 << MSR_LE) | (1 << MSR_VSX) | (1 << MSR_IR) | (1 << MSR_DR); + (1 << MSR_PR) | (1 << MSR_FP) | (1 << MSR_SE) | + (1 << MSR_BE) | (1 << MSR_LE) | (1 << MSR_VSX) | + (1 << MSR_IR) | (1 << MSR_DR); hflags_mask |= (1ULL << MSR_CM) | (1ULL << MSR_SF) | MSR_HVB; hreg_compute_mem_idx(env); env->hflags = env->msr & hflags_mask; diff --git a/qemu/target/ppc/translate.c b/qemu/target/ppc/translate.c index 0b3e5c8c08..3e2a8f7980 100644 --- a/qemu/target/ppc/translate.c +++ b/qemu/target/ppc/translate.c @@ -50,26 +50,6 @@ /*****************************************************************************/ /* Code translation helpers */ -/* global register indexes */ -static char cpu_reg_names[10 * 3 + 22 * 4 /* GPR */ - + 10 * 4 + 22 * 5 /* SPE GPRh */ - + 8 * 5 /* CRF */]; -static TCGv cpu_gpr[32]; -static TCGv cpu_gprh[32]; -static TCGv_i32 cpu_crf[8]; -static TCGv cpu_nip; -static TCGv cpu_msr; -static TCGv cpu_ctr; -static TCGv cpu_lr; -#if defined(TARGET_PPC64) -static TCGv cpu_cfar; -#endif -static TCGv cpu_xer, cpu_so, cpu_ov, cpu_ca, cpu_ov32, cpu_ca32; -static TCGv cpu_reserve; -static TCGv cpu_reserve_val; -static TCGv cpu_fpscr; -static TCGv_i32 cpu_access_type; - #include "exec/gen-icount.h" void ppc_translate_init(struct uc_struct *uc) @@ -79,12 +59,12 @@ void ppc_translate_init(struct uc_struct *uc) char *p; size_t cpu_reg_names_size; - p = cpu_reg_names; - cpu_reg_names_size = sizeof(cpu_reg_names); + p = tcg_ctx->cpu_reg_names; + cpu_reg_names_size = sizeof(tcg_ctx->cpu_reg_names); for (i = 0; i < 8; i++) { snprintf(p, cpu_reg_names_size, "crf%d", i); - cpu_crf[i] = tcg_global_mem_new_i32(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_crf[i] = tcg_global_mem_new_i32(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, crf[i]), p); p += 5; cpu_reg_names_size -= 5; @@ -92,58 +72,58 @@ void ppc_translate_init(struct uc_struct *uc) for (i = 0; i < 32; i++) { snprintf(p, cpu_reg_names_size, "r%d", i); - cpu_gpr[i] = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_gpr[i] = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, gpr[i]), p); p += (i < 10) ? 3 : 4; cpu_reg_names_size -= (i < 10) ? 3 : 4; snprintf(p, cpu_reg_names_size, "r%dH", i); - cpu_gprh[i] = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_gprh[i] = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, gprh[i]), p); p += (i < 10) ? 4 : 5; cpu_reg_names_size -= (i < 10) ? 4 : 5; } - cpu_nip = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_nip = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, nip), "nip"); - cpu_msr = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_msr = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, msr), "msr"); - cpu_ctr = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_ctr = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, ctr), "ctr"); - cpu_lr = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_lr = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, lr), "lr"); #if defined(TARGET_PPC64) - cpu_cfar = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_cfar = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, cfar), "cfar"); #endif - cpu_xer = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_xer = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, xer), "xer"); - cpu_so = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_so = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, so), "SO"); - cpu_ov = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_ov = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, ov), "OV"); - cpu_ca = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_ca = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, ca), "CA"); - cpu_ov32 = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_ov32 = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, ov32), "OV32"); - cpu_ca32 = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_ca32 = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, ca32), "CA32"); - cpu_reserve = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_reserve = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, reserve_addr), "reserve_addr"); - cpu_reserve_val = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_reserve_val = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, reserve_val), "reserve_val"); - cpu_fpscr = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_fpscr = tcg_global_mem_new(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, fpscr), "fpscr"); - cpu_access_type = tcg_global_mem_new_i32(tcg_ctx, tcg_ctx->cpu_env, + tcg_ctx->cpu_access_type = tcg_global_mem_new_i32(tcg_ctx, tcg_ctx->cpu_env, offsetof(CPUPPCState, access_type), "access_type"); } @@ -232,7 +212,7 @@ static inline void gen_set_access_type(DisasContext *ctx, int access_type) { if (ctx->need_access_type && ctx->access_type != access_type) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_movi_i32(tcg_ctx, cpu_access_type, access_type); + tcg_gen_movi_i32(tcg_ctx, tcg_ctx->cpu_access_type, access_type); ctx->access_type = access_type; } } @@ -243,7 +223,7 @@ static inline void gen_update_nip(DisasContext *ctx, target_ulong nip) if (NARROW_MODE(ctx)) { nip = (uint32_t)nip; } - tcg_gen_movi_tl(tcg_ctx, cpu_nip, nip); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_nip, nip); } static void gen_exception_err(DisasContext *ctx, uint32_t excp, uint32_t error) @@ -617,8 +597,8 @@ static inline void gen_op_cmp(TCGContext *tcg_ctx, TCGv arg0, TCGv arg1, int s, t0, arg0, arg1, t1, t0); tcg_gen_trunc_tl_i32(tcg_ctx, t, t0); - tcg_gen_trunc_tl_i32(tcg_ctx, cpu_crf[crf], cpu_so); - tcg_gen_or_i32(tcg_ctx, cpu_crf[crf], cpu_crf[crf], t); + tcg_gen_trunc_tl_i32(tcg_ctx, tcg_ctx->cpu_crf[crf], tcg_ctx->cpu_so); + tcg_gen_or_i32(tcg_ctx, tcg_ctx->cpu_crf[crf], tcg_ctx->cpu_crf[crf], t); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); @@ -672,10 +652,10 @@ static void gen_cmp(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; if ((ctx->opcode & 0x00200000) && (ctx->insns_flags & PPC_64B)) { - gen_op_cmp(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], + gen_op_cmp(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)], 1, crfD(ctx->opcode)); } else { - gen_op_cmp32(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], + gen_op_cmp32(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)], 1, crfD(ctx->opcode)); } } @@ -685,10 +665,10 @@ static void gen_cmpi(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; if ((ctx->opcode & 0x00200000) && (ctx->insns_flags & PPC_64B)) { - gen_op_cmpi(tcg_ctx, cpu_gpr[rA(ctx->opcode)], SIMM(ctx->opcode), + gen_op_cmpi(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], SIMM(ctx->opcode), 1, crfD(ctx->opcode)); } else { - gen_op_cmpi32(tcg_ctx, cpu_gpr[rA(ctx->opcode)], SIMM(ctx->opcode), + gen_op_cmpi32(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], SIMM(ctx->opcode), 1, crfD(ctx->opcode)); } } @@ -698,10 +678,10 @@ static void gen_cmpl(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; if ((ctx->opcode & 0x00200000) && (ctx->insns_flags & PPC_64B)) { - gen_op_cmp(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], + gen_op_cmp(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0, crfD(ctx->opcode)); } else { - gen_op_cmp32(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], + gen_op_cmp32(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0, crfD(ctx->opcode)); } } @@ -711,10 +691,10 @@ static void gen_cmpli(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; if ((ctx->opcode & 0x00200000) && (ctx->insns_flags & PPC_64B)) { - gen_op_cmpi(tcg_ctx, cpu_gpr[rA(ctx->opcode)], UIMM(ctx->opcode), + gen_op_cmpi(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], UIMM(ctx->opcode), 0, crfD(ctx->opcode)); } else { - gen_op_cmpi32(tcg_ctx, cpu_gpr[rA(ctx->opcode)], UIMM(ctx->opcode), + gen_op_cmpi32(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], UIMM(ctx->opcode), 0, crfD(ctx->opcode)); } } @@ -727,10 +707,10 @@ static void gen_cmprb(DisasContext *ctx) TCGv_i32 src2 = tcg_temp_new_i32(tcg_ctx); TCGv_i32 src2lo = tcg_temp_new_i32(tcg_ctx); TCGv_i32 src2hi = tcg_temp_new_i32(tcg_ctx); - TCGv_i32 crf = cpu_crf[crfD(ctx->opcode)]; + TCGv_i32 crf = tcg_ctx->cpu_crf[crfD(ctx->opcode)]; - tcg_gen_trunc_tl_i32(tcg_ctx, src1, cpu_gpr[rA(ctx->opcode)]); - tcg_gen_trunc_tl_i32(tcg_ctx, src2, cpu_gpr[rB(ctx->opcode)]); + tcg_gen_trunc_tl_i32(tcg_ctx, src1, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_trunc_tl_i32(tcg_ctx, src2, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); tcg_gen_andi_i32(tcg_ctx, src1, src1, 0xFF); tcg_gen_ext8u_i32(tcg_ctx, src2lo, src2); @@ -763,8 +743,8 @@ static void gen_cmprb(DisasContext *ctx) static void gen_cmpeqb(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_cmpeqb(tcg_ctx, cpu_crf[crfD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rB(ctx->opcode)]); + gen_helper_cmpeqb(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } #endif @@ -777,13 +757,13 @@ static void gen_isel(DisasContext *ctx) TCGv t0 = tcg_temp_new(tcg_ctx); TCGv zr; - tcg_gen_extu_i32_tl(tcg_ctx, t0, cpu_crf[bi >> 2]); + tcg_gen_extu_i32_tl(tcg_ctx, t0, tcg_ctx->cpu_crf[bi >> 2]); tcg_gen_andi_tl(tcg_ctx, t0, t0, mask); zr = tcg_const_tl(tcg_ctx, 0); - tcg_gen_movcond_tl(tcg_ctx, TCG_COND_NE, cpu_gpr[rD(ctx->opcode)], t0, zr, - rA(ctx->opcode) ? cpu_gpr[rA(ctx->opcode)] : zr, - cpu_gpr[rB(ctx->opcode)]); + tcg_gen_movcond_tl(tcg_ctx, TCG_COND_NE, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0, zr, + rA(ctx->opcode) ? tcg_ctx->cpu_gpr[rA(ctx->opcode)] : zr, + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); tcg_temp_free(tcg_ctx, zr); tcg_temp_free(tcg_ctx, t0); } @@ -792,8 +772,8 @@ static void gen_isel(DisasContext *ctx) static void gen_cmpb(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_cmpb(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], - cpu_gpr[rB(ctx->opcode)]); + gen_helper_cmpb(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)], + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } /*** Integer arithmetic ***/ @@ -804,26 +784,26 @@ static inline void gen_op_arith_compute_ov(DisasContext *ctx, TCGv arg0, TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); - tcg_gen_xor_tl(tcg_ctx, cpu_ov, arg0, arg2); + tcg_gen_xor_tl(tcg_ctx, tcg_ctx->cpu_ov, arg0, arg2); tcg_gen_xor_tl(tcg_ctx, t0, arg1, arg2); if (sub) { - tcg_gen_and_tl(tcg_ctx, cpu_ov, cpu_ov, t0); + tcg_gen_and_tl(tcg_ctx, tcg_ctx->cpu_ov, tcg_ctx->cpu_ov, t0); } else { - tcg_gen_andc_tl(tcg_ctx, cpu_ov, cpu_ov, t0); + tcg_gen_andc_tl(tcg_ctx, tcg_ctx->cpu_ov, tcg_ctx->cpu_ov, t0); } tcg_temp_free(tcg_ctx, t0); if (NARROW_MODE(ctx)) { - tcg_gen_extract_tl(tcg_ctx, cpu_ov, cpu_ov, 31, 1); + tcg_gen_extract_tl(tcg_ctx, tcg_ctx->cpu_ov, tcg_ctx->cpu_ov, 31, 1); if (is_isa300(ctx)) { - tcg_gen_mov_tl(tcg_ctx, cpu_ov32, cpu_ov); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_ov32, tcg_ctx->cpu_ov); } } else { if (is_isa300(ctx)) { - tcg_gen_extract_tl(tcg_ctx, cpu_ov32, cpu_ov, 31, 1); + tcg_gen_extract_tl(tcg_ctx, tcg_ctx->cpu_ov32, tcg_ctx->cpu_ov, 31, 1); } - tcg_gen_extract_tl(tcg_ctx, cpu_ov, cpu_ov, TARGET_LONG_BITS - 1, 1); + tcg_gen_extract_tl(tcg_ctx, tcg_ctx->cpu_ov, tcg_ctx->cpu_ov, TARGET_LONG_BITS - 1, 1); } - tcg_gen_or_tl(tcg_ctx, cpu_so, cpu_so, cpu_ov); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_so, tcg_ctx->cpu_so, tcg_ctx->cpu_ov); } static inline void gen_op_arith_compute_ca32(DisasContext *ctx, @@ -911,13 +891,15 @@ static inline void gen_op_arith_add(DisasContext *ctx, TCGv ret, TCGv arg1, } } /* Add functions with two operands */ -#define GEN_INT_ARITH_ADD(name, opc3, ca, add_ca, compute_ca, compute_ov) \ -static void glue(gen_, name)(DisasContext *ctx) \ -{ \ - gen_op_arith_add(ctx, cpu_gpr[rD(ctx->opcode)], \ - cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \ - ca, glue(ca, 32), \ - add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \ +#define GEN_INT_ARITH_ADD(name, opc3, ca, add_ca, compute_ca, compute_ov) \ +static void glue(gen_, name)(DisasContext *ctx) \ +{ \ + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; \ + gen_op_arith_add(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rA(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rB(ctx->opcode)], \ + ca, glue(ca, 32), \ + add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \ } /* Add functions with one operand and one immediate */ #define GEN_INT_ARITH_ADD_CONST(name, opc3, const_val, ca, \ @@ -926,30 +908,30 @@ static void glue(gen_, name)(DisasContext *ctx) \ { \ TCGContext *tcg_ctx = ctx->uc->tcg_ctx; \ TCGv t0 = tcg_const_tl(tcg_ctx, const_val); \ - gen_op_arith_add(ctx, cpu_gpr[rD(ctx->opcode)], \ - cpu_gpr[rA(ctx->opcode)], t0, \ + gen_op_arith_add(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, \ ca, glue(ca, 32), \ add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \ tcg_temp_free(tcg_ctx, t0); \ } /* add add. addo addo. */ -GEN_INT_ARITH_ADD(add, 0x08, cpu_ca, 0, 0, 0) -GEN_INT_ARITH_ADD(addo, 0x18, cpu_ca, 0, 0, 1) +GEN_INT_ARITH_ADD(add, 0x08, tcg_ctx->cpu_ca, 0, 0, 0) +GEN_INT_ARITH_ADD(addo, 0x18, tcg_ctx->cpu_ca, 0, 0, 1) /* addc addc. addco addco. */ -GEN_INT_ARITH_ADD(addc, 0x00, cpu_ca, 0, 1, 0) -GEN_INT_ARITH_ADD(addco, 0x10, cpu_ca, 0, 1, 1) +GEN_INT_ARITH_ADD(addc, 0x00, tcg_ctx->cpu_ca, 0, 1, 0) +GEN_INT_ARITH_ADD(addco, 0x10, tcg_ctx->cpu_ca, 0, 1, 1) /* adde adde. addeo addeo. */ -GEN_INT_ARITH_ADD(adde, 0x04, cpu_ca, 1, 1, 0) -GEN_INT_ARITH_ADD(addeo, 0x14, cpu_ca, 1, 1, 1) +GEN_INT_ARITH_ADD(adde, 0x04, tcg_ctx->cpu_ca, 1, 1, 0) +GEN_INT_ARITH_ADD(addeo, 0x14, tcg_ctx->cpu_ca, 1, 1, 1) /* addme addme. addmeo addmeo. */ -GEN_INT_ARITH_ADD_CONST(addme, 0x07, -1LL, cpu_ca, 1, 1, 0) -GEN_INT_ARITH_ADD_CONST(addmeo, 0x17, -1LL, cpu_ca, 1, 1, 1) +GEN_INT_ARITH_ADD_CONST(addme, 0x07, -1LL, tcg_ctx->cpu_ca, 1, 1, 0) +GEN_INT_ARITH_ADD_CONST(addmeo, 0x17, -1LL, tcg_ctx->cpu_ca, 1, 1, 1) /* addex */ -GEN_INT_ARITH_ADD(addex, 0x05, cpu_ov, 1, 1, 0); +GEN_INT_ARITH_ADD(addex, 0x05, tcg_ctx->cpu_ov, 1, 1, 0); /* addze addze. addzeo addzeo.*/ -GEN_INT_ARITH_ADD_CONST(addze, 0x06, 0, cpu_ca, 1, 1, 0) -GEN_INT_ARITH_ADD_CONST(addzeo, 0x16, 0, cpu_ca, 1, 1, 1) +GEN_INT_ARITH_ADD_CONST(addze, 0x06, 0, tcg_ctx->cpu_ca, 1, 1, 0) +GEN_INT_ARITH_ADD_CONST(addzeo, 0x16, 0, tcg_ctx->cpu_ca, 1, 1, 1) /* addi */ static void gen_addi(DisasContext *ctx) { @@ -958,10 +940,10 @@ static void gen_addi(DisasContext *ctx) if (rA(ctx->opcode) == 0) { /* li case */ - tcg_gen_movi_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], simm); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], simm); } else { - tcg_gen_addi_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], - cpu_gpr[rA(ctx->opcode)], simm); + tcg_gen_addi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], + tcg_ctx->cpu_gpr[rA(ctx->opcode)], simm); } } /* addic addic.*/ @@ -969,8 +951,8 @@ static inline void gen_op_addic(DisasContext *ctx, bool compute_rc0) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv c = tcg_const_tl(tcg_ctx, SIMM(ctx->opcode)); - gen_op_arith_add(ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], - c, cpu_ca, cpu_ca32, 0, 1, 0, compute_rc0); + gen_op_arith_add(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], + c, tcg_ctx->cpu_ca, tcg_ctx->cpu_ca32, 0, 1, 0, compute_rc0); tcg_temp_free(tcg_ctx, c); } @@ -992,10 +974,10 @@ static void gen_addis(DisasContext *ctx) if (rA(ctx->opcode) == 0) { /* lis case */ - tcg_gen_movi_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], simm << 16); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], simm << 16); } else { - tcg_gen_addi_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], - cpu_gpr[rA(ctx->opcode)], simm << 16); + tcg_gen_addi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], + tcg_ctx->cpu_gpr[rA(ctx->opcode)], simm << 16); } } @@ -1005,7 +987,7 @@ static void gen_addpcis(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; target_long d = DX(ctx->opcode); - tcg_gen_movi_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], ctx->base.pc_next + (d << 16)); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], ctx->base.pc_next + (d << 16)); } static inline void gen_op_arith_divw(DisasContext *ctx, TCGv ret, TCGv arg1, @@ -1037,11 +1019,11 @@ static inline void gen_op_arith_divw(DisasContext *ctx, TCGv ret, TCGv arg1, tcg_gen_extu_i32_tl(tcg_ctx, ret, t3); } if (compute_ov) { - tcg_gen_extu_i32_tl(tcg_ctx, cpu_ov, t2); + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_ov, t2); if (is_isa300(ctx)) { - tcg_gen_extu_i32_tl(tcg_ctx, cpu_ov32, t2); + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_ov32, t2); } - tcg_gen_or_tl(tcg_ctx, cpu_so, cpu_so, cpu_ov); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_so, tcg_ctx->cpu_so, tcg_ctx->cpu_ov); } tcg_temp_free_i32(tcg_ctx, t0); tcg_temp_free_i32(tcg_ctx, t1); @@ -1053,12 +1035,14 @@ static inline void gen_op_arith_divw(DisasContext *ctx, TCGv ret, TCGv arg1, } } /* Div functions */ -#define GEN_INT_ARITH_DIVW(name, opc3, sign, compute_ov) \ -static void glue(gen_, name)(DisasContext *ctx) \ -{ \ - gen_op_arith_divw(ctx, cpu_gpr[rD(ctx->opcode)], \ - cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \ - sign, compute_ov); \ +#define GEN_INT_ARITH_DIVW(name, opc3, sign, compute_ov) \ +static void glue(gen_, name)(DisasContext *ctx) \ +{ \ + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; \ + gen_op_arith_divw(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rA(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rB(ctx->opcode)], \ + sign, compute_ov); \ } /* divwu divwu. divwuo divwuo. */ GEN_INT_ARITH_DIVW(divwu, 0x0E, 0, 0); @@ -1073,11 +1057,13 @@ static void gen_##name(DisasContext *ctx) \ { \ TCGContext *tcg_ctx = ctx->uc->tcg_ctx; \ TCGv_i32 t0 = tcg_const_i32(tcg_ctx, compute_ov); \ - gen_helper_##hlpr(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, \ - cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], t0); \ + gen_helper_##hlpr(tcg_ctx, \ + tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, \ + tcg_ctx->cpu_gpr[rA(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rB(ctx->opcode)], t0); \ tcg_temp_free_i32(tcg_ctx, t0); \ if (unlikely(Rc(ctx->opcode) != 0)) { \ - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); \ + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); \ } \ } @@ -1114,11 +1100,11 @@ static inline void gen_op_arith_divd(DisasContext *ctx, TCGv ret, TCGv arg1, tcg_gen_divu_i64(tcg_ctx, ret, t0, t1); } if (compute_ov) { - tcg_gen_mov_tl(tcg_ctx, cpu_ov, t2); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_ov, t2); if (is_isa300(ctx)) { - tcg_gen_mov_tl(tcg_ctx, cpu_ov32, t2); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_ov32, t2); } - tcg_gen_or_tl(tcg_ctx, cpu_so, cpu_so, cpu_ov); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_so, tcg_ctx->cpu_so, tcg_ctx->cpu_ov); } tcg_temp_free_i64(tcg_ctx, t0); tcg_temp_free_i64(tcg_ctx, t1); @@ -1133,8 +1119,9 @@ static inline void gen_op_arith_divd(DisasContext *ctx, TCGv ret, TCGv arg1, #define GEN_INT_ARITH_DIVD(name, opc3, sign, compute_ov) \ static void glue(gen_, name)(DisasContext *ctx) \ { \ - gen_op_arith_divd(ctx, cpu_gpr[rD(ctx->opcode)], \ - cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \ + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; \ + gen_op_arith_divd(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)], \ sign, compute_ov); \ } /* divdu divdu. divduo divduo. */ @@ -1189,8 +1176,10 @@ static inline void gen_op_arith_modw(DisasContext *ctx, TCGv ret, TCGv arg1, #define GEN_INT_ARITH_MODW(name, opc3, sign) \ static void glue(gen_, name)(DisasContext *ctx) \ { \ - gen_op_arith_modw(ctx, cpu_gpr[rD(ctx->opcode)], \ - cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \ + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; \ + gen_op_arith_modw(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rA(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rB(ctx->opcode)], \ sign); \ } @@ -1235,8 +1224,9 @@ static inline void gen_op_arith_modd(DisasContext *ctx, TCGv ret, TCGv arg1, #define GEN_INT_ARITH_MODD(name, opc3, sign) \ static void glue(gen_, name)(DisasContext *ctx) \ { \ - gen_op_arith_modd(ctx, cpu_gpr[rD(ctx->opcode)], \ - cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \ + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; \ + gen_op_arith_modd(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)], \ sign); \ } @@ -1251,14 +1241,14 @@ static void gen_mulhw(DisasContext *ctx) TCGv_i32 t0 = tcg_temp_new_i32(tcg_ctx); TCGv_i32 t1 = tcg_temp_new_i32(tcg_ctx); - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); - tcg_gen_trunc_tl_i32(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)]); + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_trunc_tl_i32(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); tcg_gen_muls2_i32(tcg_ctx, t0, t1, t0, t1); - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t1); + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t1); tcg_temp_free_i32(tcg_ctx, t0); tcg_temp_free_i32(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -1269,14 +1259,14 @@ static void gen_mulhwu(DisasContext *ctx) TCGv_i32 t0 = tcg_temp_new_i32(tcg_ctx); TCGv_i32 t1 = tcg_temp_new_i32(tcg_ctx); - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); - tcg_gen_trunc_tl_i32(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)]); + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_trunc_tl_i32(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); tcg_gen_mulu2_i32(tcg_ctx, t0, t1, t0, t1); - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t1); + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t1); tcg_temp_free_i32(tcg_ctx, t0); tcg_temp_free_i32(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -1288,17 +1278,17 @@ static void gen_mullw(DisasContext *ctx) TCGv_i64 t0, t1; t0 = tcg_temp_new_i64(tcg_ctx); t1 = tcg_temp_new_i64(tcg_ctx); - tcg_gen_ext32s_tl(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); - tcg_gen_ext32s_tl(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)]); - tcg_gen_mul_i64(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0, t1); + tcg_gen_ext32s_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_ext32s_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); + tcg_gen_mul_i64(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0, t1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); #else - tcg_gen_mul_i32(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rB(ctx->opcode)]); + tcg_gen_mul_i32(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); #endif if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -1309,27 +1299,27 @@ static void gen_mullwo(DisasContext *ctx) TCGv_i32 t0 = tcg_temp_new_i32(tcg_ctx); TCGv_i32 t1 = tcg_temp_new_i32(tcg_ctx); - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); - tcg_gen_trunc_tl_i32(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)]); + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_trunc_tl_i32(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); tcg_gen_muls2_i32(tcg_ctx, t0, t1, t0, t1); #if defined(TARGET_PPC64) - tcg_gen_concat_i32_i64(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0, t1); + tcg_gen_concat_i32_i64(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0, t1); #else - tcg_gen_mov_i32(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); + tcg_gen_mov_i32(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); #endif tcg_gen_sari_i32(tcg_ctx, t0, t0, 31); tcg_gen_setcond_i32(tcg_ctx, TCG_COND_NE, t0, t0, t1); - tcg_gen_extu_i32_tl(tcg_ctx, cpu_ov, t0); + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_ov, t0); if (is_isa300(ctx)) { - tcg_gen_mov_tl(tcg_ctx, cpu_ov32, cpu_ov); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_ov32, tcg_ctx->cpu_ov); } - tcg_gen_or_tl(tcg_ctx, cpu_so, cpu_so, cpu_ov); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_so, tcg_ctx->cpu_so, tcg_ctx->cpu_ov); tcg_temp_free_i32(tcg_ctx, t0); tcg_temp_free_i32(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -1337,7 +1327,7 @@ static void gen_mullwo(DisasContext *ctx) static void gen_mulli(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_muli_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], + tcg_gen_muli_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], SIMM(ctx->opcode)); } @@ -1347,11 +1337,11 @@ static void gen_mulhd(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv lo = tcg_temp_new(tcg_ctx); - tcg_gen_muls2_tl(tcg_ctx, lo, cpu_gpr[rD(ctx->opcode)], - cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); + tcg_gen_muls2_tl(tcg_ctx, lo, tcg_ctx->cpu_gpr[rD(ctx->opcode)], + tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); tcg_temp_free(tcg_ctx, lo); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -1360,11 +1350,11 @@ static void gen_mulhdu(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv lo = tcg_temp_new(tcg_ctx); - tcg_gen_mulu2_tl(tcg_ctx, lo, cpu_gpr[rD(ctx->opcode)], - cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); + tcg_gen_mulu2_tl(tcg_ctx, lo, tcg_ctx->cpu_gpr[rD(ctx->opcode)], + tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); tcg_temp_free(tcg_ctx, lo); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -1372,10 +1362,10 @@ static void gen_mulhdu(DisasContext *ctx) static void gen_mulld(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_mul_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rB(ctx->opcode)]); + tcg_gen_mul_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -1386,22 +1376,22 @@ static void gen_mulldo(DisasContext *ctx) TCGv_i64 t0 = tcg_temp_new_i64(tcg_ctx); TCGv_i64 t1 = tcg_temp_new_i64(tcg_ctx); - tcg_gen_muls2_i64(tcg_ctx, t0, t1, cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rB(ctx->opcode)]); - tcg_gen_mov_i64(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); + tcg_gen_muls2_i64(tcg_ctx, t0, t1, tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); + tcg_gen_mov_i64(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); tcg_gen_sari_i64(tcg_ctx, t0, t0, 63); - tcg_gen_setcond_i64(tcg_ctx, TCG_COND_NE, cpu_ov, t0, t1); + tcg_gen_setcond_i64(tcg_ctx, TCG_COND_NE, tcg_ctx->cpu_ov, t0, t1); if (is_isa300(ctx)) { - tcg_gen_mov_tl(tcg_ctx, cpu_ov32, cpu_ov); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_ov32, tcg_ctx->cpu_ov); } - tcg_gen_or_tl(tcg_ctx, cpu_so, cpu_so, cpu_ov); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_so, tcg_ctx->cpu_so, tcg_ctx->cpu_ov); tcg_temp_free_i64(tcg_ctx, t0); tcg_temp_free_i64(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } #endif @@ -1430,32 +1420,32 @@ static inline void gen_op_arith_subf(DisasContext *ctx, TCGv ret, TCGv arg1, TCGv t1 = tcg_temp_new(tcg_ctx); tcg_gen_not_tl(tcg_ctx, inv1, arg1); if (add_ca) { - tcg_gen_add_tl(tcg_ctx, t0, arg2, cpu_ca); + tcg_gen_add_tl(tcg_ctx, t0, arg2, tcg_ctx->cpu_ca); } else { tcg_gen_addi_tl(tcg_ctx, t0, arg2, 1); } tcg_gen_xor_tl(tcg_ctx, t1, arg2, inv1); /* add without carry */ tcg_gen_add_tl(tcg_ctx, t0, t0, inv1); tcg_temp_free(tcg_ctx, inv1); - tcg_gen_xor_tl(tcg_ctx, cpu_ca, t0, t1); /* bits changes w/ carry */ + tcg_gen_xor_tl(tcg_ctx, tcg_ctx->cpu_ca, t0, t1); /* bits changes w/ carry */ tcg_temp_free(tcg_ctx, t1); - tcg_gen_extract_tl(tcg_ctx, cpu_ca, cpu_ca, 32, 1); + tcg_gen_extract_tl(tcg_ctx, tcg_ctx->cpu_ca, tcg_ctx->cpu_ca, 32, 1); if (is_isa300(ctx)) { - tcg_gen_mov_tl(tcg_ctx, cpu_ca32, cpu_ca); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_ca32, tcg_ctx->cpu_ca); } } else if (add_ca) { TCGv zero, inv1 = tcg_temp_new(tcg_ctx); tcg_gen_not_tl(tcg_ctx, inv1, arg1); zero = tcg_const_tl(tcg_ctx, 0); - tcg_gen_add2_tl(tcg_ctx, t0, cpu_ca, arg2, zero, cpu_ca, zero); - tcg_gen_add2_tl(tcg_ctx, t0, cpu_ca, t0, cpu_ca, inv1, zero); - gen_op_arith_compute_ca32(ctx, t0, inv1, arg2, cpu_ca32, 0); + tcg_gen_add2_tl(tcg_ctx, t0, tcg_ctx->cpu_ca, arg2, zero, tcg_ctx->cpu_ca, zero); + tcg_gen_add2_tl(tcg_ctx, t0, tcg_ctx->cpu_ca, t0, tcg_ctx->cpu_ca, inv1, zero); + gen_op_arith_compute_ca32(ctx, t0, inv1, arg2, tcg_ctx->cpu_ca32, 0); tcg_temp_free(tcg_ctx, zero); tcg_temp_free(tcg_ctx, inv1); } else { - tcg_gen_setcond_tl(tcg_ctx, TCG_COND_GEU, cpu_ca, arg2, arg1); + tcg_gen_setcond_tl(tcg_ctx, TCG_COND_GEU, tcg_ctx->cpu_ca, arg2, arg1); tcg_gen_sub_tl(tcg_ctx, t0, arg2, arg1); - gen_op_arith_compute_ca32(ctx, t0, arg1, arg2, cpu_ca32, 1); + gen_op_arith_compute_ca32(ctx, t0, arg1, arg2, tcg_ctx->cpu_ca32, 1); } } else if (add_ca) { /* @@ -1463,7 +1453,7 @@ static inline void gen_op_arith_subf(DisasContext *ctx, TCGv ret, TCGv arg1, * standard ~arg1 + arg2 + ca to arg2 - arg1 + ca - 1. */ tcg_gen_sub_tl(tcg_ctx, t0, arg2, arg1); - tcg_gen_add_tl(tcg_ctx, t0, t0, cpu_ca); + tcg_gen_add_tl(tcg_ctx, t0, t0, tcg_ctx->cpu_ca); tcg_gen_subi_tl(tcg_ctx, t0, t0, 1); } else { tcg_gen_sub_tl(tcg_ctx, t0, arg2, arg1); @@ -1485,8 +1475,10 @@ static inline void gen_op_arith_subf(DisasContext *ctx, TCGv ret, TCGv arg1, #define GEN_INT_ARITH_SUBF(name, opc3, add_ca, compute_ca, compute_ov) \ static void glue(gen_, name)(DisasContext *ctx) \ { \ - gen_op_arith_subf(ctx, cpu_gpr[rD(ctx->opcode)], \ - cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \ + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; \ + gen_op_arith_subf(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rA(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rB(ctx->opcode)], \ add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \ } /* Sub functions with one operand and one immediate */ @@ -1496,8 +1488,8 @@ static void glue(gen_, name)(DisasContext *ctx) \ { \ TCGContext *tcg_ctx = ctx->uc->tcg_ctx; \ TCGv t0 = tcg_const_tl(tcg_ctx, const_val); \ - gen_op_arith_subf(ctx, cpu_gpr[rD(ctx->opcode)], \ - cpu_gpr[rA(ctx->opcode)], t0, \ + gen_op_arith_subf(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, \ add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \ tcg_temp_free(tcg_ctx, t0); \ } @@ -1522,7 +1514,7 @@ static void gen_subfic(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv c = tcg_const_tl(tcg_ctx, SIMM(ctx->opcode)); - gen_op_arith_subf(ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], + gen_op_arith_subf(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], c, 0, 1, 0, 0); tcg_temp_free(tcg_ctx, c); } @@ -1532,7 +1524,7 @@ static inline void gen_op_arith_neg(DisasContext *ctx, bool compute_ov) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv zero = tcg_const_tl(tcg_ctx, 0); - gen_op_arith_subf(ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], + gen_op_arith_subf(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], zero, 0, 0, compute_ov, Rc(ctx->opcode)); tcg_temp_free(tcg_ctx, zero); } @@ -1540,9 +1532,9 @@ static inline void gen_op_arith_neg(DisasContext *ctx, bool compute_ov) static void gen_neg(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_neg_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); + tcg_gen_neg_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)]); if (unlikely(Rc(ctx->opcode))) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -1556,19 +1548,21 @@ static void gen_nego(DisasContext *ctx) static void glue(gen_, name)(DisasContext *ctx) \ { \ TCGContext *tcg_ctx = ctx->uc->tcg_ctx; \ - tcg_op(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], \ - cpu_gpr[rB(ctx->opcode)]); \ + tcg_op(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rS(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); \ if (unlikely(Rc(ctx->opcode) != 0)) \ - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); \ + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); \ } #define GEN_LOGICAL1(name, tcg_op, opc, type) \ static void glue(gen_, name)(DisasContext *ctx) \ { \ TCGContext *tcg_ctx = ctx->uc->tcg_ctx; \ - tcg_op(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]); \ + tcg_op(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rS(ctx->opcode)]); \ if (unlikely(Rc(ctx->opcode) != 0)) \ - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); \ + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); \ } /* and & and. */ @@ -1580,18 +1574,18 @@ GEN_LOGICAL2(andc, tcg_gen_andc_tl, 0x01, PPC_INTEGER); static void gen_andi_(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_andi_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)], UIMM(ctx->opcode)); - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } /* andis. */ static void gen_andis_(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_andi_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)], UIMM(ctx->opcode) << 16); - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } /* cntlzw */ @@ -1600,13 +1594,13 @@ static void gen_cntlzw(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t = tcg_temp_new_i32(tcg_ctx); - tcg_gen_trunc_tl_i32(tcg_ctx, t, cpu_gpr[rS(ctx->opcode)]); + tcg_gen_trunc_tl_i32(tcg_ctx, t, tcg_ctx->cpu_gpr[rS(ctx->opcode)]); tcg_gen_clzi_i32(tcg_ctx, t, t, 32); - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t); + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t); tcg_temp_free_i32(tcg_ctx, t); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -1616,13 +1610,13 @@ static void gen_cnttzw(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t = tcg_temp_new_i32(tcg_ctx); - tcg_gen_trunc_tl_i32(tcg_ctx, t, cpu_gpr[rS(ctx->opcode)]); + tcg_gen_trunc_tl_i32(tcg_ctx, t, tcg_ctx->cpu_gpr[rS(ctx->opcode)]); tcg_gen_ctzi_i32(tcg_ctx, t, t, 32); - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t); + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t); tcg_temp_free_i32(tcg_ctx, t); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -1668,15 +1662,15 @@ static void gen_or(DisasContext *ctx) /* Optimisation for mr. ri case */ if (rs != ra || rs != rb) { if (rs != rb) { - tcg_gen_or_tl(tcg_ctx, cpu_gpr[ra], cpu_gpr[rs], cpu_gpr[rb]); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gpr[ra], tcg_ctx->cpu_gpr[rs], tcg_ctx->cpu_gpr[rb]); } else { - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[ra], cpu_gpr[rs]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[ra], tcg_ctx->cpu_gpr[rs]); } if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[ra]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[ra]); } } else if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rs]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rs]); #if defined(TARGET_PPC64) } else if (rs != 0) { /* 0 is nop */ int prio = 0; @@ -1748,13 +1742,13 @@ static void gen_xor(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; /* Optimisation for "set to zero" case */ if (rS(ctx->opcode) != rB(ctx->opcode)) { - tcg_gen_xor_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], - cpu_gpr[rB(ctx->opcode)]); + tcg_gen_xor_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)], + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } else { - tcg_gen_movi_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], 0); } if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -1767,7 +1761,7 @@ static void gen_ori(DisasContext *ctx) if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) { return; } - tcg_gen_ori_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], uimm); + tcg_gen_ori_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)], uimm); } /* oris */ @@ -1780,7 +1774,7 @@ static void gen_oris(DisasContext *ctx) /* NOP */ return; } - tcg_gen_ori_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], + tcg_gen_ori_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)], uimm << 16); } @@ -1794,7 +1788,7 @@ static void gen_xori(DisasContext *ctx) /* NOP */ return; } - tcg_gen_xori_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], uimm); + tcg_gen_xori_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)], uimm); } /* xoris */ @@ -1807,7 +1801,7 @@ static void gen_xoris(DisasContext *ctx) /* NOP */ return; } - tcg_gen_xori_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], + tcg_gen_xori_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)], uimm << 16); } @@ -1815,16 +1809,16 @@ static void gen_xoris(DisasContext *ctx) static void gen_popcntb(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_popcntb(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]); + gen_helper_popcntb(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)]); } static void gen_popcntw(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; #if defined(TARGET_PPC64) - gen_helper_popcntw(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]); + gen_helper_popcntw(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)]); #else - tcg_gen_ctpop_i32(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]); + tcg_gen_ctpop_i32(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)]); #endif } @@ -1833,7 +1827,7 @@ static void gen_popcntw(DisasContext *ctx) static void gen_popcntd(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_ctpop_i64(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]); + tcg_gen_ctpop_i64(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)]); } #endif @@ -1841,8 +1835,8 @@ static void gen_popcntd(DisasContext *ctx) static void gen_prtyw(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv ra = cpu_gpr[rA(ctx->opcode)]; - TCGv rs = cpu_gpr[rS(ctx->opcode)]; + TCGv ra = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; + TCGv rs = tcg_ctx->cpu_gpr[rS(ctx->opcode)]; TCGv t0 = tcg_temp_new(tcg_ctx); tcg_gen_shri_tl(tcg_ctx, t0, rs, 16); tcg_gen_xor_tl(tcg_ctx, ra, rs, t0); @@ -1857,8 +1851,8 @@ static void gen_prtyw(DisasContext *ctx) static void gen_prtyd(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv ra = cpu_gpr[rA(ctx->opcode)]; - TCGv rs = cpu_gpr[rS(ctx->opcode)]; + TCGv ra = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; + TCGv rs = tcg_ctx->cpu_gpr[rS(ctx->opcode)]; TCGv t0 = tcg_temp_new(tcg_ctx); tcg_gen_shri_tl(tcg_ctx, t0, rs, 32); tcg_gen_xor_tl(tcg_ctx, ra, rs, t0); @@ -1876,8 +1870,8 @@ static void gen_prtyd(DisasContext *ctx) static void gen_bpermd(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_bpermd(tcg_ctx, cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); + gen_helper_bpermd(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rS(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } #endif @@ -1889,9 +1883,9 @@ GEN_LOGICAL1(extsw, tcg_gen_ext32s_tl, 0x1E, PPC_64B); static void gen_cntlzd(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_clzi_i64(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], 64); + tcg_gen_clzi_i64(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)], 64); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -1899,9 +1893,9 @@ static void gen_cntlzd(DisasContext *ctx) static void gen_cnttzd(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_ctzi_i64(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], 64); + tcg_gen_ctzi_i64(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)], 64); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -1912,16 +1906,16 @@ static void gen_darn(DisasContext *ctx) int l = L(ctx->opcode); if (l > 2) { - tcg_gen_movi_i64(tcg_ctx, cpu_gpr[rD(ctx->opcode)], -1); + tcg_gen_movi_i64(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], -1); } else { if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(tcg_ctx); } if (l == 0) { - gen_helper_darn32(tcg_ctx, cpu_gpr[rD(ctx->opcode)]); + gen_helper_darn32(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } else { /* Return 64-bit random for both CRN and RRN */ - gen_helper_darn64(tcg_ctx, cpu_gpr[rD(ctx->opcode)]); + gen_helper_darn64(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_stop_exception(ctx); @@ -1936,8 +1930,8 @@ static void gen_darn(DisasContext *ctx) static void gen_rlwimi(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv t_ra = cpu_gpr[rA(ctx->opcode)]; - TCGv t_rs = cpu_gpr[rS(ctx->opcode)]; + TCGv t_ra = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; + TCGv t_rs = tcg_ctx->cpu_gpr[rS(ctx->opcode)]; uint32_t sh = SH(ctx->opcode); uint32_t mb = MB(ctx->opcode); uint32_t me = ME(ctx->opcode); @@ -1984,8 +1978,8 @@ static void gen_rlwimi(DisasContext *ctx) static void gen_rlwinm(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv t_ra = cpu_gpr[rA(ctx->opcode)]; - TCGv t_rs = cpu_gpr[rS(ctx->opcode)]; + TCGv t_ra = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; + TCGv t_rs = tcg_ctx->cpu_gpr[rS(ctx->opcode)]; int sh = SH(ctx->opcode); int mb = MB(ctx->opcode); int me = ME(ctx->opcode); @@ -2033,9 +2027,9 @@ static void gen_rlwinm(DisasContext *ctx) static void gen_rlwnm(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv t_ra = cpu_gpr[rA(ctx->opcode)]; - TCGv t_rs = cpu_gpr[rS(ctx->opcode)]; - TCGv t_rb = cpu_gpr[rB(ctx->opcode)]; + TCGv t_ra = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; + TCGv t_rs = tcg_ctx->cpu_gpr[rS(ctx->opcode)]; + TCGv t_rb = tcg_ctx->cpu_gpr[rB(ctx->opcode)]; uint32_t mb = MB(ctx->opcode); uint32_t me = ME(ctx->opcode); target_ulong mask; @@ -2110,8 +2104,8 @@ static void glue(gen_, name##3)(DisasContext *ctx) \ static void gen_rldinm(DisasContext *ctx, int mb, int me, int sh) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv t_ra = cpu_gpr[rA(ctx->opcode)]; - TCGv t_rs = cpu_gpr[rS(ctx->opcode)]; + TCGv t_ra = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; + TCGv t_rs = tcg_ctx->cpu_gpr[rS(ctx->opcode)]; int len = me - mb + 1; int rsh = (64 - sh) & 63; @@ -2164,9 +2158,9 @@ GEN_PPC64_R4(rldic, 0x1E, 0x04); static void gen_rldnm(DisasContext *ctx, int mb, int me) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv t_ra = cpu_gpr[rA(ctx->opcode)]; - TCGv t_rs = cpu_gpr[rS(ctx->opcode)]; - TCGv t_rb = cpu_gpr[rB(ctx->opcode)]; + TCGv t_ra = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; + TCGv t_rs = tcg_ctx->cpu_gpr[rS(ctx->opcode)]; + TCGv t_rb = tcg_ctx->cpu_gpr[rB(ctx->opcode)]; TCGv t0; t0 = tcg_temp_new(tcg_ctx); @@ -2204,8 +2198,8 @@ GEN_PPC64_R2(rldcr, 0x1E, 0x09); static void gen_rldimi(DisasContext *ctx, int mbn, int shn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv t_ra = cpu_gpr[rA(ctx->opcode)]; - TCGv t_rs = cpu_gpr[rS(ctx->opcode)]; + TCGv t_ra = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; + TCGv t_rs = tcg_ctx->cpu_gpr[rS(ctx->opcode)]; uint32_t sh = SH(ctx->opcode) | (shn << 5); uint32_t mb = MB(ctx->opcode) | (mbn << 5); uint32_t me = 63 - sh; @@ -2240,21 +2234,21 @@ static void gen_slw(DisasContext *ctx) t0 = tcg_temp_new(tcg_ctx); /* AND rS with a mask that is 0 when rB >= 0x20 */ #if defined(TARGET_PPC64) - tcg_gen_shli_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 0x3a); + tcg_gen_shli_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x3a); tcg_gen_sari_tl(tcg_ctx, t0, t0, 0x3f); #else - tcg_gen_shli_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 0x1a); + tcg_gen_shli_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1a); tcg_gen_sari_tl(tcg_ctx, t0, t0, 0x1f); #endif - tcg_gen_andc_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t0); + tcg_gen_andc_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t0); t1 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)], 0x1f); - tcg_gen_shl_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0, t1); + tcg_gen_andi_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1f); + tcg_gen_shl_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t1); tcg_temp_free(tcg_ctx, t1); tcg_temp_free(tcg_ctx, t0); - tcg_gen_ext32u_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); + tcg_gen_ext32u_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)]); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -2262,10 +2256,10 @@ static void gen_slw(DisasContext *ctx) static void gen_sraw(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_sraw(tcg_ctx, cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_env, - cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); + gen_helper_sraw(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_env, + tcg_ctx->cpu_gpr[rS(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -2274,25 +2268,25 @@ static void gen_srawi(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; int sh = SH(ctx->opcode); - TCGv dst = cpu_gpr[rA(ctx->opcode)]; - TCGv src = cpu_gpr[rS(ctx->opcode)]; + TCGv dst = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; + TCGv src = tcg_ctx->cpu_gpr[rS(ctx->opcode)]; if (sh == 0) { tcg_gen_ext32s_tl(tcg_ctx, dst, src); - tcg_gen_movi_tl(tcg_ctx, cpu_ca, 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ca, 0); if (is_isa300(ctx)) { - tcg_gen_movi_tl(tcg_ctx, cpu_ca32, 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ca32, 0); } } else { TCGv t0; tcg_gen_ext32s_tl(tcg_ctx, dst, src); - tcg_gen_andi_tl(tcg_ctx, cpu_ca, dst, (1ULL << sh) - 1); + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_ca, dst, (1ULL << sh) - 1); t0 = tcg_temp_new(tcg_ctx); tcg_gen_sari_tl(tcg_ctx, t0, dst, TARGET_LONG_BITS - 1); - tcg_gen_and_tl(tcg_ctx, cpu_ca, cpu_ca, t0); + tcg_gen_and_tl(tcg_ctx, tcg_ctx->cpu_ca, tcg_ctx->cpu_ca, t0); tcg_temp_free(tcg_ctx, t0); - tcg_gen_setcondi_tl(tcg_ctx, TCG_COND_NE, cpu_ca, cpu_ca, 0); + tcg_gen_setcondi_tl(tcg_ctx, TCG_COND_NE, tcg_ctx->cpu_ca, tcg_ctx->cpu_ca, 0); if (is_isa300(ctx)) { - tcg_gen_mov_tl(tcg_ctx, cpu_ca32, cpu_ca); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_ca32, tcg_ctx->cpu_ca); } tcg_gen_sari_tl(tcg_ctx, dst, dst, sh); } @@ -2310,21 +2304,21 @@ static void gen_srw(DisasContext *ctx) t0 = tcg_temp_new(tcg_ctx); /* AND rS with a mask that is 0 when rB >= 0x20 */ #if defined(TARGET_PPC64) - tcg_gen_shli_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 0x3a); + tcg_gen_shli_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x3a); tcg_gen_sari_tl(tcg_ctx, t0, t0, 0x3f); #else - tcg_gen_shli_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 0x1a); + tcg_gen_shli_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1a); tcg_gen_sari_tl(tcg_ctx, t0, t0, 0x1f); #endif - tcg_gen_andc_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t0); + tcg_gen_andc_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t0); tcg_gen_ext32u_tl(tcg_ctx, t0, t0); t1 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)], 0x1f); - tcg_gen_shr_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0, t1); + tcg_gen_andi_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1f); + tcg_gen_shr_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t1); tcg_temp_free(tcg_ctx, t1); tcg_temp_free(tcg_ctx, t0); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -2337,16 +2331,16 @@ static void gen_sld(DisasContext *ctx) t0 = tcg_temp_new(tcg_ctx); /* AND rS with a mask that is 0 when rB >= 0x40 */ - tcg_gen_shli_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 0x39); + tcg_gen_shli_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x39); tcg_gen_sari_tl(tcg_ctx, t0, t0, 0x3f); - tcg_gen_andc_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t0); + tcg_gen_andc_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t0); t1 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)], 0x3f); - tcg_gen_shl_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0, t1); + tcg_gen_andi_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x3f); + tcg_gen_shl_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t1); tcg_temp_free(tcg_ctx, t1); tcg_temp_free(tcg_ctx, t0); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -2354,10 +2348,10 @@ static void gen_sld(DisasContext *ctx) static void gen_srad(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_srad(tcg_ctx, cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_env, - cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); + gen_helper_srad(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_env, + tcg_ctx->cpu_gpr[rS(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } /* sradi & sradi. */ @@ -2365,24 +2359,24 @@ static inline void gen_sradi(DisasContext *ctx, int n) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; int sh = SH(ctx->opcode) + (n << 5); - TCGv dst = cpu_gpr[rA(ctx->opcode)]; - TCGv src = cpu_gpr[rS(ctx->opcode)]; + TCGv dst = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; + TCGv src = tcg_ctx->cpu_gpr[rS(ctx->opcode)]; if (sh == 0) { tcg_gen_mov_tl(tcg_ctx, dst, src); - tcg_gen_movi_tl(tcg_ctx, cpu_ca, 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ca, 0); if (is_isa300(ctx)) { - tcg_gen_movi_tl(tcg_ctx, cpu_ca32, 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ca32, 0); } } else { TCGv t0; - tcg_gen_andi_tl(tcg_ctx, cpu_ca, src, (1ULL << sh) - 1); + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_ca, src, (1ULL << sh) - 1); t0 = tcg_temp_new(tcg_ctx); tcg_gen_sari_tl(tcg_ctx, t0, src, TARGET_LONG_BITS - 1); - tcg_gen_and_tl(tcg_ctx, cpu_ca, cpu_ca, t0); + tcg_gen_and_tl(tcg_ctx, tcg_ctx->cpu_ca, tcg_ctx->cpu_ca, t0); tcg_temp_free(tcg_ctx, t0); - tcg_gen_setcondi_tl(tcg_ctx, TCG_COND_NE, cpu_ca, cpu_ca, 0); + tcg_gen_setcondi_tl(tcg_ctx, TCG_COND_NE, tcg_ctx->cpu_ca, tcg_ctx->cpu_ca, 0); if (is_isa300(ctx)) { - tcg_gen_mov_tl(tcg_ctx, cpu_ca32, cpu_ca); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_ca32, tcg_ctx->cpu_ca); } tcg_gen_sari_tl(tcg_ctx, dst, src, sh); } @@ -2406,8 +2400,8 @@ static inline void gen_extswsli(DisasContext *ctx, int n) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; int sh = SH(ctx->opcode) + (n << 5); - TCGv dst = cpu_gpr[rA(ctx->opcode)]; - TCGv src = cpu_gpr[rS(ctx->opcode)]; + TCGv dst = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; + TCGv src = tcg_ctx->cpu_gpr[rS(ctx->opcode)]; tcg_gen_ext32s_tl(tcg_ctx, dst, src); tcg_gen_shli_tl(tcg_ctx, dst, dst, sh); @@ -2434,16 +2428,16 @@ static void gen_srd(DisasContext *ctx) t0 = tcg_temp_new(tcg_ctx); /* AND rS with a mask that is 0 when rB >= 0x40 */ - tcg_gen_shli_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 0x39); + tcg_gen_shli_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x39); tcg_gen_sari_tl(tcg_ctx, t0, t0, 0x3f); - tcg_gen_andc_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t0); + tcg_gen_andc_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t0); t1 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)], 0x3f); - tcg_gen_shr_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0, t1); + tcg_gen_andi_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x3f); + tcg_gen_shr_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t1); tcg_temp_free(tcg_ctx, t1); tcg_temp_free(tcg_ctx, t0); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } #endif @@ -2463,15 +2457,15 @@ static inline void gen_addr_imm_index(DisasContext *ctx, TCGv EA, } tcg_gen_movi_tl(tcg_ctx, EA, simm); } else if (likely(simm != 0)) { - tcg_gen_addi_tl(tcg_ctx, EA, cpu_gpr[rA(ctx->opcode)], simm); + tcg_gen_addi_tl(tcg_ctx, EA, tcg_ctx->cpu_gpr[rA(ctx->opcode)], simm); if (NARROW_MODE(ctx)) { tcg_gen_ext32u_tl(tcg_ctx, EA, EA); } } else { if (NARROW_MODE(ctx)) { - tcg_gen_ext32u_tl(tcg_ctx, EA, cpu_gpr[rA(ctx->opcode)]); + tcg_gen_ext32u_tl(tcg_ctx, EA, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } else { - tcg_gen_mov_tl(tcg_ctx, EA, cpu_gpr[rA(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, EA, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } } @@ -2481,12 +2475,12 @@ static inline void gen_addr_reg_index(DisasContext *ctx, TCGv EA) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; if (rA(ctx->opcode) == 0) { if (NARROW_MODE(ctx)) { - tcg_gen_ext32u_tl(tcg_ctx, EA, cpu_gpr[rB(ctx->opcode)]); + tcg_gen_ext32u_tl(tcg_ctx, EA, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } else { - tcg_gen_mov_tl(tcg_ctx, EA, cpu_gpr[rB(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, EA, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } } else { - tcg_gen_add_tl(tcg_ctx, EA, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); + tcg_gen_add_tl(tcg_ctx, EA, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); if (NARROW_MODE(ctx)) { tcg_gen_ext32u_tl(tcg_ctx, EA, EA); } @@ -2499,9 +2493,9 @@ static inline void gen_addr_register(DisasContext *ctx, TCGv EA) if (rA(ctx->opcode) == 0) { tcg_gen_movi_tl(tcg_ctx, EA, 0); } else if (NARROW_MODE(ctx)) { - tcg_gen_ext32u_tl(tcg_ctx, EA, cpu_gpr[rA(ctx->opcode)]); + tcg_gen_ext32u_tl(tcg_ctx, EA, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } else { - tcg_gen_mov_tl(tcg_ctx, EA, cpu_gpr[rA(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, EA, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -2604,7 +2598,7 @@ static void glue(gen_, name)(DisasContext *ctx) \ gen_set_access_type(ctx, ACCESS_INT); \ EA = tcg_temp_new(tcg_ctx); \ gen_addr_imm_index(ctx, EA, 0); \ - gen_qemu_##ldop(ctx, cpu_gpr[rD(ctx->opcode)], EA); \ + gen_qemu_##ldop(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], EA); \ tcg_temp_free(tcg_ctx, EA); \ } @@ -2624,8 +2618,8 @@ static void glue(gen_, name##u)(DisasContext *ctx) \ gen_addr_imm_index(ctx, EA, 0x03); \ else \ gen_addr_imm_index(ctx, EA, 0); \ - gen_qemu_##ldop(ctx, cpu_gpr[rD(ctx->opcode)], EA); \ - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], EA); \ + gen_qemu_##ldop(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], EA); \ + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], EA); \ tcg_temp_free(tcg_ctx, EA); \ } @@ -2642,8 +2636,8 @@ static void glue(gen_, name##ux)(DisasContext *ctx) \ gen_set_access_type(ctx, ACCESS_INT); \ EA = tcg_temp_new(tcg_ctx); \ gen_addr_reg_index(ctx, EA); \ - gen_qemu_##ldop(ctx, cpu_gpr[rD(ctx->opcode)], EA); \ - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], EA); \ + gen_qemu_##ldop(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], EA); \ + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], EA); \ tcg_temp_free(tcg_ctx, EA); \ } @@ -2656,7 +2650,7 @@ static void glue(gen_, name##x)(DisasContext *ctx) \ gen_set_access_type(ctx, ACCESS_INT); \ EA = tcg_temp_new(tcg_ctx); \ gen_addr_reg_index(ctx, EA); \ - gen_qemu_##ldop(ctx, cpu_gpr[rD(ctx->opcode)], EA); \ + gen_qemu_##ldop(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], EA); \ tcg_temp_free(tcg_ctx, EA); \ } @@ -2690,7 +2684,7 @@ static void glue(gen_, name##epx)(DisasContext *ctx) \ gen_set_access_type(ctx, ACCESS_INT); \ EA = tcg_temp_new(tcg_ctx); \ gen_addr_reg_index(ctx, EA); \ - tcg_gen_qemu_ld_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], EA, PPC_TLB_EPID_LOAD, ldop);\ + tcg_gen_qemu_ld_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], EA, PPC_TLB_EPID_LOAD, ldop);\ tcg_temp_free(tcg_ctx, EA); \ } @@ -2733,13 +2727,13 @@ static void gen_ld(DisasContext *ctx) gen_addr_imm_index(ctx, EA, 0x03); if (ctx->opcode & 0x02) { /* lwa (lwau is undefined) */ - gen_qemu_ld32s(ctx, cpu_gpr[rD(ctx->opcode)], EA); + gen_qemu_ld32s(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], EA); } else { /* ld - ldu */ - gen_qemu_ld64_i64(ctx, cpu_gpr[rD(ctx->opcode)], EA); + gen_qemu_ld64_i64(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], EA); } if (Rc(ctx->opcode)) { - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], EA); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], EA); } tcg_temp_free(tcg_ctx, EA); } @@ -2776,8 +2770,8 @@ static void gen_lq(DisasContext *ctx) gen_addr_imm_index(ctx, EA, 0x0F); /* Note that the low part is always in RD+1, even in LE mode. */ - lo = cpu_gpr[rd + 1]; - hi = cpu_gpr[rd]; + lo = tcg_ctx->cpu_gpr[rd + 1]; + hi = tcg_ctx->cpu_gpr[rd]; if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { #if HAVE_ATOMIC128 == 1 @@ -2818,7 +2812,7 @@ static void glue(gen_, name)(DisasContext *ctx) \ gen_set_access_type(ctx, ACCESS_INT); \ EA = tcg_temp_new(tcg_ctx); \ gen_addr_imm_index(ctx, EA, 0); \ - gen_qemu_##stop(ctx, cpu_gpr[rS(ctx->opcode)], EA); \ + gen_qemu_##stop(ctx, tcg_ctx->cpu_gpr[rS(ctx->opcode)], EA); \ tcg_temp_free(tcg_ctx, EA); \ } @@ -2837,8 +2831,8 @@ static void glue(gen_, stop##u)(DisasContext *ctx) \ gen_addr_imm_index(ctx, EA, 0x03); \ else \ gen_addr_imm_index(ctx, EA, 0); \ - gen_qemu_##stop(ctx, cpu_gpr[rS(ctx->opcode)], EA); \ - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], EA); \ + gen_qemu_##stop(ctx, tcg_ctx->cpu_gpr[rS(ctx->opcode)], EA); \ + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], EA); \ tcg_temp_free(tcg_ctx, EA); \ } @@ -2854,8 +2848,8 @@ static void glue(gen_, name##ux)(DisasContext *ctx) \ gen_set_access_type(ctx, ACCESS_INT); \ EA = tcg_temp_new(tcg_ctx); \ gen_addr_reg_index(ctx, EA); \ - gen_qemu_##stop(ctx, cpu_gpr[rS(ctx->opcode)], EA); \ - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], EA); \ + gen_qemu_##stop(ctx, tcg_ctx->cpu_gpr[rS(ctx->opcode)], EA); \ + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], EA); \ tcg_temp_free(tcg_ctx, EA); \ } @@ -2868,7 +2862,7 @@ static void glue(gen_, name##x)(DisasContext *ctx) \ gen_set_access_type(ctx, ACCESS_INT); \ EA = tcg_temp_new(tcg_ctx); \ gen_addr_reg_index(ctx, EA); \ - gen_qemu_##stop(ctx, cpu_gpr[rS(ctx->opcode)], EA); \ + gen_qemu_##stop(ctx, tcg_ctx->cpu_gpr[rS(ctx->opcode)], EA); \ tcg_temp_free(tcg_ctx, EA); \ } #define GEN_STX(name, stop, opc2, opc3, type) \ @@ -2900,7 +2894,7 @@ static void glue(gen_, name##epx)(DisasContext *ctx) \ EA = tcg_temp_new(tcg_ctx); \ gen_addr_reg_index(ctx, EA); \ tcg_gen_qemu_st_tl(tcg_ctx, \ - cpu_gpr[rD(ctx->opcode)], EA, PPC_TLB_EPID_STORE, stop); \ + tcg_ctx->cpu_gpr[rD(ctx->opcode)], EA, PPC_TLB_EPID_STORE, stop); \ tcg_temp_free(tcg_ctx, EA); \ } @@ -2954,8 +2948,8 @@ static void gen_std(DisasContext *ctx) gen_addr_imm_index(ctx, EA, 0x03); /* Note that the low part is always in RS+1, even in LE mode. */ - lo = cpu_gpr[rs + 1]; - hi = cpu_gpr[rs]; + lo = tcg_ctx->cpu_gpr[rs + 1]; + hi = tcg_ctx->cpu_gpr[rs]; if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { #if HAVE_ATOMIC128 == 1 @@ -2994,9 +2988,9 @@ static void gen_std(DisasContext *ctx) gen_set_access_type(ctx, ACCESS_INT); EA = tcg_temp_new(tcg_ctx); gen_addr_imm_index(ctx, EA, 0x03); - gen_qemu_st64_i64(ctx, cpu_gpr[rs], EA); + gen_qemu_st64_i64(ctx, tcg_ctx->cpu_gpr[rs], EA); if (Rc(ctx->opcode)) { - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], EA); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], EA); } tcg_temp_free(tcg_ctx, EA); } @@ -3171,7 +3165,7 @@ static void gen_stswx(DisasContext *ctx) t0 = tcg_temp_new(tcg_ctx); gen_addr_reg_index(ctx, t0); t1 = tcg_temp_new_i32(tcg_ctx); - tcg_gen_trunc_tl_i32(tcg_ctx, t1, cpu_xer); + tcg_gen_trunc_tl_i32(tcg_ctx, t1, tcg_ctx->cpu_xer); tcg_gen_andi_i32(tcg_ctx, t1, t1, 0x7F); t2 = tcg_const_i32(tcg_ctx, rS(ctx->opcode)); gen_helper_stsw(tcg_ctx, tcg_ctx->cpu_env, t0, t1, t2); @@ -3251,14 +3245,14 @@ static void gen_isync(DisasContext *ctx) static void gen_load_locked(DisasContext *ctx, MemOp memop) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv gpr = cpu_gpr[rD(ctx->opcode)]; + TCGv gpr = tcg_ctx->cpu_gpr[rD(ctx->opcode)]; TCGv t0 = tcg_temp_new(tcg_ctx); gen_set_access_type(ctx, ACCESS_RES); gen_addr_reg_index(ctx, t0); tcg_gen_qemu_ld_tl(tcg_ctx, gpr, t0, ctx->mem_idx, memop | MO_ALIGN); - tcg_gen_mov_tl(tcg_ctx, cpu_reserve, t0); - tcg_gen_mov_tl(tcg_ctx, cpu_reserve_val, gpr); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_reserve, t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_reserve_val, gpr); tcg_gen_mb(tcg_ctx, TCG_MO_ALL | TCG_BAR_LDAQ); tcg_temp_free(tcg_ctx, t0); } @@ -3294,7 +3288,7 @@ static void gen_fetch_inc_conditional(DisasContext *ctx, MemOp memop, /* RT = (t != t2 ? t : u = 1<<(s*8-1)) */ tcg_gen_movi_tl(tcg_ctx, u, 1ULL << (MEMOP_GET_SIZE(memop) * 8 - 1)); - tcg_gen_movcond_tl(tcg_ctx, cond, cpu_gpr[rD(ctx->opcode)], t, t2, t, u); + tcg_gen_movcond_tl(tcg_ctx, cond, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t, t2, t, u); tcg_temp_free(tcg_ctx, t); tcg_temp_free(tcg_ctx, t2); @@ -3311,8 +3305,8 @@ static void gen_ld_atomic(DisasContext *ctx, MemOp memop) TCGv src, dst; gen_addr_register(ctx, EA); - dst = cpu_gpr[rt]; - src = cpu_gpr[(rt + 1) & 31]; + dst = tcg_ctx->cpu_gpr[rt]; + src = tcg_ctx->cpu_gpr[(rt + 1) & 31]; need_serial = false; memop |= MO_ALIGN; @@ -3359,7 +3353,7 @@ static void gen_ld_atomic(DisasContext *ctx, MemOp memop) tcg_gen_ext32u_tl(tcg_ctx, t1, src); } tcg_gen_movcond_tl(tcg_ctx, TCG_COND_NE, t1, t0, t1, - cpu_gpr[(rt + 2) & 31], t0); + tcg_ctx->cpu_gpr[(rt + 2) & 31], t0); tcg_gen_qemu_st_tl(tcg_ctx, t1, EA, ctx->mem_idx, memop); tcg_gen_mov_tl(tcg_ctx, dst, t0); @@ -3423,7 +3417,7 @@ static void gen_st_atomic(DisasContext *ctx, MemOp memop) TCGv src, discard; gen_addr_register(ctx, EA); - src = cpu_gpr[rD(ctx->opcode)]; + src = tcg_ctx->cpu_gpr[rD(ctx->opcode)]; discard = tcg_temp_new(tcg_ctx); memop |= MO_ALIGN; @@ -3509,17 +3503,17 @@ static void gen_conditional_store(DisasContext *ctx, MemOp memop) gen_set_access_type(ctx, ACCESS_RES); gen_addr_reg_index(ctx, t0); - tcg_gen_brcond_tl(tcg_ctx, TCG_COND_NE, t0, cpu_reserve, l1); + tcg_gen_brcond_tl(tcg_ctx, TCG_COND_NE, t0, tcg_ctx->cpu_reserve, l1); tcg_temp_free(tcg_ctx, t0); t0 = tcg_temp_new(tcg_ctx); - tcg_gen_atomic_cmpxchg_tl(tcg_ctx, t0, cpu_reserve, cpu_reserve_val, - cpu_gpr[reg], ctx->mem_idx, + tcg_gen_atomic_cmpxchg_tl(tcg_ctx, t0, tcg_ctx->cpu_reserve, tcg_ctx->cpu_reserve_val, + tcg_ctx->cpu_gpr[reg], ctx->mem_idx, DEF_MEMOP(memop) | MO_ALIGN); - tcg_gen_setcond_tl(tcg_ctx, TCG_COND_EQ, t0, t0, cpu_reserve_val); + tcg_gen_setcond_tl(tcg_ctx, TCG_COND_EQ, t0, t0, tcg_ctx->cpu_reserve_val); tcg_gen_shli_tl(tcg_ctx, t0, t0, CRF_EQ_BIT); - tcg_gen_or_tl(tcg_ctx, t0, t0, cpu_so); - tcg_gen_trunc_tl_i32(tcg_ctx, cpu_crf[0], t0); + tcg_gen_or_tl(tcg_ctx, t0, t0, tcg_ctx->cpu_so); + tcg_gen_trunc_tl_i32(tcg_ctx, tcg_ctx->cpu_crf[0], t0); tcg_temp_free(tcg_ctx, t0); tcg_gen_br(tcg_ctx, l2); @@ -3530,10 +3524,10 @@ static void gen_conditional_store(DisasContext *ctx, MemOp memop) * the memory barrier semantics of the instruction. */ tcg_gen_mb(tcg_ctx, TCG_MO_ALL | TCG_BAR_STRL); - tcg_gen_trunc_tl_i32(tcg_ctx, cpu_crf[0], cpu_so); + tcg_gen_trunc_tl_i32(tcg_ctx, tcg_ctx->cpu_crf[0], tcg_ctx->cpu_so); gen_set_label(tcg_ctx, l2); - tcg_gen_movi_tl(tcg_ctx, cpu_reserve, -1); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_reserve, -1); } #define STCX(name, memop) \ @@ -3570,8 +3564,8 @@ static void gen_lqarx(DisasContext *ctx) gen_addr_reg_index(ctx, EA); /* Note that the low part is always in RD+1, even in LE mode. */ - lo = cpu_gpr[rd + 1]; - hi = cpu_gpr[rd]; + lo = tcg_ctx->cpu_gpr[rd + 1]; + hi = tcg_ctx->cpu_gpr[rd]; if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { #if HAVE_ATOMIC128 == 1 @@ -3596,12 +3590,12 @@ static void gen_lqarx(DisasContext *ctx) #endif } else if (ctx->le_mode) { tcg_gen_qemu_ld_i64(tcg_ctx, lo, EA, ctx->mem_idx, MO_LEQ | MO_ALIGN_16); - tcg_gen_mov_tl(tcg_ctx, cpu_reserve, EA); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_reserve, EA); gen_addr_add(ctx, EA, EA, 8); tcg_gen_qemu_ld_i64(tcg_ctx, hi, EA, ctx->mem_idx, MO_LEQ); } else { tcg_gen_qemu_ld_i64(tcg_ctx, hi, EA, ctx->mem_idx, MO_BEQ | MO_ALIGN_16); - tcg_gen_mov_tl(tcg_ctx, cpu_reserve, EA); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_reserve, EA); gen_addr_add(ctx, EA, EA, 8); tcg_gen_qemu_ld_i64(tcg_ctx, lo, EA, ctx->mem_idx, MO_BEQ); } @@ -3628,17 +3622,17 @@ static void gen_stqcx_(DisasContext *ctx) gen_addr_reg_index(ctx, EA); /* Note that the low part is always in RS+1, even in LE mode. */ - lo = cpu_gpr[rs + 1]; - hi = cpu_gpr[rs]; + lo = tcg_ctx->cpu_gpr[rs + 1]; + hi = tcg_ctx->cpu_gpr[rs]; if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { #if HAVE_CMPXCHG128 == 1 TCGv_i32 oi = tcg_const_i32(tcg_ctx, DEF_MEMOP(MO_Q) | MO_ALIGN_16); if (ctx->le_mode) { - gen_helper_stqcx_le_parallel(tcg_ctx, cpu_crf[0], tcg_ctx->cpu_env, + gen_helper_stqcx_le_parallel(tcg_ctx, tcg_ctx->cpu_crf[0], tcg_ctx->cpu_env, EA, lo, hi, oi); } else { - gen_helper_stqcx_be_parallel(tcg_ctx, cpu_crf[0], tcg_ctx->cpu_env, + gen_helper_stqcx_be_parallel(tcg_ctx, tcg_ctx->cpu_crf[0], tcg_ctx->cpu_env, EA, lo, hi, oi); } tcg_temp_free_i32(tcg_ctx, oi); @@ -3654,16 +3648,16 @@ static void gen_stqcx_(DisasContext *ctx) TCGv_i64 t0 = tcg_temp_new_i64(tcg_ctx); TCGv_i64 t1 = tcg_temp_new_i64(tcg_ctx); - tcg_gen_brcond_tl(tcg_ctx, TCG_COND_NE, EA, cpu_reserve, lab_fail); + tcg_gen_brcond_tl(tcg_ctx, TCG_COND_NE, EA, tcg_ctx->cpu_reserve, lab_fail); tcg_temp_free(tcg_ctx, EA); - gen_qemu_ld64_i64(ctx, t0, cpu_reserve); + gen_qemu_ld64_i64(ctx, t0, tcg_ctx->cpu_reserve); tcg_gen_ld_i64(tcg_ctx, t1, tcg_ctx->cpu_env, (ctx->le_mode ? offsetof(CPUPPCState, reserve_val2) : offsetof(CPUPPCState, reserve_val))); tcg_gen_brcond_i64(tcg_ctx, TCG_COND_NE, t0, t1, lab_fail); - tcg_gen_addi_i64(tcg_ctx, t0, cpu_reserve, 8); + tcg_gen_addi_i64(tcg_ctx, t0, tcg_ctx->cpu_reserve, 8); gen_qemu_ld64_i64(ctx, t0, t0); tcg_gen_ld_i64(tcg_ctx, t1, tcg_ctx->cpu_env, (ctx->le_mode ? offsetof(CPUPPCState, reserve_val) @@ -3671,19 +3665,19 @@ static void gen_stqcx_(DisasContext *ctx) tcg_gen_brcond_i64(tcg_ctx, TCG_COND_NE, t0, t1, lab_fail); /* Success */ - gen_qemu_st64_i64(ctx, ctx->le_mode ? lo : hi, cpu_reserve); - tcg_gen_addi_i64(tcg_ctx, t0, cpu_reserve, 8); + gen_qemu_st64_i64(ctx, ctx->le_mode ? lo : hi, tcg_ctx->cpu_reserve); + tcg_gen_addi_i64(tcg_ctx, t0, tcg_ctx->cpu_reserve, 8); gen_qemu_st64_i64(ctx, ctx->le_mode ? hi : lo, t0); - tcg_gen_trunc_tl_i32(tcg_ctx, cpu_crf[0], cpu_so); - tcg_gen_ori_i32(tcg_ctx, cpu_crf[0], cpu_crf[0], CRF_EQ); + tcg_gen_trunc_tl_i32(tcg_ctx, tcg_ctx->cpu_crf[0], tcg_ctx->cpu_so); + tcg_gen_ori_i32(tcg_ctx, tcg_ctx->cpu_crf[0], tcg_ctx->cpu_crf[0], CRF_EQ); tcg_gen_br(tcg_ctx, lab_over); gen_set_label(tcg_ctx, lab_fail); - tcg_gen_trunc_tl_i32(tcg_ctx, cpu_crf[0], cpu_so); + tcg_gen_trunc_tl_i32(tcg_ctx, tcg_ctx->cpu_crf[0], tcg_ctx->cpu_so); gen_set_label(tcg_ctx, lab_over); - tcg_gen_movi_tl(tcg_ctx, cpu_reserve, -1); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_reserve, -1); tcg_temp_free_i64(tcg_ctx, t0); tcg_temp_free_i64(tcg_ctx, t1); } @@ -3799,7 +3793,7 @@ static inline void gen_update_cfar(DisasContext *ctx, target_ulong nip) #if defined(TARGET_PPC64) if (ctx->has_cfar) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_movi_tl(tcg_ctx, cpu_cfar, nip); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_cfar, nip); } #endif } @@ -3839,10 +3833,10 @@ static void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest) } if (use_goto_tb(ctx, dest)) { tcg_gen_goto_tb(tcg_ctx, n); - tcg_gen_movi_tl(tcg_ctx, cpu_nip, dest & ~3); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_nip, dest & ~3); tcg_gen_exit_tb(tcg_ctx, ctx->base.tb, n); } else { - tcg_gen_movi_tl(tcg_ctx, cpu_nip, dest & ~3); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_nip, dest & ~3); gen_lookup_and_goto_ptr(ctx); } } @@ -3853,7 +3847,7 @@ static inline void gen_setlr(DisasContext *ctx, target_ulong nip) if (NARROW_MODE(ctx)) { nip = (uint32_t)nip; } - tcg_gen_movi_tl(tcg_ctx, cpu_lr, nip); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_lr, nip); } /* b ba bl bla */ @@ -3893,11 +3887,11 @@ static void gen_bcond(DisasContext *ctx, int type) if (type == BCOND_LR || type == BCOND_CTR || type == BCOND_TAR) { target = tcg_temp_local_new(tcg_ctx); if (type == BCOND_CTR) { - tcg_gen_mov_tl(tcg_ctx, target, cpu_ctr); + tcg_gen_mov_tl(tcg_ctx, target, tcg_ctx->cpu_ctr); } else if (type == BCOND_TAR) { gen_load_spr(tcg_ctx, target, SPR_TAR); } else { - tcg_gen_mov_tl(tcg_ctx, target, cpu_lr); + tcg_gen_mov_tl(tcg_ctx, target, tcg_ctx->cpu_lr); } } else { target = NULL; @@ -3933,22 +3927,22 @@ static void gen_bcond(DisasContext *ctx, int type) } if (NARROW_MODE(ctx)) { - tcg_gen_ext32u_tl(tcg_ctx, temp, cpu_ctr); + tcg_gen_ext32u_tl(tcg_ctx, temp, tcg_ctx->cpu_ctr); } else { - tcg_gen_mov_tl(tcg_ctx, temp, cpu_ctr); + tcg_gen_mov_tl(tcg_ctx, temp, tcg_ctx->cpu_ctr); } if (bo & 0x2) { tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_NE, temp, 0, l1); } else { tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_EQ, temp, 0, l1); } - tcg_gen_subi_tl(tcg_ctx, cpu_ctr, cpu_ctr, 1); + tcg_gen_subi_tl(tcg_ctx, tcg_ctx->cpu_ctr, tcg_ctx->cpu_ctr, 1); } else { - tcg_gen_subi_tl(tcg_ctx, cpu_ctr, cpu_ctr, 1); + tcg_gen_subi_tl(tcg_ctx, tcg_ctx->cpu_ctr, tcg_ctx->cpu_ctr, 1); if (NARROW_MODE(ctx)) { - tcg_gen_ext32u_tl(tcg_ctx, temp, cpu_ctr); + tcg_gen_ext32u_tl(tcg_ctx, temp, tcg_ctx->cpu_ctr); } else { - tcg_gen_mov_tl(tcg_ctx, temp, cpu_ctr); + tcg_gen_mov_tl(tcg_ctx, temp, tcg_ctx->cpu_ctr); } if (bo & 0x2) { tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_NE, temp, 0, l1); @@ -3965,10 +3959,10 @@ static void gen_bcond(DisasContext *ctx, int type) TCGv_i32 temp = tcg_temp_new_i32(tcg_ctx); if (bo & 0x8) { - tcg_gen_andi_i32(tcg_ctx, temp, cpu_crf[bi >> 2], mask); + tcg_gen_andi_i32(tcg_ctx, temp, tcg_ctx->cpu_crf[bi >> 2], mask); tcg_gen_brcondi_i32(tcg_ctx, TCG_COND_EQ, temp, 0, l1); } else { - tcg_gen_andi_i32(tcg_ctx, temp, cpu_crf[bi >> 2], mask); + tcg_gen_andi_i32(tcg_ctx, temp, tcg_ctx->cpu_crf[bi >> 2], mask); tcg_gen_brcondi_i32(tcg_ctx, TCG_COND_NE, temp, 0, l1); } tcg_temp_free_i32(tcg_ctx, temp); @@ -3983,9 +3977,9 @@ static void gen_bcond(DisasContext *ctx, int type) } } else { if (NARROW_MODE(ctx)) { - tcg_gen_andi_tl(tcg_ctx, cpu_nip, target, (uint32_t)~3); + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_nip, target, (uint32_t)~3); } else { - tcg_gen_andi_tl(tcg_ctx, cpu_nip, target, ~3); + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_nip, target, ~3); } gen_lookup_and_goto_ptr(ctx); tcg_temp_free(tcg_ctx, target); @@ -4028,24 +4022,24 @@ static void glue(gen_, name)(DisasContext *ctx) \ sh = (crbD(ctx->opcode) & 0x03) - (crbA(ctx->opcode) & 0x03); \ t0 = tcg_temp_new_i32(tcg_ctx); \ if (sh > 0) \ - tcg_gen_shri_i32(tcg_ctx, t0, cpu_crf[crbA(ctx->opcode) >> 2], sh); \ + tcg_gen_shri_i32(tcg_ctx, t0, tcg_ctx->cpu_crf[crbA(ctx->opcode) >> 2], sh); \ else if (sh < 0) \ - tcg_gen_shli_i32(tcg_ctx, t0, cpu_crf[crbA(ctx->opcode) >> 2], -sh); \ + tcg_gen_shli_i32(tcg_ctx, t0, tcg_ctx->cpu_crf[crbA(ctx->opcode) >> 2], -sh); \ else \ - tcg_gen_mov_i32(tcg_ctx, t0, cpu_crf[crbA(ctx->opcode) >> 2]); \ + tcg_gen_mov_i32(tcg_ctx, t0, tcg_ctx->cpu_crf[crbA(ctx->opcode) >> 2]); \ t1 = tcg_temp_new_i32(tcg_ctx); \ sh = (crbD(ctx->opcode) & 0x03) - (crbB(ctx->opcode) & 0x03); \ if (sh > 0) \ - tcg_gen_shri_i32(tcg_ctx, t1, cpu_crf[crbB(ctx->opcode) >> 2], sh); \ + tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->cpu_crf[crbB(ctx->opcode) >> 2], sh); \ else if (sh < 0) \ - tcg_gen_shli_i32(tcg_ctx, t1, cpu_crf[crbB(ctx->opcode) >> 2], -sh); \ + tcg_gen_shli_i32(tcg_ctx, t1, tcg_ctx->cpu_crf[crbB(ctx->opcode) >> 2], -sh); \ else \ - tcg_gen_mov_i32(tcg_ctx, t1, cpu_crf[crbB(ctx->opcode) >> 2]); \ + tcg_gen_mov_i32(tcg_ctx, t1, tcg_ctx->cpu_crf[crbB(ctx->opcode) >> 2]); \ tcg_op(tcg_ctx, t0, t0, t1); \ bitmask = 0x08 >> (crbD(ctx->opcode) & 0x03); \ tcg_gen_andi_i32(tcg_ctx, t0, t0, bitmask); \ - tcg_gen_andi_i32(tcg_ctx, t1, cpu_crf[crbD(ctx->opcode) >> 2], ~bitmask); \ - tcg_gen_or_i32(tcg_ctx, cpu_crf[crbD(ctx->opcode) >> 2], t0, t1); \ + tcg_gen_andi_i32(tcg_ctx, t1, tcg_ctx->cpu_crf[crbD(ctx->opcode) >> 2], ~bitmask); \ + tcg_gen_or_i32(tcg_ctx, tcg_ctx->cpu_crf[crbD(ctx->opcode) >> 2], t0, t1); \ tcg_temp_free_i32(tcg_ctx, t0); \ tcg_temp_free_i32(tcg_ctx, t1); \ } @@ -4071,7 +4065,7 @@ GEN_CRLOGIC(crxor, tcg_gen_xor_i32, 0x06); static void gen_mcrf(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_mov_i32(tcg_ctx, cpu_crf[crfD(ctx->opcode)], cpu_crf[crfS(ctx->opcode)]); + tcg_gen_mov_i32(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], tcg_ctx->cpu_crf[crfS(ctx->opcode)]); } /*** System linkage ***/ @@ -4159,7 +4153,7 @@ static void gen_tw(DisasContext *ctx) return; } t0 = tcg_const_i32(tcg_ctx, TO(ctx->opcode)); - gen_helper_tw(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], + gen_helper_tw(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)], t0); tcg_temp_free_i32(tcg_ctx, t0); } @@ -4176,7 +4170,7 @@ static void gen_twi(DisasContext *ctx) } t0 = tcg_const_tl(tcg_ctx, SIMM(ctx->opcode)); t1 = tcg_const_i32(tcg_ctx, TO(ctx->opcode)); - gen_helper_tw(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rA(ctx->opcode)], t0, t1); + gen_helper_tw(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free_i32(tcg_ctx, t1); } @@ -4192,7 +4186,7 @@ static void gen_td(DisasContext *ctx) return; } t0 = tcg_const_i32(tcg_ctx, TO(ctx->opcode)); - gen_helper_td(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], + gen_helper_td(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)], t0); tcg_temp_free_i32(tcg_ctx, t0); } @@ -4209,7 +4203,7 @@ static void gen_tdi(DisasContext *ctx) } t0 = tcg_const_tl(tcg_ctx, SIMM(ctx->opcode)); t1 = tcg_const_i32(tcg_ctx, TO(ctx->opcode)); - gen_helper_td(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rA(ctx->opcode)], t0, t1); + gen_helper_td(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free_i32(tcg_ctx, t1); } @@ -4223,17 +4217,17 @@ static void gen_read_xer(DisasContext *ctx, TCGv dst) TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); TCGv t2 = tcg_temp_new(tcg_ctx); - tcg_gen_mov_tl(tcg_ctx, dst, cpu_xer); - tcg_gen_shli_tl(tcg_ctx, t0, cpu_so, XER_SO); - tcg_gen_shli_tl(tcg_ctx, t1, cpu_ov, XER_OV); - tcg_gen_shli_tl(tcg_ctx, t2, cpu_ca, XER_CA); + tcg_gen_mov_tl(tcg_ctx, dst, tcg_ctx->cpu_xer); + tcg_gen_shli_tl(tcg_ctx, t0, tcg_ctx->cpu_so, XER_SO); + tcg_gen_shli_tl(tcg_ctx, t1, tcg_ctx->cpu_ov, XER_OV); + tcg_gen_shli_tl(tcg_ctx, t2, tcg_ctx->cpu_ca, XER_CA); tcg_gen_or_tl(tcg_ctx, t0, t0, t1); tcg_gen_or_tl(tcg_ctx, dst, dst, t2); tcg_gen_or_tl(tcg_ctx, dst, dst, t0); if (is_isa300(ctx)) { - tcg_gen_shli_tl(tcg_ctx, t0, cpu_ov32, XER_OV32); + tcg_gen_shli_tl(tcg_ctx, t0, tcg_ctx->cpu_ov32, XER_OV32); tcg_gen_or_tl(tcg_ctx, dst, dst, t0); - tcg_gen_shli_tl(tcg_ctx, t0, cpu_ca32, XER_CA32); + tcg_gen_shli_tl(tcg_ctx, t0, tcg_ctx->cpu_ca32, XER_CA32); tcg_gen_or_tl(tcg_ctx, dst, dst, t0); } tcg_temp_free(tcg_ctx, t0); @@ -4244,15 +4238,15 @@ static void gen_read_xer(DisasContext *ctx, TCGv dst) static void gen_write_xer(TCGContext *tcg_ctx, TCGv src) { /* Write all flags, while reading back check for isa300 */ - tcg_gen_andi_tl(tcg_ctx, cpu_xer, src, + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_xer, src, ~((1u << XER_SO) | (1u << XER_OV) | (1u << XER_OV32) | (1u << XER_CA) | (1u << XER_CA32))); - tcg_gen_extract_tl(tcg_ctx, cpu_ov32, src, XER_OV32, 1); - tcg_gen_extract_tl(tcg_ctx, cpu_ca32, src, XER_CA32, 1); - tcg_gen_extract_tl(tcg_ctx, cpu_so, src, XER_SO, 1); - tcg_gen_extract_tl(tcg_ctx, cpu_ov, src, XER_OV, 1); - tcg_gen_extract_tl(tcg_ctx, cpu_ca, src, XER_CA, 1); + tcg_gen_extract_tl(tcg_ctx, tcg_ctx->cpu_ov32, src, XER_OV32, 1); + tcg_gen_extract_tl(tcg_ctx, tcg_ctx->cpu_ca32, src, XER_CA32, 1); + tcg_gen_extract_tl(tcg_ctx, tcg_ctx->cpu_so, src, XER_SO, 1); + tcg_gen_extract_tl(tcg_ctx, tcg_ctx->cpu_ov, src, XER_OV, 1); + tcg_gen_extract_tl(tcg_ctx, tcg_ctx->cpu_ca, src, XER_CA, 1); } /* mcrxr */ @@ -4261,11 +4255,11 @@ static void gen_mcrxr(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_temp_new_i32(tcg_ctx); TCGv_i32 t1 = tcg_temp_new_i32(tcg_ctx); - TCGv_i32 dst = cpu_crf[crfD(ctx->opcode)]; + TCGv_i32 dst = tcg_ctx->cpu_crf[crfD(ctx->opcode)]; - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_so); - tcg_gen_trunc_tl_i32(tcg_ctx, t1, cpu_ov); - tcg_gen_trunc_tl_i32(tcg_ctx, dst, cpu_ca); + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_so); + tcg_gen_trunc_tl_i32(tcg_ctx, t1, tcg_ctx->cpu_ov); + tcg_gen_trunc_tl_i32(tcg_ctx, dst, tcg_ctx->cpu_ca); tcg_gen_shli_i32(tcg_ctx, t0, t0, 3); tcg_gen_shli_i32(tcg_ctx, t1, t1, 2); tcg_gen_shli_i32(tcg_ctx, dst, dst, 1); @@ -4274,9 +4268,9 @@ static void gen_mcrxr(DisasContext *ctx) tcg_temp_free_i32(tcg_ctx, t0); tcg_temp_free_i32(tcg_ctx, t1); - tcg_gen_movi_tl(tcg_ctx, cpu_so, 0); - tcg_gen_movi_tl(tcg_ctx, cpu_ov, 0); - tcg_gen_movi_tl(tcg_ctx, cpu_ca, 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_so, 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ov, 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ca, 0); } #ifdef TARGET_PPC64 @@ -4286,15 +4280,15 @@ static void gen_mcrxrx(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - TCGv_i32 dst = cpu_crf[crfD(ctx->opcode)]; + TCGv_i32 dst = tcg_ctx->cpu_crf[crfD(ctx->opcode)]; /* copy OV and OV32 */ - tcg_gen_shli_tl(tcg_ctx, t0, cpu_ov, 1); - tcg_gen_or_tl(tcg_ctx, t0, t0, cpu_ov32); + tcg_gen_shli_tl(tcg_ctx, t0, tcg_ctx->cpu_ov, 1); + tcg_gen_or_tl(tcg_ctx, t0, t0, tcg_ctx->cpu_ov32); tcg_gen_shli_tl(tcg_ctx, t0, t0, 2); /* copy CA and CA32 */ - tcg_gen_shli_tl(tcg_ctx, t1, cpu_ca, 1); - tcg_gen_or_tl(tcg_ctx, t1, t1, cpu_ca32); + tcg_gen_shli_tl(tcg_ctx, t1, tcg_ctx->cpu_ca, 1); + tcg_gen_or_tl(tcg_ctx, t1, t1, tcg_ctx->cpu_ca32); tcg_gen_or_tl(tcg_ctx, t0, t0, t1); tcg_gen_trunc_tl_i32(tcg_ctx, dst, t0); tcg_temp_free(tcg_ctx, t0); @@ -4312,28 +4306,28 @@ static void gen_mfcr(DisasContext *ctx) crm = CRM(ctx->opcode); if (likely(crm && ((crm & (crm - 1)) == 0))) { crn = ctz32(crm); - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_crf[7 - crn]); - tcg_gen_shli_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], - cpu_gpr[rD(ctx->opcode)], crn * 4); + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_crf[7 - crn]); + tcg_gen_shli_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], + tcg_ctx->cpu_gpr[rD(ctx->opcode)], crn * 4); } } else { TCGv_i32 t0 = tcg_temp_new_i32(tcg_ctx); - tcg_gen_mov_i32(tcg_ctx, t0, cpu_crf[0]); + tcg_gen_mov_i32(tcg_ctx, t0, tcg_ctx->cpu_crf[0]); tcg_gen_shli_i32(tcg_ctx, t0, t0, 4); - tcg_gen_or_i32(tcg_ctx, t0, t0, cpu_crf[1]); + tcg_gen_or_i32(tcg_ctx, t0, t0, tcg_ctx->cpu_crf[1]); tcg_gen_shli_i32(tcg_ctx, t0, t0, 4); - tcg_gen_or_i32(tcg_ctx, t0, t0, cpu_crf[2]); + tcg_gen_or_i32(tcg_ctx, t0, t0, tcg_ctx->cpu_crf[2]); tcg_gen_shli_i32(tcg_ctx, t0, t0, 4); - tcg_gen_or_i32(tcg_ctx, t0, t0, cpu_crf[3]); + tcg_gen_or_i32(tcg_ctx, t0, t0, tcg_ctx->cpu_crf[3]); tcg_gen_shli_i32(tcg_ctx, t0, t0, 4); - tcg_gen_or_i32(tcg_ctx, t0, t0, cpu_crf[4]); + tcg_gen_or_i32(tcg_ctx, t0, t0, tcg_ctx->cpu_crf[4]); tcg_gen_shli_i32(tcg_ctx, t0, t0, 4); - tcg_gen_or_i32(tcg_ctx, t0, t0, cpu_crf[5]); + tcg_gen_or_i32(tcg_ctx, t0, t0, tcg_ctx->cpu_crf[5]); tcg_gen_shli_i32(tcg_ctx, t0, t0, 4); - tcg_gen_or_i32(tcg_ctx, t0, t0, cpu_crf[6]); + tcg_gen_or_i32(tcg_ctx, t0, t0, tcg_ctx->cpu_crf[6]); tcg_gen_shli_i32(tcg_ctx, t0, t0, 4); - tcg_gen_or_i32(tcg_ctx, t0, t0, cpu_crf[7]); - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); + tcg_gen_or_i32(tcg_ctx, t0, t0, tcg_ctx->cpu_crf[7]); + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); tcg_temp_free_i32(tcg_ctx, t0); } } @@ -4343,7 +4337,7 @@ static void gen_mfmsr(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_msr); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_msr); } static void spr_noaccess(DisasContext *ctx, int gprn, int sprn) @@ -4432,18 +4426,18 @@ static void gen_mtcrf(DisasContext *ctx) if (crm && ((crm & (crm - 1)) == 0)) { TCGv_i32 temp = tcg_temp_new_i32(tcg_ctx); crn = ctz32(crm); - tcg_gen_trunc_tl_i32(tcg_ctx, temp, cpu_gpr[rS(ctx->opcode)]); + tcg_gen_trunc_tl_i32(tcg_ctx, temp, tcg_ctx->cpu_gpr[rS(ctx->opcode)]); tcg_gen_shri_i32(tcg_ctx, temp, temp, crn * 4); - tcg_gen_andi_i32(tcg_ctx, cpu_crf[7 - crn], temp, 0xf); + tcg_gen_andi_i32(tcg_ctx, tcg_ctx->cpu_crf[7 - crn], temp, 0xf); tcg_temp_free_i32(tcg_ctx, temp); } } else { TCGv_i32 temp = tcg_temp_new_i32(tcg_ctx); - tcg_gen_trunc_tl_i32(tcg_ctx, temp, cpu_gpr[rS(ctx->opcode)]); + tcg_gen_trunc_tl_i32(tcg_ctx, temp, tcg_ctx->cpu_gpr[rS(ctx->opcode)]); for (crn = 0 ; crn < 8 ; crn++) { if (crm & (1 << crn)) { - tcg_gen_shri_i32(tcg_ctx, cpu_crf[7 - crn], temp, crn * 4); - tcg_gen_andi_i32(tcg_ctx, cpu_crf[7 - crn], cpu_crf[7 - crn], 0xf); + tcg_gen_shri_i32(tcg_ctx, tcg_ctx->cpu_crf[7 - crn], temp, crn * 4); + tcg_gen_andi_i32(tcg_ctx, tcg_ctx->cpu_crf[7 - crn], tcg_ctx->cpu_crf[7 - crn], 0xf); } } tcg_temp_free_i32(tcg_ctx, temp); @@ -4464,9 +4458,9 @@ static void gen_mtmsrd(DisasContext *ctx) /* L=1 form only updates EE and RI */ TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], (1 << MSR_RI) | (1 << MSR_EE)); - tcg_gen_andi_tl(tcg_ctx, t1, cpu_msr, + tcg_gen_andi_tl(tcg_ctx, t1, tcg_ctx->cpu_msr, ~(target_ulong)((1 << MSR_RI) | (1 << MSR_EE))); tcg_gen_or_tl(tcg_ctx, t1, t1, t0); @@ -4481,7 +4475,7 @@ static void gen_mtmsrd(DisasContext *ctx) * ppc_store_msr */ gen_update_nip(ctx, ctx->base.pc_next); - gen_helper_store_msr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rS(ctx->opcode)]); + gen_helper_store_msr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rS(ctx->opcode)]); } /* Must stop the translation as machine state (may have) changed */ gen_stop_exception(ctx); @@ -4500,9 +4494,9 @@ static void gen_mtmsr(DisasContext *ctx) /* L=1 form only updates EE and RI */ TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], (1 << MSR_RI) | (1 << MSR_EE)); - tcg_gen_andi_tl(tcg_ctx, t1, cpu_msr, + tcg_gen_andi_tl(tcg_ctx, t1, tcg_ctx->cpu_msr, ~(target_ulong)((1 << MSR_RI) | (1 << MSR_EE))); tcg_gen_or_tl(tcg_ctx, t1, t1, t0); @@ -4520,9 +4514,9 @@ static void gen_mtmsr(DisasContext *ctx) */ gen_update_nip(ctx, ctx->base.pc_next); #if defined(TARGET_PPC64) - tcg_gen_deposit_tl(tcg_ctx, msr, cpu_msr, cpu_gpr[rS(ctx->opcode)], 0, 32); + tcg_gen_deposit_tl(tcg_ctx, msr, tcg_ctx->cpu_msr, tcg_ctx->cpu_gpr[rS(ctx->opcode)], 0, 32); #else - tcg_gen_mov_tl(tcg_ctx, msr, cpu_gpr[rS(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, msr, tcg_ctx->cpu_gpr[rS(ctx->opcode)]); #endif gen_helper_store_msr(tcg_ctx, tcg_ctx->cpu_env, msr); tcg_temp_free(tcg_ctx, msr); @@ -4595,11 +4589,11 @@ static void gen_setb(DisasContext *ctx) TCGv_i32 tm1 = tcg_temp_new_i32(tcg_ctx); int crf = crfS(ctx->opcode); - tcg_gen_setcondi_i32(tcg_ctx, TCG_COND_GEU, t0, cpu_crf[crf], 4); + tcg_gen_setcondi_i32(tcg_ctx, TCG_COND_GEU, t0, tcg_ctx->cpu_crf[crf], 4); tcg_gen_movi_i32(tcg_ctx, t8, 8); tcg_gen_movi_i32(tcg_ctx, tm1, -1); - tcg_gen_movcond_i32(tcg_ctx, TCG_COND_GEU, t0, cpu_crf[crf], t8, tm1, t0); - tcg_gen_ext_i32_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); + tcg_gen_movcond_i32(tcg_ctx, TCG_COND_GEU, t0, tcg_ctx->cpu_crf[crf], t8, tm1, t0); + tcg_gen_ext_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); tcg_temp_free_i32(tcg_ctx, t0); tcg_temp_free_i32(tcg_ctx, t8); @@ -4837,7 +4831,7 @@ static void gen_mfsr(DisasContext *ctx) CHK_SV; t0 = tcg_const_tl(tcg_ctx, SR(ctx->opcode)); - gen_helper_load_sr(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); + gen_helper_load_sr(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); tcg_temp_free(tcg_ctx, t0); } @@ -4849,8 +4843,8 @@ static void gen_mfsrin(DisasContext *ctx) CHK_SV; t0 = tcg_temp_new(tcg_ctx); - tcg_gen_extract_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 28, 4); - gen_helper_load_sr(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); + tcg_gen_extract_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 28, 4); + gen_helper_load_sr(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); tcg_temp_free(tcg_ctx, t0); } @@ -4862,7 +4856,7 @@ static void gen_mtsr(DisasContext *ctx) CHK_SV; t0 = tcg_const_tl(tcg_ctx, SR(ctx->opcode)); - gen_helper_store_sr(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[rS(ctx->opcode)]); + gen_helper_store_sr(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)]); tcg_temp_free(tcg_ctx, t0); } @@ -4874,8 +4868,8 @@ static void gen_mtsrin(DisasContext *ctx) CHK_SV; t0 = tcg_temp_new(tcg_ctx); - tcg_gen_extract_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 28, 4); - gen_helper_store_sr(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[rD(ctx->opcode)]); + tcg_gen_extract_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 28, 4); + gen_helper_store_sr(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); tcg_temp_free(tcg_ctx, t0); } @@ -4890,7 +4884,7 @@ static void gen_mfsr_64b(DisasContext *ctx) CHK_SV; t0 = tcg_const_tl(tcg_ctx, SR(ctx->opcode)); - gen_helper_load_sr(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); + gen_helper_load_sr(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); tcg_temp_free(tcg_ctx, t0); } @@ -4902,8 +4896,8 @@ static void gen_mfsrin_64b(DisasContext *ctx) CHK_SV; t0 = tcg_temp_new(tcg_ctx); - tcg_gen_extract_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 28, 4); - gen_helper_load_sr(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); + tcg_gen_extract_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 28, 4); + gen_helper_load_sr(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); tcg_temp_free(tcg_ctx, t0); } @@ -4915,7 +4909,7 @@ static void gen_mtsr_64b(DisasContext *ctx) CHK_SV; t0 = tcg_const_tl(tcg_ctx, SR(ctx->opcode)); - gen_helper_store_sr(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[rS(ctx->opcode)]); + gen_helper_store_sr(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)]); tcg_temp_free(tcg_ctx, t0); } @@ -4927,8 +4921,8 @@ static void gen_mtsrin_64b(DisasContext *ctx) CHK_SV; t0 = tcg_temp_new(tcg_ctx); - tcg_gen_extract_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 28, 4); - gen_helper_store_sr(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[rS(ctx->opcode)]); + tcg_gen_extract_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 28, 4); + gen_helper_store_sr(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)]); tcg_temp_free(tcg_ctx, t0); } @@ -4938,8 +4932,8 @@ static void gen_slbmte(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_store_slb(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)], - cpu_gpr[rS(ctx->opcode)]); + gen_helper_store_slb(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)], + tcg_ctx->cpu_gpr[rS(ctx->opcode)]); } static void gen_slbmfee(DisasContext *ctx) @@ -4947,8 +4941,8 @@ static void gen_slbmfee(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_load_slb_esid(tcg_ctx, cpu_gpr[rS(ctx->opcode)], tcg_ctx->cpu_env, - cpu_gpr[rB(ctx->opcode)]); + gen_helper_load_slb_esid(tcg_ctx, tcg_ctx->cpu_gpr[rS(ctx->opcode)], tcg_ctx->cpu_env, + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } static void gen_slbmfev(DisasContext *ctx) @@ -4956,8 +4950,8 @@ static void gen_slbmfev(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_load_slb_vsid(tcg_ctx, cpu_gpr[rS(ctx->opcode)], tcg_ctx->cpu_env, - cpu_gpr[rB(ctx->opcode)]); + gen_helper_load_slb_vsid(tcg_ctx, tcg_ctx->cpu_gpr[rS(ctx->opcode)], tcg_ctx->cpu_env, + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } static void gen_slbfee_(DisasContext *ctx) @@ -4969,16 +4963,16 @@ static void gen_slbfee_(DisasContext *ctx) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); return; } - gen_helper_find_slb_vsid(tcg_ctx, cpu_gpr[rS(ctx->opcode)], tcg_ctx->cpu_env, - cpu_gpr[rB(ctx->opcode)]); + gen_helper_find_slb_vsid(tcg_ctx, tcg_ctx->cpu_gpr[rS(ctx->opcode)], tcg_ctx->cpu_env, + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); l1 = gen_new_label(tcg_ctx); l2 = gen_new_label(tcg_ctx); - tcg_gen_trunc_tl_i32(tcg_ctx, cpu_crf[0], cpu_so); - tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_EQ, cpu_gpr[rS(ctx->opcode)], -1, l1); - tcg_gen_ori_i32(tcg_ctx, cpu_crf[0], cpu_crf[0], CRF_EQ); + tcg_gen_trunc_tl_i32(tcg_ctx, tcg_ctx->cpu_crf[0], tcg_ctx->cpu_so); + tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_EQ, tcg_ctx->cpu_gpr[rS(ctx->opcode)], -1, l1); + tcg_gen_ori_i32(tcg_ctx, tcg_ctx->cpu_crf[0], tcg_ctx->cpu_crf[0], CRF_EQ); tcg_gen_br(tcg_ctx, l2); gen_set_label(tcg_ctx, l1); - tcg_gen_movi_tl(tcg_ctx, cpu_gpr[rS(ctx->opcode)], 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rS(ctx->opcode)], 0); gen_set_label(tcg_ctx, l2); } #endif /* defined(TARGET_PPC64) */ @@ -5001,7 +4995,7 @@ static void gen_tlbiel(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_tlbie(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_tlbie(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } /* tlbie */ @@ -5018,11 +5012,11 @@ static void gen_tlbie(DisasContext *ctx) if (NARROW_MODE(ctx)) { TCGv t0 = tcg_temp_new(tcg_ctx); - tcg_gen_ext32u_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)]); + tcg_gen_ext32u_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); gen_helper_tlbie(tcg_ctx, tcg_ctx->cpu_env, t0); tcg_temp_free(tcg_ctx, t0); } else { - gen_helper_tlbie(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_tlbie(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } t1 = tcg_temp_new_i32(tcg_ctx); tcg_gen_ld_i32(tcg_ctx, t1, tcg_ctx->cpu_env, offsetof(CPUPPCState, tlb_need_flush)); @@ -5066,7 +5060,7 @@ static void gen_slbie(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_slbie(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_slbie(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } /* slbieg */ @@ -5075,7 +5069,7 @@ static void gen_slbieg(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_slbieg(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_slbieg(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } /* slbsync */ @@ -5099,7 +5093,7 @@ static void gen_eciwx(DisasContext *ctx) gen_set_access_type(ctx, ACCESS_EXT); t0 = tcg_temp_new(tcg_ctx); gen_addr_reg_index(ctx, t0); - tcg_gen_qemu_ld_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0, ctx->mem_idx, + tcg_gen_qemu_ld_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0, ctx->mem_idx, DEF_MEMOP(MO_UL | MO_ALIGN)); tcg_temp_free(tcg_ctx, t0); } @@ -5113,7 +5107,7 @@ static void gen_ecowx(DisasContext *ctx) gen_set_access_type(ctx, ACCESS_EXT); t0 = tcg_temp_new(tcg_ctx); gen_addr_reg_index(ctx, t0); - tcg_gen_qemu_st_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0, ctx->mem_idx, + tcg_gen_qemu_st_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0, ctx->mem_idx, DEF_MEMOP(MO_UL | MO_ALIGN)); tcg_temp_free(tcg_ctx, t0); } @@ -5124,8 +5118,8 @@ static void gen_ecowx(DisasContext *ctx) static void gen_abs(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv d = cpu_gpr[rD(ctx->opcode)]; - TCGv a = cpu_gpr[rA(ctx->opcode)]; + TCGv d = tcg_ctx->cpu_gpr[rD(ctx->opcode)]; + TCGv a = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; tcg_gen_abs_tl(tcg_ctx, d, a); if (unlikely(Rc(ctx->opcode) != 0)) { @@ -5137,12 +5131,12 @@ static void gen_abs(DisasContext *ctx) static void gen_abso(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv d = cpu_gpr[rD(ctx->opcode)]; - TCGv a = cpu_gpr[rA(ctx->opcode)]; + TCGv d = tcg_ctx->cpu_gpr[rD(ctx->opcode)]; + TCGv a = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; - tcg_gen_setcondi_tl(tcg_ctx, TCG_COND_EQ, cpu_ov, a, 0x80000000); + tcg_gen_setcondi_tl(tcg_ctx, TCG_COND_EQ, tcg_ctx->cpu_ov, a, 0x80000000); tcg_gen_abs_tl(tcg_ctx, d, a); - tcg_gen_or_tl(tcg_ctx, cpu_so, cpu_so, cpu_ov); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_so, tcg_ctx->cpu_so, tcg_ctx->cpu_ov); if (unlikely(Rc(ctx->opcode) != 0)) { gen_set_Rc0(ctx, d); } @@ -5153,7 +5147,7 @@ static void gen_clcs(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, rA(ctx->opcode)); - gen_helper_clcs(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); + gen_helper_clcs(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); tcg_temp_free_i32(tcg_ctx, t0); /* Rc=1 sets CR0 to an undefined state */ } @@ -5162,10 +5156,10 @@ static void gen_clcs(DisasContext *ctx) static void gen_div(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_div(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rB(ctx->opcode)]); + gen_helper_div(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -5173,10 +5167,10 @@ static void gen_div(DisasContext *ctx) static void gen_divo(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_divo(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rB(ctx->opcode)]); + gen_helper_divo(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -5184,10 +5178,10 @@ static void gen_divo(DisasContext *ctx) static void gen_divs(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_divs(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rB(ctx->opcode)]); + gen_helper_divs(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -5195,10 +5189,10 @@ static void gen_divs(DisasContext *ctx) static void gen_divso(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_divso(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, - cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); + gen_helper_divso(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, + tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -5208,16 +5202,16 @@ static void gen_doz(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGLabel *l1 = gen_new_label(tcg_ctx); TCGLabel *l2 = gen_new_label(tcg_ctx); - tcg_gen_brcond_tl(tcg_ctx, TCG_COND_GE, cpu_gpr[rB(ctx->opcode)], - cpu_gpr[rA(ctx->opcode)], l1); - tcg_gen_sub_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], - cpu_gpr[rA(ctx->opcode)]); + tcg_gen_brcond_tl(tcg_ctx, TCG_COND_GE, tcg_ctx->cpu_gpr[rB(ctx->opcode)], + tcg_ctx->cpu_gpr[rA(ctx->opcode)], l1); + tcg_gen_sub_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)], + tcg_ctx->cpu_gpr[rA(ctx->opcode)]); tcg_gen_br(tcg_ctx, l2); gen_set_label(tcg_ctx, l1); - tcg_gen_movi_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], 0); gen_set_label(tcg_ctx, l2); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -5231,26 +5225,26 @@ static void gen_dozo(DisasContext *ctx) TCGv t1 = tcg_temp_new(tcg_ctx); TCGv t2 = tcg_temp_new(tcg_ctx); /* Start with XER OV disabled, the most likely case */ - tcg_gen_movi_tl(tcg_ctx, cpu_ov, 0); - tcg_gen_brcond_tl(tcg_ctx, TCG_COND_GE, cpu_gpr[rB(ctx->opcode)], - cpu_gpr[rA(ctx->opcode)], l1); - tcg_gen_sub_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - tcg_gen_xor_tl(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - tcg_gen_xor_tl(tcg_ctx, t2, cpu_gpr[rA(ctx->opcode)], t0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ov, 0); + tcg_gen_brcond_tl(tcg_ctx, TCG_COND_GE, tcg_ctx->cpu_gpr[rB(ctx->opcode)], + tcg_ctx->cpu_gpr[rA(ctx->opcode)], l1); + tcg_gen_sub_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_xor_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_xor_tl(tcg_ctx, t2, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0); tcg_gen_andc_tl(tcg_ctx, t1, t1, t2); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_GE, t1, 0, l2); - tcg_gen_movi_tl(tcg_ctx, cpu_ov, 1); - tcg_gen_movi_tl(tcg_ctx, cpu_so, 1); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ov, 1); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_so, 1); tcg_gen_br(tcg_ctx, l2); gen_set_label(tcg_ctx, l1); - tcg_gen_movi_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], 0); gen_set_label(tcg_ctx, l2); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); tcg_temp_free(tcg_ctx, t2); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -5261,14 +5255,14 @@ static void gen_dozi(DisasContext *ctx) target_long simm = SIMM(ctx->opcode); TCGLabel *l1 = gen_new_label(tcg_ctx); TCGLabel *l2 = gen_new_label(tcg_ctx); - tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_LT, cpu_gpr[rA(ctx->opcode)], simm, l1); - tcg_gen_subfi_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], simm, cpu_gpr[rA(ctx->opcode)]); + tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_LT, tcg_ctx->cpu_gpr[rA(ctx->opcode)], simm, l1); + tcg_gen_subfi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], simm, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); tcg_gen_br(tcg_ctx, l2); gen_set_label(tcg_ctx, l1); - tcg_gen_movi_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], 0); gen_set_label(tcg_ctx, l2); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -5286,8 +5280,8 @@ static void gen_lscbx(DisasContext *ctx) tcg_temp_free_i32(tcg_ctx, t1); tcg_temp_free_i32(tcg_ctx, t2); tcg_temp_free_i32(tcg_ctx, t3); - tcg_gen_andi_tl(tcg_ctx, cpu_xer, cpu_xer, ~0x7F); - tcg_gen_or_tl(tcg_ctx, cpu_xer, cpu_xer, t0); + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_xer, tcg_ctx->cpu_xer, ~0x7F); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_xer, tcg_ctx->cpu_xer, t0); if (unlikely(Rc(ctx->opcode) != 0)) { gen_set_Rc0(ctx, t0); } @@ -5304,21 +5298,21 @@ static void gen_maskg(DisasContext *ctx) TCGv t2 = tcg_temp_new(tcg_ctx); TCGv t3 = tcg_temp_new(tcg_ctx); tcg_gen_movi_tl(tcg_ctx, t3, 0xFFFFFFFF); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 0x1F); - tcg_gen_andi_tl(tcg_ctx, t1, cpu_gpr[rS(ctx->opcode)], 0x1F); + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1F); + tcg_gen_andi_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rS(ctx->opcode)], 0x1F); tcg_gen_addi_tl(tcg_ctx, t2, t0, 1); tcg_gen_shr_tl(tcg_ctx, t2, t3, t2); tcg_gen_shr_tl(tcg_ctx, t3, t3, t1); - tcg_gen_xor_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t2, t3); + tcg_gen_xor_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t2, t3); tcg_gen_brcond_tl(tcg_ctx, TCG_COND_GE, t0, t1, l1); - tcg_gen_neg_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); + tcg_gen_neg_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)]); gen_set_label(tcg_ctx, l1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); tcg_temp_free(tcg_ctx, t2); tcg_temp_free(tcg_ctx, t3); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5328,13 +5322,13 @@ static void gen_maskir(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - tcg_gen_and_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); - tcg_gen_andc_tl(tcg_ctx, t1, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); - tcg_gen_or_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0, t1); + tcg_gen_and_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); + tcg_gen_andc_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5345,18 +5339,18 @@ static void gen_mul(DisasContext *ctx) TCGv_i64 t0 = tcg_temp_new_i64(tcg_ctx); TCGv_i64 t1 = tcg_temp_new_i64(tcg_ctx); TCGv t2 = tcg_temp_new(tcg_ctx); - tcg_gen_extu_tl_i64(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); - tcg_gen_extu_tl_i64(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)]); + tcg_gen_extu_tl_i64(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_extu_tl_i64(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); tcg_gen_mul_i64(tcg_ctx, t0, t0, t1); tcg_gen_trunc_i64_tl(tcg_ctx, t2, t0); gen_store_spr(tcg_ctx, SPR_MQ, t2); tcg_gen_shri_i64(tcg_ctx, t1, t0, 32); - tcg_gen_trunc_i64_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t1); + tcg_gen_trunc_i64_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t1); tcg_temp_free_i64(tcg_ctx, t0); tcg_temp_free_i64(tcg_ctx, t1); tcg_temp_free(tcg_ctx, t2); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -5369,24 +5363,24 @@ static void gen_mulo(DisasContext *ctx) TCGv_i64 t1 = tcg_temp_new_i64(tcg_ctx); TCGv t2 = tcg_temp_new(tcg_ctx); /* Start with XER OV disabled, the most likely case */ - tcg_gen_movi_tl(tcg_ctx, cpu_ov, 0); - tcg_gen_extu_tl_i64(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); - tcg_gen_extu_tl_i64(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)]); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ov, 0); + tcg_gen_extu_tl_i64(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_extu_tl_i64(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); tcg_gen_mul_i64(tcg_ctx, t0, t0, t1); tcg_gen_trunc_i64_tl(tcg_ctx, t2, t0); gen_store_spr(tcg_ctx, SPR_MQ, t2); tcg_gen_shri_i64(tcg_ctx, t1, t0, 32); - tcg_gen_trunc_i64_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t1); + tcg_gen_trunc_i64_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t1); tcg_gen_ext32s_i64(tcg_ctx, t1, t0); tcg_gen_brcond_i64(tcg_ctx, TCG_COND_EQ, t0, t1, l1); - tcg_gen_movi_tl(tcg_ctx, cpu_ov, 1); - tcg_gen_movi_tl(tcg_ctx, cpu_so, 1); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ov, 1); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_so, 1); gen_set_label(tcg_ctx, l1); tcg_temp_free_i64(tcg_ctx, t0); tcg_temp_free_i64(tcg_ctx, t1); tcg_temp_free(tcg_ctx, t2); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } } @@ -5394,8 +5388,8 @@ static void gen_mulo(DisasContext *ctx) static void gen_nabs(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv d = cpu_gpr[rD(ctx->opcode)]; - TCGv a = cpu_gpr[rA(ctx->opcode)]; + TCGv d = tcg_ctx->cpu_gpr[rD(ctx->opcode)]; + TCGv a = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; tcg_gen_abs_tl(tcg_ctx, d, a); tcg_gen_neg_tl(tcg_ctx, d, d); @@ -5408,13 +5402,13 @@ static void gen_nabs(DisasContext *ctx) static void gen_nabso(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv d = cpu_gpr[rD(ctx->opcode)]; - TCGv a = cpu_gpr[rA(ctx->opcode)]; + TCGv d = tcg_ctx->cpu_gpr[rD(ctx->opcode)]; + TCGv a = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; tcg_gen_abs_tl(tcg_ctx, d, a); tcg_gen_neg_tl(tcg_ctx, d, d); /* nabs never overflows */ - tcg_gen_movi_tl(tcg_ctx, cpu_ov, 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ov, 0); if (unlikely(Rc(ctx->opcode) != 0)) { gen_set_Rc0(ctx, d); } @@ -5427,15 +5421,15 @@ static void gen_rlmi(DisasContext *ctx) uint32_t mb = MB(ctx->opcode); uint32_t me = ME(ctx->opcode); TCGv t0 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 0x1F); - tcg_gen_rotl_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t0); + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1F); + tcg_gen_rotl_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t0); tcg_gen_andi_tl(tcg_ctx, t0, t0, MASK(mb, me)); - tcg_gen_andi_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], ~MASK(mb, me)); - tcg_gen_or_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], t0); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0); tcg_temp_free(tcg_ctx, t0); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5445,17 +5439,17 @@ static void gen_rrib(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 0x1F); + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1F); tcg_gen_movi_tl(tcg_ctx, t1, 0x80000000); tcg_gen_shr_tl(tcg_ctx, t1, t1, t0); - tcg_gen_shr_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t0); + tcg_gen_shr_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t0); tcg_gen_and_tl(tcg_ctx, t0, t0, t1); - tcg_gen_andc_tl(tcg_ctx, t1, cpu_gpr[rA(ctx->opcode)], t1); - tcg_gen_or_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0, t1); + tcg_gen_andc_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t1); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5465,17 +5459,17 @@ static void gen_sle(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)], 0x1F); - tcg_gen_shl_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t1); + tcg_gen_andi_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1F); + tcg_gen_shl_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t1); tcg_gen_subfi_tl(tcg_ctx, t1, 32, t1); - tcg_gen_shr_tl(tcg_ctx, t1, cpu_gpr[rS(ctx->opcode)], t1); + tcg_gen_shr_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t1); tcg_gen_or_tl(tcg_ctx, t1, t0, t1); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0); gen_store_spr(tcg_ctx, SPR_MQ, t1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5486,20 +5480,20 @@ static void gen_sleq(DisasContext *ctx) TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); TCGv t2 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 0x1F); + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1F); tcg_gen_movi_tl(tcg_ctx, t2, 0xFFFFFFFF); tcg_gen_shl_tl(tcg_ctx, t2, t2, t0); - tcg_gen_rotl_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t0); + tcg_gen_rotl_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t0); gen_load_spr(tcg_ctx, t1, SPR_MQ); gen_store_spr(tcg_ctx, SPR_MQ, t0); tcg_gen_and_tl(tcg_ctx, t0, t0, t2); tcg_gen_andc_tl(tcg_ctx, t1, t1, t2); - tcg_gen_or_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0, t1); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); tcg_temp_free(tcg_ctx, t2); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5510,15 +5504,15 @@ static void gen_sliq(DisasContext *ctx) int sh = SH(ctx->opcode); TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - tcg_gen_shli_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], sh); - tcg_gen_shri_tl(tcg_ctx, t1, cpu_gpr[rS(ctx->opcode)], 32 - sh); + tcg_gen_shli_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], sh); + tcg_gen_shri_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rS(ctx->opcode)], 32 - sh); tcg_gen_or_tl(tcg_ctx, t1, t0, t1); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0); gen_store_spr(tcg_ctx, SPR_MQ, t1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5529,16 +5523,16 @@ static void gen_slliq(DisasContext *ctx) int sh = SH(ctx->opcode); TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - tcg_gen_rotli_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], sh); + tcg_gen_rotli_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], sh); gen_load_spr(tcg_ctx, t1, SPR_MQ); gen_store_spr(tcg_ctx, SPR_MQ, t0); tcg_gen_andi_tl(tcg_ctx, t0, t0, (0xFFFFFFFFU << sh)); tcg_gen_andi_tl(tcg_ctx, t1, t1, ~(0xFFFFFFFFU << sh)); - tcg_gen_or_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0, t1); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5551,25 +5545,25 @@ static void gen_sllq(DisasContext *ctx) TCGv t0 = tcg_temp_local_new(tcg_ctx); TCGv t1 = tcg_temp_local_new(tcg_ctx); TCGv t2 = tcg_temp_local_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t2, cpu_gpr[rB(ctx->opcode)], 0x1F); + tcg_gen_andi_tl(tcg_ctx, t2, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1F); tcg_gen_movi_tl(tcg_ctx, t1, 0xFFFFFFFF); tcg_gen_shl_tl(tcg_ctx, t1, t1, t2); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 0x20); + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x20); tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_EQ, t0, 0, l1); gen_load_spr(tcg_ctx, t0, SPR_MQ); - tcg_gen_and_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0, t1); + tcg_gen_and_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t1); tcg_gen_br(tcg_ctx, l2); gen_set_label(tcg_ctx, l1); - tcg_gen_shl_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t2); + tcg_gen_shl_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t2); gen_load_spr(tcg_ctx, t2, SPR_MQ); tcg_gen_andc_tl(tcg_ctx, t1, t2, t1); - tcg_gen_or_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0, t1); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t1); gen_set_label(tcg_ctx, l2); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); tcg_temp_free(tcg_ctx, t2); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5580,21 +5574,21 @@ static void gen_slq(DisasContext *ctx) TCGLabel *l1 = gen_new_label(tcg_ctx); TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)], 0x1F); - tcg_gen_shl_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t1); + tcg_gen_andi_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1F); + tcg_gen_shl_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t1); tcg_gen_subfi_tl(tcg_ctx, t1, 32, t1); - tcg_gen_shr_tl(tcg_ctx, t1, cpu_gpr[rS(ctx->opcode)], t1); + tcg_gen_shr_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t1); tcg_gen_or_tl(tcg_ctx, t1, t0, t1); gen_store_spr(tcg_ctx, SPR_MQ, t1); - tcg_gen_andi_tl(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)], 0x20); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0); + tcg_gen_andi_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x20); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0); tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_EQ, t1, 0, l1); - tcg_gen_movi_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], 0); gen_set_label(tcg_ctx, l1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5606,20 +5600,20 @@ static void gen_sraiq(DisasContext *ctx) TCGLabel *l1 = gen_new_label(tcg_ctx); TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - tcg_gen_shri_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], sh); - tcg_gen_shli_tl(tcg_ctx, t1, cpu_gpr[rS(ctx->opcode)], 32 - sh); + tcg_gen_shri_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], sh); + tcg_gen_shli_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rS(ctx->opcode)], 32 - sh); tcg_gen_or_tl(tcg_ctx, t0, t0, t1); gen_store_spr(tcg_ctx, SPR_MQ, t0); - tcg_gen_movi_tl(tcg_ctx, cpu_ca, 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ca, 0); tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_EQ, t1, 0, l1); - tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_GE, cpu_gpr[rS(ctx->opcode)], 0, l1); - tcg_gen_movi_tl(tcg_ctx, cpu_ca, 1); + tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_GE, tcg_ctx->cpu_gpr[rS(ctx->opcode)], 0, l1); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ca, 1); gen_set_label(tcg_ctx, l1); - tcg_gen_sari_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], sh); + tcg_gen_sari_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)], sh); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5632,29 +5626,29 @@ static void gen_sraq(DisasContext *ctx) TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_local_new(tcg_ctx); TCGv t2 = tcg_temp_local_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t2, cpu_gpr[rB(ctx->opcode)], 0x1F); - tcg_gen_shr_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t2); - tcg_gen_sar_tl(tcg_ctx, t1, cpu_gpr[rS(ctx->opcode)], t2); + tcg_gen_andi_tl(tcg_ctx, t2, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1F); + tcg_gen_shr_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t2); + tcg_gen_sar_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t2); tcg_gen_subfi_tl(tcg_ctx, t2, 32, t2); - tcg_gen_shl_tl(tcg_ctx, t2, cpu_gpr[rS(ctx->opcode)], t2); + tcg_gen_shl_tl(tcg_ctx, t2, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t2); tcg_gen_or_tl(tcg_ctx, t0, t0, t2); gen_store_spr(tcg_ctx, SPR_MQ, t0); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 0x20); + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x20); tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_EQ, t2, 0, l1); - tcg_gen_mov_tl(tcg_ctx, t2, cpu_gpr[rS(ctx->opcode)]); - tcg_gen_sari_tl(tcg_ctx, t1, cpu_gpr[rS(ctx->opcode)], 31); + tcg_gen_mov_tl(tcg_ctx, t2, tcg_ctx->cpu_gpr[rS(ctx->opcode)]); + tcg_gen_sari_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rS(ctx->opcode)], 31); gen_set_label(tcg_ctx, l1); tcg_temp_free(tcg_ctx, t0); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t1); - tcg_gen_movi_tl(tcg_ctx, cpu_ca, 0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t1); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ca, 0); tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_GE, t1, 0, l2); tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_EQ, t2, 0, l2); - tcg_gen_movi_tl(tcg_ctx, cpu_ca, 1); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ca, 1); gen_set_label(tcg_ctx, l2); tcg_temp_free(tcg_ctx, t1); tcg_temp_free(tcg_ctx, t2); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5664,17 +5658,17 @@ static void gen_sre(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)], 0x1F); - tcg_gen_shr_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t1); + tcg_gen_andi_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1F); + tcg_gen_shr_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t1); tcg_gen_subfi_tl(tcg_ctx, t1, 32, t1); - tcg_gen_shl_tl(tcg_ctx, t1, cpu_gpr[rS(ctx->opcode)], t1); + tcg_gen_shl_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t1); tcg_gen_or_tl(tcg_ctx, t1, t0, t1); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0); gen_store_spr(tcg_ctx, SPR_MQ, t1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5684,14 +5678,14 @@ static void gen_srea(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)], 0x1F); - tcg_gen_rotr_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t1); + tcg_gen_andi_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1F); + tcg_gen_rotr_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t1); gen_store_spr(tcg_ctx, SPR_MQ, t0); - tcg_gen_sar_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], t1); + tcg_gen_sar_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rS(ctx->opcode)], t1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5702,20 +5696,20 @@ static void gen_sreq(DisasContext *ctx) TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); TCGv t2 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 0x1F); + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1F); tcg_gen_movi_tl(tcg_ctx, t1, 0xFFFFFFFF); tcg_gen_shr_tl(tcg_ctx, t1, t1, t0); - tcg_gen_rotr_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t0); + tcg_gen_rotr_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t0); gen_load_spr(tcg_ctx, t2, SPR_MQ); gen_store_spr(tcg_ctx, SPR_MQ, t0); tcg_gen_and_tl(tcg_ctx, t0, t0, t1); tcg_gen_andc_tl(tcg_ctx, t2, t2, t1); - tcg_gen_or_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0, t2); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t2); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); tcg_temp_free(tcg_ctx, t2); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5726,15 +5720,15 @@ static void gen_sriq(DisasContext *ctx) int sh = SH(ctx->opcode); TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - tcg_gen_shri_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], sh); - tcg_gen_shli_tl(tcg_ctx, t1, cpu_gpr[rS(ctx->opcode)], 32 - sh); + tcg_gen_shri_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], sh); + tcg_gen_shli_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rS(ctx->opcode)], 32 - sh); tcg_gen_or_tl(tcg_ctx, t1, t0, t1); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0); gen_store_spr(tcg_ctx, SPR_MQ, t1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5745,16 +5739,16 @@ static void gen_srliq(DisasContext *ctx) int sh = SH(ctx->opcode); TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - tcg_gen_rotri_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], sh); + tcg_gen_rotri_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], sh); gen_load_spr(tcg_ctx, t1, SPR_MQ); gen_store_spr(tcg_ctx, SPR_MQ, t0); tcg_gen_andi_tl(tcg_ctx, t0, t0, (0xFFFFFFFFU >> sh)); tcg_gen_andi_tl(tcg_ctx, t1, t1, ~(0xFFFFFFFFU >> sh)); - tcg_gen_or_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0, t1); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5767,26 +5761,26 @@ static void gen_srlq(DisasContext *ctx) TCGv t0 = tcg_temp_local_new(tcg_ctx); TCGv t1 = tcg_temp_local_new(tcg_ctx); TCGv t2 = tcg_temp_local_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t2, cpu_gpr[rB(ctx->opcode)], 0x1F); + tcg_gen_andi_tl(tcg_ctx, t2, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1F); tcg_gen_movi_tl(tcg_ctx, t1, 0xFFFFFFFF); tcg_gen_shr_tl(tcg_ctx, t2, t1, t2); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)], 0x20); + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x20); tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_EQ, t0, 0, l1); gen_load_spr(tcg_ctx, t0, SPR_MQ); - tcg_gen_and_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0, t2); + tcg_gen_and_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t2); tcg_gen_br(tcg_ctx, l2); gen_set_label(tcg_ctx, l1); - tcg_gen_shr_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t2); + tcg_gen_shr_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t2); tcg_gen_and_tl(tcg_ctx, t0, t0, t2); gen_load_spr(tcg_ctx, t1, SPR_MQ); tcg_gen_andc_tl(tcg_ctx, t1, t1, t2); - tcg_gen_or_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0, t1); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0, t1); gen_set_label(tcg_ctx, l2); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); tcg_temp_free(tcg_ctx, t2); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5797,21 +5791,21 @@ static void gen_srq(DisasContext *ctx) TCGLabel *l1 = gen_new_label(tcg_ctx); TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)], 0x1F); - tcg_gen_shr_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], t1); + tcg_gen_andi_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x1F); + tcg_gen_shr_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t1); tcg_gen_subfi_tl(tcg_ctx, t1, 32, t1); - tcg_gen_shl_tl(tcg_ctx, t1, cpu_gpr[rS(ctx->opcode)], t1); + tcg_gen_shl_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rS(ctx->opcode)], t1); tcg_gen_or_tl(tcg_ctx, t1, t0, t1); gen_store_spr(tcg_ctx, SPR_MQ, t1); - tcg_gen_andi_tl(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)], 0x20); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0); + tcg_gen_andi_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)], 0x20); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0); tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_EQ, t0, 0, l1); - tcg_gen_movi_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], 0); gen_set_label(tcg_ctx, l1); tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -5836,7 +5830,7 @@ static void gen_mfrom(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_602_mfrom(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); + gen_helper_602_mfrom(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } /* 602 - 603 - G2 TLB management */ @@ -5846,7 +5840,7 @@ static void gen_tlbld_6xx(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_6xx_tlbd(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_6xx_tlbd(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } /* tlbli */ @@ -5854,7 +5848,7 @@ static void gen_tlbli_6xx(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_6xx_tlbi(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_6xx_tlbi(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } /* 74xx TLB management */ @@ -5864,7 +5858,7 @@ static void gen_tlbld_74xx(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_74xx_tlbd(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_74xx_tlbd(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } /* tlbli */ @@ -5872,7 +5866,7 @@ static void gen_tlbli_74xx(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_74xx_tlbi(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_74xx_tlbi(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } /* POWER instructions not in PowerPC 601 */ @@ -5907,10 +5901,10 @@ static void gen_mfsri(DisasContext *ctx) t0 = tcg_temp_new(tcg_ctx); gen_addr_reg_index(ctx, t0); tcg_gen_extract_tl(tcg_ctx, t0, t0, 28, 4); - gen_helper_load_sr(tcg_ctx, cpu_gpr[rd], tcg_ctx->cpu_env, t0); + gen_helper_load_sr(tcg_ctx, tcg_ctx->cpu_gpr[rd], tcg_ctx->cpu_env, t0); tcg_temp_free(tcg_ctx, t0); if (ra != 0 && ra != rd) { - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[ra], cpu_gpr[rd]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[ra], tcg_ctx->cpu_gpr[rd]); } } @@ -5922,7 +5916,7 @@ static void gen_rac(DisasContext *ctx) CHK_SV; t0 = tcg_temp_new(tcg_ctx); gen_addr_reg_index(ctx, t0); - gen_helper_rac(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); + gen_helper_rac(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); tcg_temp_free(tcg_ctx, t0); } @@ -5955,7 +5949,7 @@ static void gen_tlbiva(DisasContext *ctx) CHK_SV; t0 = tcg_temp_new(tcg_ctx); gen_addr_reg_index(ctx, t0); - gen_helper_tlbiva(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_tlbiva(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); tcg_temp_free(tcg_ctx, t0); } @@ -5976,16 +5970,16 @@ static inline void gen_405_mulladd_insn(DisasContext *ctx, int opc2, int opc3, /* nmacchw - nmacchw. - nmacchwo - nmacchwo. */ /* nmacchws - nmacchws. - nmacchwso - nmacchwso. */ /* mulchw - mulchw. */ - tcg_gen_ext16s_tl(tcg_ctx, t0, cpu_gpr[ra]); - tcg_gen_sari_tl(tcg_ctx, t1, cpu_gpr[rb], 16); + tcg_gen_ext16s_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[ra]); + tcg_gen_sari_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rb], 16); tcg_gen_ext16s_tl(tcg_ctx, t1, t1); break; case 0x04: /* macchwu - macchwu. - macchwuo - macchwuo. */ /* macchwsu - macchwsu. - macchwsuo - macchwsuo. */ /* mulchwu - mulchwu. */ - tcg_gen_ext16u_tl(tcg_ctx, t0, cpu_gpr[ra]); - tcg_gen_shri_tl(tcg_ctx, t1, cpu_gpr[rb], 16); + tcg_gen_ext16u_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[ra]); + tcg_gen_shri_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rb], 16); tcg_gen_ext16u_tl(tcg_ctx, t1, t1); break; case 0x01: @@ -5994,18 +5988,18 @@ static inline void gen_405_mulladd_insn(DisasContext *ctx, int opc2, int opc3, /* nmachhw - nmachhw. - nmachhwo - nmachhwo. */ /* nmachhws - nmachhws. - nmachhwso - nmachhwso. */ /* mulhhw - mulhhw. */ - tcg_gen_sari_tl(tcg_ctx, t0, cpu_gpr[ra], 16); + tcg_gen_sari_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[ra], 16); tcg_gen_ext16s_tl(tcg_ctx, t0, t0); - tcg_gen_sari_tl(tcg_ctx, t1, cpu_gpr[rb], 16); + tcg_gen_sari_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rb], 16); tcg_gen_ext16s_tl(tcg_ctx, t1, t1); break; case 0x00: /* machhwu - machhwu. - machhwuo - machhwuo. */ /* machhwsu - machhwsu. - machhwsuo - machhwsuo. */ /* mulhhwu - mulhhwu. */ - tcg_gen_shri_tl(tcg_ctx, t0, cpu_gpr[ra], 16); + tcg_gen_shri_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[ra], 16); tcg_gen_ext16u_tl(tcg_ctx, t0, t0); - tcg_gen_shri_tl(tcg_ctx, t1, cpu_gpr[rb], 16); + tcg_gen_shri_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rb], 16); tcg_gen_ext16u_tl(tcg_ctx, t1, t1); break; case 0x0D: @@ -6014,15 +6008,15 @@ static inline void gen_405_mulladd_insn(DisasContext *ctx, int opc2, int opc3, /* nmaclhw - nmaclhw. - nmaclhwo - nmaclhwo. */ /* nmaclhws - nmaclhws. - nmaclhwso - nmaclhwso. */ /* mullhw - mullhw. */ - tcg_gen_ext16s_tl(tcg_ctx, t0, cpu_gpr[ra]); - tcg_gen_ext16s_tl(tcg_ctx, t1, cpu_gpr[rb]); + tcg_gen_ext16s_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[ra]); + tcg_gen_ext16s_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rb]); break; case 0x0C: /* maclhwu - maclhwu. - maclhwuo - maclhwuo. */ /* maclhwsu - maclhwsu. - maclhwsuo - maclhwsuo. */ /* mullhwu - mullhwu. */ - tcg_gen_ext16u_tl(tcg_ctx, t0, cpu_gpr[ra]); - tcg_gen_ext16u_tl(tcg_ctx, t1, cpu_gpr[rb]); + tcg_gen_ext16u_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[ra]); + tcg_gen_ext16u_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rb]); break; } if (opc2 & 0x04) { @@ -6030,10 +6024,10 @@ static inline void gen_405_mulladd_insn(DisasContext *ctx, int opc2, int opc3, tcg_gen_mul_tl(tcg_ctx, t1, t0, t1); if (opc2 & 0x02) { /* nmultiply-and-accumulate (0x0E) */ - tcg_gen_sub_tl(tcg_ctx, t0, cpu_gpr[rt], t1); + tcg_gen_sub_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rt], t1); } else { /* multiply-and-accumulate (0x0C) */ - tcg_gen_add_tl(tcg_ctx, t0, cpu_gpr[rt], t1); + tcg_gen_add_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rt], t1); } if (opc3 & 0x12) { @@ -6042,17 +6036,17 @@ static inline void gen_405_mulladd_insn(DisasContext *ctx, int opc2, int opc3, if (opc3 & 0x10) { /* Start with XER OV disabled, the most likely case */ - tcg_gen_movi_tl(tcg_ctx, cpu_ov, 0); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ov, 0); } if (opc3 & 0x01) { /* Signed */ - tcg_gen_xor_tl(tcg_ctx, t1, cpu_gpr[rt], t1); + tcg_gen_xor_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rt], t1); tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_GE, t1, 0, l1); - tcg_gen_xor_tl(tcg_ctx, t1, cpu_gpr[rt], t0); + tcg_gen_xor_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[rt], t0); tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_LT, t1, 0, l1); if (opc3 & 0x02) { /* Saturate */ - tcg_gen_sari_tl(tcg_ctx, t0, cpu_gpr[rt], 31); + tcg_gen_sari_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rt], 31); tcg_gen_xori_tl(tcg_ctx, t0, t0, 0x7fffffff); } } else { @@ -6065,20 +6059,20 @@ static inline void gen_405_mulladd_insn(DisasContext *ctx, int opc2, int opc3, } if (opc3 & 0x10) { /* Check overflow */ - tcg_gen_movi_tl(tcg_ctx, cpu_ov, 1); - tcg_gen_movi_tl(tcg_ctx, cpu_so, 1); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_ov, 1); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_so, 1); } gen_set_label(tcg_ctx, l1); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rt], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rt], t0); } } else { - tcg_gen_mul_tl(tcg_ctx, cpu_gpr[rt], t0, t1); + tcg_gen_mul_tl(tcg_ctx, tcg_ctx->cpu_gpr[rt], t0, t1); } tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); if (unlikely(Rc) != 0) { /* Update Rc0 */ - gen_set_Rc0(ctx, cpu_gpr[rt]); + gen_set_Rc0(ctx, tcg_ctx->cpu_gpr[rt]); } } @@ -6183,7 +6177,7 @@ static void gen_mfdcr(DisasContext *ctx) CHK_SV; dcrn = tcg_const_tl(tcg_ctx, SPR(ctx->opcode)); - gen_helper_load_dcr(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, dcrn); + gen_helper_load_dcr(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, dcrn); tcg_temp_free(tcg_ctx, dcrn); } @@ -6195,7 +6189,7 @@ static void gen_mtdcr(DisasContext *ctx) CHK_SV; dcrn = tcg_const_tl(tcg_ctx, SPR(ctx->opcode)); - gen_helper_store_dcr(tcg_ctx, tcg_ctx->cpu_env, dcrn, cpu_gpr[rS(ctx->opcode)]); + gen_helper_store_dcr(tcg_ctx, tcg_ctx->cpu_env, dcrn, tcg_ctx->cpu_gpr[rS(ctx->opcode)]); tcg_temp_free(tcg_ctx, dcrn); } @@ -6205,8 +6199,8 @@ static void gen_mfdcrx(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_load_dcr(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, - cpu_gpr[rA(ctx->opcode)]); + gen_helper_load_dcr(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, + tcg_ctx->cpu_gpr[rA(ctx->opcode)]); /* Note: Rc update flag set leads to undefined state of Rc0 */ } @@ -6216,8 +6210,8 @@ static void gen_mtdcrx(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_store_dcr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rS(ctx->opcode)]); + gen_helper_store_dcr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rS(ctx->opcode)]); /* Note: Rc update flag set leads to undefined state of Rc0 */ } @@ -6225,8 +6219,8 @@ static void gen_mtdcrx(DisasContext *ctx) static void gen_mfdcrux(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_load_dcr(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, - cpu_gpr[rA(ctx->opcode)]); + gen_helper_load_dcr(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, + tcg_ctx->cpu_gpr[rA(ctx->opcode)]); /* Note: Rc update flag set leads to undefined state of Rc0 */ } @@ -6234,8 +6228,8 @@ static void gen_mfdcrux(DisasContext *ctx) static void gen_mtdcrux(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_dcr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rS(ctx->opcode)]); + gen_helper_store_dcr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rS(ctx->opcode)]); /* Note: Rc update flag set leads to undefined state of Rc0 */ } @@ -6259,7 +6253,7 @@ static void gen_dcread(DisasContext *ctx) val = tcg_temp_new(tcg_ctx); gen_qemu_ld32u(ctx, val, EA); tcg_temp_free(tcg_ctx, val); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], EA); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], EA); tcg_temp_free(tcg_ctx, EA); } @@ -6337,12 +6331,12 @@ static void gen_tlbre_40x(DisasContext *ctx) CHK_SV; switch (rB(ctx->opcode)) { case 0: - gen_helper_4xx_tlbre_hi(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, - cpu_gpr[rA(ctx->opcode)]); + gen_helper_4xx_tlbre_hi(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, + tcg_ctx->cpu_gpr[rA(ctx->opcode)]); break; case 1: - gen_helper_4xx_tlbre_lo(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, - cpu_gpr[rA(ctx->opcode)]); + gen_helper_4xx_tlbre_lo(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, + tcg_ctx->cpu_gpr[rA(ctx->opcode)]); break; default: gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); @@ -6359,13 +6353,13 @@ static void gen_tlbsx_40x(DisasContext *ctx) CHK_SV; t0 = tcg_temp_new(tcg_ctx); gen_addr_reg_index(ctx, t0); - gen_helper_4xx_tlbsx(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); + gen_helper_4xx_tlbsx(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); tcg_temp_free(tcg_ctx, t0); if (Rc(ctx->opcode)) { TCGLabel *l1 = gen_new_label(tcg_ctx); - tcg_gen_trunc_tl_i32(tcg_ctx, cpu_crf[0], cpu_so); - tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_EQ, cpu_gpr[rD(ctx->opcode)], -1, l1); - tcg_gen_ori_i32(tcg_ctx, cpu_crf[0], cpu_crf[0], 0x02); + tcg_gen_trunc_tl_i32(tcg_ctx, tcg_ctx->cpu_crf[0], tcg_ctx->cpu_so); + tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_EQ, tcg_ctx->cpu_gpr[rD(ctx->opcode)], -1, l1); + tcg_gen_ori_i32(tcg_ctx, tcg_ctx->cpu_crf[0], tcg_ctx->cpu_crf[0], 0x02); gen_set_label(tcg_ctx, l1); } } @@ -6378,12 +6372,12 @@ static void gen_tlbwe_40x(DisasContext *ctx) switch (rB(ctx->opcode)) { case 0: - gen_helper_4xx_tlbwe_hi(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rS(ctx->opcode)]); + gen_helper_4xx_tlbwe_hi(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rS(ctx->opcode)]); break; case 1: - gen_helper_4xx_tlbwe_lo(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rS(ctx->opcode)]); + gen_helper_4xx_tlbwe_lo(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rS(ctx->opcode)]); break; default: gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); @@ -6405,8 +6399,8 @@ static void gen_tlbre_440(DisasContext *ctx) case 2: { TCGv_i32 t0 = tcg_const_i32(tcg_ctx, rB(ctx->opcode)); - gen_helper_440_tlbre(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, - t0, cpu_gpr[rA(ctx->opcode)]); + gen_helper_440_tlbre(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, + t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); tcg_temp_free_i32(tcg_ctx, t0); } break; @@ -6425,13 +6419,13 @@ static void gen_tlbsx_440(DisasContext *ctx) CHK_SV; t0 = tcg_temp_new(tcg_ctx); gen_addr_reg_index(ctx, t0); - gen_helper_440_tlbsx(tcg_ctx, cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); + gen_helper_440_tlbsx(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_env, t0); tcg_temp_free(tcg_ctx, t0); if (Rc(ctx->opcode)) { TCGLabel *l1 = gen_new_label(tcg_ctx); - tcg_gen_trunc_tl_i32(tcg_ctx, cpu_crf[0], cpu_so); - tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_EQ, cpu_gpr[rD(ctx->opcode)], -1, l1); - tcg_gen_ori_i32(tcg_ctx, cpu_crf[0], cpu_crf[0], 0x02); + tcg_gen_trunc_tl_i32(tcg_ctx, tcg_ctx->cpu_crf[0], tcg_ctx->cpu_so); + tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_EQ, tcg_ctx->cpu_gpr[rD(ctx->opcode)], -1, l1); + tcg_gen_ori_i32(tcg_ctx, tcg_ctx->cpu_crf[0], tcg_ctx->cpu_crf[0], 0x02); gen_set_label(tcg_ctx, l1); } } @@ -6447,8 +6441,8 @@ static void gen_tlbwe_440(DisasContext *ctx) case 2: { TCGv_i32 t0 = tcg_const_i32(tcg_ctx, rB(ctx->opcode)); - gen_helper_440_tlbwe(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rS(ctx->opcode)]); + gen_helper_440_tlbwe(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rS(ctx->opcode)]); tcg_temp_free_i32(tcg_ctx, t0); } break; @@ -6477,12 +6471,12 @@ static void gen_tlbsx_booke206(DisasContext *ctx) CHK_SV; if (rA(ctx->opcode)) { t0 = tcg_temp_new(tcg_ctx); - tcg_gen_mov_tl(tcg_ctx, t0, cpu_gpr[rD(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rD(ctx->opcode)]); } else { t0 = tcg_const_tl(tcg_ctx, 0); } - tcg_gen_add_tl(tcg_ctx, t0, t0, cpu_gpr[rB(ctx->opcode)]); + tcg_gen_add_tl(tcg_ctx, t0, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); gen_helper_booke206_tlbsx(tcg_ctx, tcg_ctx->cpu_env, t0); tcg_temp_free(tcg_ctx, t0); } @@ -6543,9 +6537,9 @@ static void gen_wrtee(DisasContext *ctx) CHK_SV; t0 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[rD(ctx->opcode)], (1 << MSR_EE)); - tcg_gen_andi_tl(tcg_ctx, cpu_msr, cpu_msr, ~(1 << MSR_EE)); - tcg_gen_or_tl(tcg_ctx, cpu_msr, cpu_msr, t0); + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rD(ctx->opcode)], (1 << MSR_EE)); + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_msr, tcg_ctx->cpu_msr, ~(1 << MSR_EE)); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_msr, tcg_ctx->cpu_msr, t0); tcg_temp_free(tcg_ctx, t0); /* * Stop translation to have a chance to raise an exception if we @@ -6560,11 +6554,11 @@ static void gen_wrteei(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; if (ctx->opcode & 0x00008000) { - tcg_gen_ori_tl(tcg_ctx, cpu_msr, cpu_msr, (1 << MSR_EE)); + tcg_gen_ori_tl(tcg_ctx, tcg_ctx->cpu_msr, tcg_ctx->cpu_msr, (1 << MSR_EE)); /* Stop translation to have a chance to raise an exception */ gen_stop_exception(ctx); } else { - tcg_gen_andi_tl(tcg_ctx, cpu_msr, cpu_msr, ~(1 << MSR_EE)); + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_msr, tcg_ctx->cpu_msr, ~(1 << MSR_EE)); } } @@ -6575,8 +6569,8 @@ static void gen_dlmzb(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, Rc(ctx->opcode)); - gen_helper_dlmzb(tcg_ctx, cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_env, - cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], t0); + gen_helper_dlmzb(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_env, + tcg_ctx->cpu_gpr[rS(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)], t0); tcg_temp_free_i32(tcg_ctx, t0); } @@ -6614,9 +6608,9 @@ static void gen_msgclr(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_HV; if (is_book3s_arch2x(ctx)) { - gen_helper_book3s_msgclr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_book3s_msgclr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } else { - gen_helper_msgclr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_msgclr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } } @@ -6625,9 +6619,9 @@ static void gen_msgsnd(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_HV; if (is_book3s_arch2x(ctx)) { - gen_helper_book3s_msgsnd(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_book3s_msgsnd(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } else { - gen_helper_msgsnd(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_msgsnd(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } } @@ -6636,14 +6630,14 @@ static void gen_msgclrp(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_book3s_msgclrp(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_book3s_msgclrp(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } static void gen_msgsndp(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; CHK_SV; - gen_helper_book3s_msgsndp(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[rB(ctx->opcode)]); + gen_helper_book3s_msgsndp(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } #endif @@ -6659,8 +6653,8 @@ static void gen_maddld(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i64 t1 = tcg_temp_new_i64(tcg_ctx); - tcg_gen_mul_i64(tcg_ctx, t1, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); - tcg_gen_add_i64(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t1, cpu_gpr[rC(ctx->opcode)]); + tcg_gen_mul_i64(tcg_ctx, t1, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); + tcg_gen_add_i64(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t1, tcg_ctx->cpu_gpr[rC(ctx->opcode)]); tcg_temp_free_i64(tcg_ctx, t1); } @@ -6673,16 +6667,16 @@ static void gen_maddhd_maddhdu(DisasContext *ctx) TCGv_i64 t1 = tcg_temp_new_i64(tcg_ctx); if (Rc(ctx->opcode)) { - tcg_gen_mulu2_i64(tcg_ctx, lo, hi, cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rB(ctx->opcode)]); + tcg_gen_mulu2_i64(tcg_ctx, lo, hi, tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); tcg_gen_movi_i64(tcg_ctx, t1, 0); } else { - tcg_gen_muls2_i64(tcg_ctx, lo, hi, cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rB(ctx->opcode)]); - tcg_gen_sari_i64(tcg_ctx, t1, cpu_gpr[rC(ctx->opcode)], 63); + tcg_gen_muls2_i64(tcg_ctx, lo, hi, tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); + tcg_gen_sari_i64(tcg_ctx, t1, tcg_ctx->cpu_gpr[rC(ctx->opcode)], 63); } - tcg_gen_add2_i64(tcg_ctx, t1, cpu_gpr[rD(ctx->opcode)], lo, hi, - cpu_gpr[rC(ctx->opcode)], t1); + tcg_gen_add2_i64(tcg_ctx, t1, tcg_ctx->cpu_gpr[rD(ctx->opcode)], lo, hi, + tcg_ctx->cpu_gpr[rC(ctx->opcode)], t1); tcg_temp_free_i64(tcg_ctx, lo); tcg_temp_free_i64(tcg_ctx, hi); tcg_temp_free_i64(tcg_ctx, t1); @@ -6714,7 +6708,7 @@ static inline void gen_##name(DisasContext *ctx) \ * CR[0] = 0b0 || MSR[TS] || 0b0 \ * = 0b0 || 0b00 || 0b0 \ */ \ - tcg_gen_movi_i32(tcg_ctx, cpu_crf[0], 0); \ + tcg_gen_movi_i32(tcg_ctx, tcg_ctx->cpu_crf[0], 0); \ } GEN_TM_NOOP(tend); @@ -6757,7 +6751,7 @@ static void gen_tcheck(DisasContext *ctx) * CR[CRF] = TDOOMED || MSR[TS] || 0b0 * = 0b1 || 0b00 || 0b0 */ - tcg_gen_movi_i32(tcg_ctx, cpu_crf[crfD(ctx->opcode)], 0x8); + tcg_gen_movi_i32(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], 0x8); } #define GEN_TM_PRIV_NOOP(name) \ @@ -6776,7 +6770,7 @@ static inline void gen_##name(DisasContext *ctx) \ * CR[0] = 0b0 || MSR[TS] || 0b0 \ * = 0b0 || 0b00 | 0b0 \ */ \ - tcg_gen_movi_i32(tcg_ctx, cpu_crf[0], 0); \ + tcg_gen_movi_i32(tcg_ctx, tcg_ctx->cpu_crf[0], 0); \ } GEN_TM_PRIV_NOOP(treclaim); diff --git a/qemu/target/ppc/translate/dfp-impl.inc.c b/qemu/target/ppc/translate/dfp-impl.inc.c index 172c1c6ee7..a1b2f9e6cf 100644 --- a/qemu/target/ppc/translate/dfp-impl.inc.c +++ b/qemu/target/ppc/translate/dfp-impl.inc.c @@ -41,7 +41,7 @@ static void gen_##name(DisasContext *ctx) \ gen_update_nip(ctx, ctx->base.pc_next - 4); \ ra = gen_fprp_ptr(tcg_ctx, rA(ctx->opcode)); \ rb = gen_fprp_ptr(tcg_ctx, rB(ctx->opcode)); \ - gen_helper_##name(tcg_ctx, cpu_crf[crfD(ctx->opcode)], \ + gen_helper_##name(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], \ tcg_ctx->cpu_env, ra, rb); \ tcg_temp_free_ptr(tcg_ctx, ra); \ tcg_temp_free_ptr(tcg_ctx, rb); \ @@ -60,7 +60,7 @@ static void gen_##name(DisasContext *ctx) \ gen_update_nip(ctx, ctx->base.pc_next - 4); \ uim = tcg_const_i32(tcg_ctx, UIMM5(ctx->opcode)); \ rb = gen_fprp_ptr(tcg_ctx, rB(ctx->opcode)); \ - gen_helper_##name(tcg_ctx, cpu_crf[crfD(ctx->opcode)], \ + gen_helper_##name(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], \ tcg_ctx->cpu_env, uim, rb); \ tcg_temp_free_i32(tcg_ctx, uim); \ tcg_temp_free_ptr(tcg_ctx, rb); \ @@ -79,7 +79,7 @@ static void gen_##name(DisasContext *ctx) \ gen_update_nip(ctx, ctx->base.pc_next - 4); \ ra = gen_fprp_ptr(tcg_ctx, rA(ctx->opcode)); \ dcm = tcg_const_i32(tcg_ctx, DCM(ctx->opcode)); \ - gen_helper_##name(tcg_ctx, cpu_crf[crfD(ctx->opcode)], \ + gen_helper_##name(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], \ tcg_ctx->cpu_env, ra, dcm); \ tcg_temp_free_ptr(tcg_ctx, ra); \ tcg_temp_free_i32(tcg_ctx, dcm); \ diff --git a/qemu/target/ppc/translate/fp-impl.inc.c b/qemu/target/ppc/translate/fp-impl.inc.c index 58155f21eb..4ea9e43fb0 100644 --- a/qemu/target/ppc/translate/fp-impl.inc.c +++ b/qemu/target/ppc/translate/fp-impl.inc.c @@ -20,15 +20,15 @@ static void gen_set_cr1_from_fpscr(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 tmp = tcg_temp_new_i32(tcg_ctx); - tcg_gen_trunc_tl_i32(tcg_ctx, tmp, cpu_fpscr); - tcg_gen_shri_i32(tcg_ctx, cpu_crf[1], tmp, 28); + tcg_gen_trunc_tl_i32(tcg_ctx, tmp, tcg_ctx->cpu_fpscr); + tcg_gen_shri_i32(tcg_ctx, tcg_ctx->cpu_crf[1], tmp, 28); tcg_temp_free_i32(tcg_ctx, tmp); } #else static void gen_set_cr1_from_fpscr(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_shri_tl(tcg_ctx, cpu_crf[1], cpu_fpscr, 28); + tcg_gen_shri_tl(tcg_ctx, tcg_ctx->cpu_crf[1], tcg_ctx->cpu_fpscr, 28); } #endif @@ -353,7 +353,7 @@ static void gen_ftdiv(DisasContext *ctx) t1 = tcg_temp_new_i64(tcg_ctx); get_fpr(tcg_ctx, t0, rA(ctx->opcode)); get_fpr(tcg_ctx, t1, rB(ctx->opcode)); - gen_helper_ftdiv(tcg_ctx, cpu_crf[crfD(ctx->opcode)], t0, t1); + gen_helper_ftdiv(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], t0, t1); tcg_temp_free_i64(tcg_ctx, t0); tcg_temp_free_i64(tcg_ctx, t1); } @@ -368,7 +368,7 @@ static void gen_ftsqrt(DisasContext *ctx) } t0 = tcg_temp_new_i64(tcg_ctx); get_fpr(tcg_ctx, t0, rB(ctx->opcode)); - gen_helper_ftsqrt(tcg_ctx, cpu_crf[crfD(ctx->opcode)], t0); + gen_helper_ftsqrt(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], t0); tcg_temp_free_i64(tcg_ctx, t0); } @@ -605,12 +605,12 @@ static void gen_mcrfs(DisasContext *ctx) bfa = crfS(ctx->opcode); nibble = 7 - bfa; shift = 4 * nibble; - tcg_gen_shri_tl(tcg_ctx, tmp, cpu_fpscr, shift); - tcg_gen_trunc_tl_i32(tcg_ctx, cpu_crf[crfD(ctx->opcode)], tmp); - tcg_gen_andi_i32(tcg_ctx, cpu_crf[crfD(ctx->opcode)], cpu_crf[crfD(ctx->opcode)], + tcg_gen_shri_tl(tcg_ctx, tmp, tcg_ctx->cpu_fpscr, shift); + tcg_gen_trunc_tl_i32(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], tmp); + tcg_gen_andi_i32(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], tcg_ctx->cpu_crf[crfD(ctx->opcode)], 0xf); tcg_temp_free(tcg_ctx, tmp); - tcg_gen_extu_tl_i64(tcg_ctx, tnew_fpscr, cpu_fpscr); + tcg_gen_extu_tl_i64(tcg_ctx, tnew_fpscr, tcg_ctx->cpu_fpscr); /* Only the exception bits (including FX) should be cleared if read */ tcg_gen_andi_i64(tcg_ctx, tnew_fpscr, tnew_fpscr, ~((0xF << shift) & FP_EX_CLEAR_BITS)); @@ -632,7 +632,7 @@ static void gen_mffs(DisasContext *ctx) } t0 = tcg_temp_new_i64(tcg_ctx); gen_reset_fpstatus(tcg_ctx); - tcg_gen_extu_tl_i64(tcg_ctx, t0, cpu_fpscr); + tcg_gen_extu_tl_i64(tcg_ctx, t0, tcg_ctx->cpu_fpscr); set_fpr(tcg_ctx, rD(ctx->opcode), t0); if (unlikely(Rc(ctx->opcode))) { gen_set_cr1_from_fpscr(ctx); @@ -647,7 +647,7 @@ static void gen_mffsl(DisasContext *ctx) TCGv_i64 t0; if (unlikely(!(ctx->insns_flags2 & PPC2_ISA300))) { - return; + return gen_mffs(ctx); } if (unlikely(!ctx->fpu_enabled)) { @@ -656,7 +656,7 @@ static void gen_mffsl(DisasContext *ctx) } t0 = tcg_temp_new_i64(tcg_ctx); gen_reset_fpstatus(tcg_ctx); - tcg_gen_extu_tl_i64(tcg_ctx, t0, cpu_fpscr); + tcg_gen_extu_tl_i64(tcg_ctx, t0, tcg_ctx->cpu_fpscr); /* Mask everything except mode, status, and enables. */ tcg_gen_andi_i64(tcg_ctx, t0, t0, FP_DRN | FP_STATUS | FP_ENABLES | FP_RN); set_fpr(tcg_ctx, rD(ctx->opcode), t0); @@ -671,7 +671,7 @@ static void gen_mffsce(DisasContext *ctx) TCGv_i32 mask; if (unlikely(!(ctx->insns_flags2 & PPC2_ISA300))) { - return; + return gen_mffs(ctx); } if (unlikely(!ctx->fpu_enabled)) { @@ -682,7 +682,7 @@ static void gen_mffsce(DisasContext *ctx) t0 = tcg_temp_new_i64(tcg_ctx); gen_reset_fpstatus(tcg_ctx); - tcg_gen_extu_tl_i64(tcg_ctx, t0, cpu_fpscr); + tcg_gen_extu_tl_i64(tcg_ctx, t0, tcg_ctx->cpu_fpscr); set_fpr(tcg_ctx, rD(ctx->opcode), t0); /* Clear exception enable bits in the FPSCR. */ @@ -701,7 +701,7 @@ static void gen_helper_mffscrn(DisasContext *ctx, TCGv_i64 t1) TCGv_i32 mask = tcg_const_i32(tcg_ctx, 0x0001); gen_reset_fpstatus(tcg_ctx); - tcg_gen_extu_tl_i64(tcg_ctx, t0, cpu_fpscr); + tcg_gen_extu_tl_i64(tcg_ctx, t0, tcg_ctx->cpu_fpscr); tcg_gen_andi_i64(tcg_ctx, t0, t0, FP_DRN | FP_ENABLES | FP_RN); set_fpr(tcg_ctx, rD(ctx->opcode), t0); @@ -724,7 +724,7 @@ static void gen_mffscrn(DisasContext *ctx) TCGv_i64 t1; if (unlikely(!(ctx->insns_flags2 & PPC2_ISA300))) { - return; + return gen_mffs(ctx); } if (unlikely(!ctx->fpu_enabled)) { @@ -749,7 +749,7 @@ static void gen_mffscrni(DisasContext *ctx) TCGv_i64 t1; if (unlikely(!(ctx->insns_flags2 & PPC2_ISA300))) { - return; + return gen_mffs(ctx); } if (unlikely(!ctx->fpu_enabled)) { @@ -783,8 +783,8 @@ static void gen_mtfsb0(DisasContext *ctx) tcg_temp_free_i32(tcg_ctx, t0); } if (unlikely(Rc(ctx->opcode) != 0)) { - tcg_gen_trunc_tl_i32(tcg_ctx, cpu_crf[1], cpu_fpscr); - tcg_gen_shri_i32(tcg_ctx, cpu_crf[1], cpu_crf[1], FPSCR_OX); + tcg_gen_trunc_tl_i32(tcg_ctx, tcg_ctx->cpu_crf[1], tcg_ctx->cpu_fpscr); + tcg_gen_shri_i32(tcg_ctx, tcg_ctx->cpu_crf[1], tcg_ctx->cpu_crf[1], FPSCR_OX); } } @@ -808,8 +808,8 @@ static void gen_mtfsb1(DisasContext *ctx) tcg_temp_free_i32(tcg_ctx, t0); } if (unlikely(Rc(ctx->opcode) != 0)) { - tcg_gen_trunc_tl_i32(tcg_ctx, cpu_crf[1], cpu_fpscr); - tcg_gen_shri_i32(tcg_ctx, cpu_crf[1], cpu_crf[1], FPSCR_OX); + tcg_gen_trunc_tl_i32(tcg_ctx, tcg_ctx->cpu_crf[1], tcg_ctx->cpu_fpscr); + tcg_gen_shri_i32(tcg_ctx, tcg_ctx->cpu_crf[1], tcg_ctx->cpu_crf[1], FPSCR_OX); } /* We can raise a deferred exception */ gen_helper_float_check_status(tcg_ctx, tcg_ctx->cpu_env); @@ -845,8 +845,8 @@ static void gen_mtfsf(DisasContext *ctx) gen_helper_store_fpscr(tcg_ctx, tcg_ctx->cpu_env, t1, t0); tcg_temp_free_i32(tcg_ctx, t0); if (unlikely(Rc(ctx->opcode) != 0)) { - tcg_gen_trunc_tl_i32(tcg_ctx, cpu_crf[1], cpu_fpscr); - tcg_gen_shri_i32(tcg_ctx, cpu_crf[1], cpu_crf[1], FPSCR_OX); + tcg_gen_trunc_tl_i32(tcg_ctx, tcg_ctx->cpu_crf[1], tcg_ctx->cpu_fpscr); + tcg_gen_shri_i32(tcg_ctx, tcg_ctx->cpu_crf[1], tcg_ctx->cpu_crf[1], FPSCR_OX); } /* We can raise a deferred exception */ gen_helper_float_check_status(tcg_ctx, tcg_ctx->cpu_env); @@ -879,8 +879,8 @@ static void gen_mtfsfi(DisasContext *ctx) tcg_temp_free_i64(tcg_ctx, t0); tcg_temp_free_i32(tcg_ctx, t1); if (unlikely(Rc(ctx->opcode) != 0)) { - tcg_gen_trunc_tl_i32(tcg_ctx, cpu_crf[1], cpu_fpscr); - tcg_gen_shri_i32(tcg_ctx, cpu_crf[1], cpu_crf[1], FPSCR_OX); + tcg_gen_trunc_tl_i32(tcg_ctx, tcg_ctx->cpu_crf[1], tcg_ctx->cpu_fpscr); + tcg_gen_shri_i32(tcg_ctx, tcg_ctx->cpu_crf[1], tcg_ctx->cpu_crf[1], FPSCR_OX); } /* We can raise a deferred exception */ gen_helper_float_check_status(tcg_ctx, tcg_ctx->cpu_env); @@ -898,13 +898,13 @@ static void glue(gen_, name)(DisasContext *ctx) \ return; \ } \ gen_set_access_type(ctx, ACCESS_FLOAT); \ - EA = tcg_temp_new(tcg_ctx); \ - t0 = tcg_temp_new_i64(tcg_ctx); \ + EA = tcg_temp_new(tcg_ctx); \ + t0 = tcg_temp_new_i64(tcg_ctx); \ gen_addr_imm_index(ctx, EA, 0); \ gen_qemu_##ldop(ctx, t0, EA); \ - set_fpr(tcg_ctx, rD(ctx->opcode), t0); \ - tcg_temp_free(tcg_ctx, EA); \ - tcg_temp_free_i64(tcg_ctx, t0); \ + set_fpr(tcg_ctx, rD(ctx->opcode), t0); \ + tcg_temp_free(tcg_ctx, EA); \ + tcg_temp_free_i64(tcg_ctx, t0); \ } #define GEN_LDUF(name, ldop, opc, type) \ @@ -927,7 +927,7 @@ static void glue(gen_, name##u)(DisasContext *ctx) \ gen_addr_imm_index(ctx, EA, 0); \ gen_qemu_##ldop(ctx, t0, EA); \ set_fpr(tcg_ctx, rD(ctx->opcode), t0); \ - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], EA); \ + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], EA); \ tcg_temp_free(tcg_ctx, EA); \ tcg_temp_free_i64(tcg_ctx, t0); \ } @@ -952,7 +952,7 @@ static void glue(gen_, name##ux)(DisasContext *ctx) \ gen_addr_reg_index(ctx, EA); \ gen_qemu_##ldop(ctx, t0, EA); \ set_fpr(tcg_ctx, rD(ctx->opcode), t0); \ - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], EA); \ + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], EA); \ tcg_temp_free(tcg_ctx, EA); \ tcg_temp_free_i64(tcg_ctx, t0); \ } @@ -1172,7 +1172,7 @@ static void glue(gen_, name##u)(DisasContext *ctx) \ gen_addr_imm_index(ctx, EA, 0); \ get_fpr(tcg_ctx, t0, rS(ctx->opcode)); \ gen_qemu_##stop(ctx, t0, EA); \ - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], EA); \ + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], EA); \ tcg_temp_free(tcg_ctx, EA); \ tcg_temp_free_i64(tcg_ctx, t0); \ } @@ -1197,7 +1197,7 @@ static void glue(gen_, name##ux)(DisasContext *ctx) \ gen_addr_reg_index(ctx, EA); \ get_fpr(tcg_ctx, t0, rS(ctx->opcode)); \ gen_qemu_##stop(ctx, t0, EA); \ - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], EA); \ + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], EA); \ tcg_temp_free(tcg_ctx, EA); \ tcg_temp_free_i64(tcg_ctx, t0); \ } @@ -1387,7 +1387,7 @@ static void gen_lfqu(DisasContext *ctx) gen_qemu_ld64_i64(ctx, t2, t1); set_fpr(tcg_ctx, (rd + 1) % 32, t2); if (ra != 0) { - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[ra], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[ra], t0); } tcg_temp_free(tcg_ctx, t0); tcg_temp_free(tcg_ctx, t1); @@ -1414,7 +1414,7 @@ static void gen_lfqux(DisasContext *ctx) set_fpr(tcg_ctx, (rd + 1) % 32, t2); tcg_temp_free(tcg_ctx, t1); if (ra != 0) { - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[ra], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[ra], t0); } tcg_temp_free(tcg_ctx, t0); tcg_temp_free_i64(tcg_ctx, t2); @@ -1480,7 +1480,7 @@ static void gen_stfqu(DisasContext *ctx) gen_qemu_st64_i64(ctx, t2, t1); tcg_temp_free(tcg_ctx, t1); if (ra != 0) { - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[ra], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[ra], t0); } tcg_temp_free(tcg_ctx, t0); tcg_temp_free_i64(tcg_ctx, t2); @@ -1506,7 +1506,7 @@ static void gen_stfqux(DisasContext *ctx) gen_qemu_st64_i64(ctx, t2, t1); tcg_temp_free(tcg_ctx, t1); if (ra != 0) { - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[ra], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[ra], t0); } tcg_temp_free(tcg_ctx, t0); tcg_temp_free_i64(tcg_ctx, t2); diff --git a/qemu/target/ppc/translate/spe-impl.inc.c b/qemu/target/ppc/translate/spe-impl.inc.c index 3b229861d6..02415344a1 100644 --- a/qemu/target/ppc/translate/spe-impl.inc.c +++ b/qemu/target/ppc/translate/spe-impl.inc.c @@ -19,26 +19,26 @@ static inline void gen_evmra(DisasContext *ctx) TCGv_i64 tmp = tcg_temp_new_i64(tcg_ctx); /* tmp := rA_lo + rA_hi << 32 */ - tcg_gen_concat_tl_i64(tcg_ctx, tmp, cpu_gpr[rA(ctx->opcode)], - cpu_gprh[rA(ctx->opcode)]); + tcg_gen_concat_tl_i64(tcg_ctx, tmp, tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gprh[rA(ctx->opcode)]); /* spe_acc := tmp */ tcg_gen_st_i64(tcg_ctx, tmp, tcg_ctx->cpu_env, offsetof(CPUPPCState, spe_acc)); tcg_temp_free_i64(tcg_ctx, tmp); /* rD := rA */ - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - tcg_gen_mov_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rA(ctx->opcode)]); } static inline void gen_load_gpr64(TCGContext *tcg_ctx, TCGv_i64 t, int reg) { - tcg_gen_concat_tl_i64(tcg_ctx, t, cpu_gpr[reg], cpu_gprh[reg]); + tcg_gen_concat_tl_i64(tcg_ctx, t, tcg_ctx->cpu_gpr[reg], tcg_ctx->cpu_gprh[reg]); } static inline void gen_store_gpr64(TCGContext *tcg_ctx, int reg, TCGv_i64 t) { - tcg_gen_extr_i64_tl(tcg_ctx, cpu_gpr[reg], cpu_gprh[reg], t); + tcg_gen_extr_i64_tl(tcg_ctx, tcg_ctx->cpu_gpr[reg], tcg_ctx->cpu_gprh[reg], t); } #define GEN_SPE(name0, name1, opc2, opc3, inval0, inval1, type) \ @@ -65,10 +65,10 @@ static inline void gen_##name(DisasContext *ctx) \ gen_exception(ctx, POWERPC_EXCP_SPEU); \ return; \ } \ - tcg_op(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], \ - cpu_gpr[rB(ctx->opcode)]); \ - tcg_op(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)], \ - cpu_gprh[rB(ctx->opcode)]); \ + tcg_op(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rB(ctx->opcode)]); \ + tcg_op(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rA(ctx->opcode)], \ + tcg_ctx->cpu_gprh[rB(ctx->opcode)]); \ } GEN_SPEOP_LOGIC2(evand, tcg_gen_and_tl); @@ -92,13 +92,13 @@ static inline void gen_##name(DisasContext *ctx) \ } \ t0 = tcg_temp_new_i32(tcg_ctx); \ \ - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); \ tcg_opi(tcg_ctx, t0, t0, rB(ctx->opcode)); \ - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); \ + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); \ \ - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gprh[rA(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gprh[rA(ctx->opcode)]); \ tcg_opi(tcg_ctx, t0, t0, rB(ctx->opcode)); \ - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], t0); \ + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0); \ \ tcg_temp_free_i32(tcg_ctx, t0); \ } @@ -119,13 +119,13 @@ static inline void gen_##name(DisasContext *ctx) \ } \ t0 = tcg_temp_new_i32(tcg_ctx); \ \ - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); \ tcg_op(tcg_ctx, t0, t0); \ - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); \ + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); \ \ - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gprh[rA(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gprh[rA(ctx->opcode)]); \ tcg_op(tcg_ctx, t0, t0); \ - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], t0); \ + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0); \ \ tcg_temp_free_i32(tcg_ctx, t0); \ } @@ -155,15 +155,15 @@ static inline void gen_##name(DisasContext *ctx) \ t0 = tcg_temp_new_i32(tcg_ctx); \ t1 = tcg_temp_new_i32(tcg_ctx); \ \ - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); \ - tcg_gen_trunc_tl_i32(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); \ tcg_op(tcg_ctx, t0, t0, t1); \ - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); \ + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); \ \ - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gprh[rA(ctx->opcode)]); \ - tcg_gen_trunc_tl_i32(tcg_ctx, t1, cpu_gprh[rB(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gprh[rA(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t1, tcg_ctx->cpu_gprh[rB(ctx->opcode)]); \ tcg_op(tcg_ctx, t0, t0, t1); \ - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], t0); \ + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0); \ \ tcg_temp_free_i32(tcg_ctx, t0); \ tcg_temp_free_i32(tcg_ctx, t1); \ @@ -235,8 +235,8 @@ static inline void gen_evmergehi(DisasContext *ctx) gen_exception(ctx, POWERPC_EXCP_SPEU); return; } - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gprh[rB(ctx->opcode)]); - tcg_gen_mov_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rB(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rA(ctx->opcode)]); } GEN_SPEOP_ARITH2(evaddw, tcg_gen_add_i32); static inline void gen_op_evsubf(TCGContext *tcg_ctx, TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) @@ -257,13 +257,13 @@ static inline void gen_##name(DisasContext *ctx) \ } \ t0 = tcg_temp_new_i32(tcg_ctx); \ \ - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); \ tcg_op(tcg_ctx, t0, t0, rA(ctx->opcode)); \ - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); \ + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); \ \ - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gprh[rB(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gprh[rB(ctx->opcode)]); \ tcg_op(tcg_ctx, t0, t0, rA(ctx->opcode)); \ - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], t0); \ + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0); \ \ tcg_temp_free_i32(tcg_ctx, t0); \ } @@ -284,26 +284,26 @@ static inline void gen_##name(DisasContext *ctx) \ TCGLabel *l3 = gen_new_label(tcg_ctx); \ TCGLabel *l4 = gen_new_label(tcg_ctx); \ \ - tcg_gen_ext32s_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); \ - tcg_gen_ext32s_tl(tcg_ctx, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); \ - tcg_gen_ext32s_tl(tcg_ctx, cpu_gprh[rA(ctx->opcode)], cpu_gprh[rA(ctx->opcode)]); \ - tcg_gen_ext32s_tl(tcg_ctx, cpu_gprh[rB(ctx->opcode)], cpu_gprh[rB(ctx->opcode)]); \ + tcg_gen_ext32s_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)]); \ + tcg_gen_ext32s_tl(tcg_ctx, tcg_ctx->cpu_gpr[rB(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); \ + tcg_gen_ext32s_tl(tcg_ctx, tcg_ctx->cpu_gprh[rA(ctx->opcode)], tcg_ctx->cpu_gprh[rA(ctx->opcode)]); \ + tcg_gen_ext32s_tl(tcg_ctx, tcg_ctx->cpu_gprh[rB(ctx->opcode)], tcg_ctx->cpu_gprh[rB(ctx->opcode)]); \ \ - tcg_gen_brcond_tl(tcg_ctx, tcg_cond, cpu_gpr[rA(ctx->opcode)], \ - cpu_gpr[rB(ctx->opcode)], l1); \ - tcg_gen_movi_i32(tcg_ctx, cpu_crf[crfD(ctx->opcode)], 0); \ + tcg_gen_brcond_tl(tcg_ctx, tcg_cond, tcg_ctx->cpu_gpr[rA(ctx->opcode)], \ + tcg_ctx->cpu_gpr[rB(ctx->opcode)], l1); \ + tcg_gen_movi_i32(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], 0); \ tcg_gen_br(tcg_ctx, l2); \ gen_set_label(tcg_ctx, l1); \ - tcg_gen_movi_i32(tcg_ctx, cpu_crf[crfD(ctx->opcode)], \ + tcg_gen_movi_i32(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], \ CRF_CL | CRF_CH_OR_CL | CRF_CH_AND_CL); \ gen_set_label(tcg_ctx, l2); \ - tcg_gen_brcond_tl(tcg_ctx, tcg_cond, cpu_gprh[rA(ctx->opcode)], \ - cpu_gprh[rB(ctx->opcode)], l3); \ - tcg_gen_andi_i32(tcg_ctx, cpu_crf[crfD(ctx->opcode)], cpu_crf[crfD(ctx->opcode)], \ + tcg_gen_brcond_tl(tcg_ctx, tcg_cond, tcg_ctx->cpu_gprh[rA(ctx->opcode)], \ + tcg_ctx->cpu_gprh[rB(ctx->opcode)], l3); \ + tcg_gen_andi_i32(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], tcg_ctx->cpu_crf[crfD(ctx->opcode)], \ ~(CRF_CH | CRF_CH_AND_CL)); \ tcg_gen_br(tcg_ctx, l4); \ gen_set_label(tcg_ctx, l3); \ - tcg_gen_ori_i32(tcg_ctx, cpu_crf[crfD(ctx->opcode)], cpu_crf[crfD(ctx->opcode)], \ + tcg_gen_ori_i32(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], tcg_ctx->cpu_crf[crfD(ctx->opcode)], \ CRF_CH | CRF_CH_OR_CL); \ gen_set_label(tcg_ctx, l4); \ } @@ -318,8 +318,8 @@ static inline void gen_brinc(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; /* Note: brinc is usable even if SPE is disabled */ - gen_helper_brinc(tcg_ctx, cpu_gpr[rD(ctx->opcode)], - cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); + gen_helper_brinc(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], + tcg_ctx->cpu_gpr[rA(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } static inline void gen_evmergelo(DisasContext *ctx) @@ -329,8 +329,8 @@ static inline void gen_evmergelo(DisasContext *ctx) gen_exception(ctx, POWERPC_EXCP_SPEU); return; } - tcg_gen_mov_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); } static inline void gen_evmergehilo(DisasContext *ctx) @@ -340,8 +340,8 @@ static inline void gen_evmergehilo(DisasContext *ctx) gen_exception(ctx, POWERPC_EXCP_SPEU); return; } - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); - tcg_gen_mov_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rA(ctx->opcode)]); } static inline void gen_evmergelohi(DisasContext *ctx) @@ -353,13 +353,13 @@ static inline void gen_evmergelohi(DisasContext *ctx) } if (rD(ctx->opcode) == rA(ctx->opcode)) { TCGv tmp = tcg_temp_new(tcg_ctx); - tcg_gen_mov_tl(tcg_ctx, tmp, cpu_gpr[rA(ctx->opcode)]); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gprh[rB(ctx->opcode)]); - tcg_gen_mov_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], tmp); + tcg_gen_mov_tl(tcg_ctx, tmp, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rB(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tmp); tcg_temp_free(tcg_ctx, tmp); } else { - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gprh[rB(ctx->opcode)]); - tcg_gen_mov_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rB(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } } @@ -368,8 +368,8 @@ static inline void gen_evsplati(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; uint64_t imm = ((int32_t)(rA(ctx->opcode) << 27)) >> 27; - tcg_gen_movi_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], imm); - tcg_gen_movi_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], imm); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], imm); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], imm); } static inline void gen_evsplatfi(DisasContext *ctx) @@ -377,8 +377,8 @@ static inline void gen_evsplatfi(DisasContext *ctx) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; uint64_t imm = rA(ctx->opcode) << 27; - tcg_gen_movi_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], imm); - tcg_gen_movi_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], imm); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], imm); + tcg_gen_movi_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], imm); } static inline void gen_evsel(DisasContext *ctx) @@ -390,19 +390,19 @@ static inline void gen_evsel(DisasContext *ctx) TCGLabel *l4 = gen_new_label(tcg_ctx); TCGv_i32 t0 = tcg_temp_local_new_i32(tcg_ctx); - tcg_gen_andi_i32(tcg_ctx, t0, cpu_crf[ctx->opcode & 0x07], 1 << 3); + tcg_gen_andi_i32(tcg_ctx, t0, tcg_ctx->cpu_crf[ctx->opcode & 0x07], 1 << 3); tcg_gen_brcondi_i32(tcg_ctx, TCG_COND_EQ, t0, 0, l1); - tcg_gen_mov_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rA(ctx->opcode)]); tcg_gen_br(tcg_ctx, l2); gen_set_label(tcg_ctx, l1); - tcg_gen_mov_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gprh[rB(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rB(ctx->opcode)]); gen_set_label(tcg_ctx, l2); - tcg_gen_andi_i32(tcg_ctx, t0, cpu_crf[ctx->opcode & 0x07], 1 << 2); + tcg_gen_andi_i32(tcg_ctx, t0, tcg_ctx->cpu_crf[ctx->opcode & 0x07], 1 << 2); tcg_gen_brcondi_i32(tcg_ctx, TCG_COND_EQ, t0, 0, l3); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)]); tcg_gen_br(tcg_ctx, l4); gen_set_label(tcg_ctx, l3); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rB(ctx->opcode)]); gen_set_label(tcg_ctx, l4); tcg_temp_free_i32(tcg_ctx, t0); } @@ -443,9 +443,9 @@ static inline void gen_evmwumi(DisasContext *ctx) t1 = tcg_temp_new_i64(tcg_ctx); /* t0 := rA; t1 := rB */ - tcg_gen_extu_tl_i64(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); + tcg_gen_extu_tl_i64(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); tcg_gen_ext32u_i64(tcg_ctx, t0, t0); - tcg_gen_extu_tl_i64(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)]); + tcg_gen_extu_tl_i64(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); tcg_gen_ext32u_i64(tcg_ctx, t1, t1); tcg_gen_mul_i64(tcg_ctx, t0, t0, t1); /* t0 := rA * rB */ @@ -525,9 +525,9 @@ static inline void gen_evmwsmi(DisasContext *ctx) t1 = tcg_temp_new_i64(tcg_ctx); /* t0 := rA; t1 := rB */ - tcg_gen_extu_tl_i64(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); + tcg_gen_extu_tl_i64(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); tcg_gen_ext32s_i64(tcg_ctx, t0, t0); - tcg_gen_extu_tl_i64(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)]); + tcg_gen_extu_tl_i64(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); tcg_gen_ext32s_i64(tcg_ctx, t1, t1); tcg_gen_mul_i64(tcg_ctx, t0, t0, t1); /* t0 := rA * rB */ @@ -623,7 +623,7 @@ static inline void gen_addr_spe_imm_index(DisasContext *ctx, TCGv EA, int sh) if (rA(ctx->opcode) == 0) { tcg_gen_movi_tl(tcg_ctx, EA, uimm << sh); } else { - tcg_gen_addi_tl(tcg_ctx, EA, cpu_gpr[rA(ctx->opcode)], uimm << sh); + tcg_gen_addi_tl(tcg_ctx, EA, tcg_ctx->cpu_gpr[rA(ctx->opcode)], uimm << sh); if (NARROW_MODE(ctx)) { tcg_gen_ext32u_tl(tcg_ctx, EA, EA); } @@ -641,9 +641,10 @@ static inline void gen_op_evldd(DisasContext *ctx, TCGv addr) static inline void gen_op_evldw(DisasContext *ctx, TCGv addr) { - gen_qemu_ld32u(ctx, cpu_gprh[rD(ctx->opcode)], addr); + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; + gen_qemu_ld32u(ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], addr); gen_addr_add(ctx, addr, addr, 4); - gen_qemu_ld32u(ctx, cpu_gpr[rD(ctx->opcode)], addr); + gen_qemu_ld32u(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], addr); } static inline void gen_op_evldh(DisasContext *ctx, TCGv addr) @@ -651,16 +652,16 @@ static inline void gen_op_evldh(DisasContext *ctx, TCGv addr) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); gen_qemu_ld16u(ctx, t0, addr); - tcg_gen_shli_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], t0, 16); + tcg_gen_shli_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0, 16); gen_addr_add(ctx, addr, addr, 2); gen_qemu_ld16u(ctx, t0, addr); - tcg_gen_or_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gprh[rD(ctx->opcode)], t0); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0); gen_addr_add(ctx, addr, addr, 2); gen_qemu_ld16u(ctx, t0, addr); - tcg_gen_shli_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], t0, 16); + tcg_gen_shli_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0, 16); gen_addr_add(ctx, addr, addr, 2); gen_qemu_ld16u(ctx, t0, addr); - tcg_gen_or_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rD(ctx->opcode)], t0); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); tcg_temp_free(tcg_ctx, t0); } @@ -670,8 +671,8 @@ static inline void gen_op_evlhhesplat(DisasContext *ctx, TCGv addr) TCGv t0 = tcg_temp_new(tcg_ctx); gen_qemu_ld16u(ctx, t0, addr); tcg_gen_shli_tl(tcg_ctx, t0, t0, 16); - tcg_gen_mov_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], t0); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); tcg_temp_free(tcg_ctx, t0); } @@ -680,8 +681,8 @@ static inline void gen_op_evlhhousplat(DisasContext *ctx, TCGv addr) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); gen_qemu_ld16u(ctx, t0, addr); - tcg_gen_mov_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], t0); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); tcg_temp_free(tcg_ctx, t0); } @@ -690,8 +691,8 @@ static inline void gen_op_evlhhossplat(DisasContext *ctx, TCGv addr) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); gen_qemu_ld16s(ctx, t0, addr); - tcg_gen_mov_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], t0); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); tcg_temp_free(tcg_ctx, t0); } @@ -700,25 +701,27 @@ static inline void gen_op_evlwhe(DisasContext *ctx, TCGv addr) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); gen_qemu_ld16u(ctx, t0, addr); - tcg_gen_shli_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], t0, 16); + tcg_gen_shli_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0, 16); gen_addr_add(ctx, addr, addr, 2); gen_qemu_ld16u(ctx, t0, addr); - tcg_gen_shli_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0, 16); + tcg_gen_shli_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0, 16); tcg_temp_free(tcg_ctx, t0); } static inline void gen_op_evlwhou(DisasContext *ctx, TCGv addr) { - gen_qemu_ld16u(ctx, cpu_gprh[rD(ctx->opcode)], addr); + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; + gen_qemu_ld16u(ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], addr); gen_addr_add(ctx, addr, addr, 2); - gen_qemu_ld16u(ctx, cpu_gpr[rD(ctx->opcode)], addr); + gen_qemu_ld16u(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], addr); } static inline void gen_op_evlwhos(DisasContext *ctx, TCGv addr) { - gen_qemu_ld16s(ctx, cpu_gprh[rD(ctx->opcode)], addr); + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; + gen_qemu_ld16s(ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], addr); gen_addr_add(ctx, addr, addr, 2); - gen_qemu_ld16s(ctx, cpu_gpr[rD(ctx->opcode)], addr); + gen_qemu_ld16s(ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], addr); } static inline void gen_op_evlwwsplat(DisasContext *ctx, TCGv addr) @@ -726,8 +729,8 @@ static inline void gen_op_evlwwsplat(DisasContext *ctx, TCGv addr) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); gen_qemu_ld32u(ctx, t0, addr); - tcg_gen_mov_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], t0); - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); tcg_temp_free(tcg_ctx, t0); } @@ -736,12 +739,12 @@ static inline void gen_op_evlwhsplat(DisasContext *ctx, TCGv addr) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); gen_qemu_ld16u(ctx, t0, addr); - tcg_gen_shli_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], t0, 16); - tcg_gen_or_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gprh[rD(ctx->opcode)], t0); + tcg_gen_shli_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0, 16); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0); gen_addr_add(ctx, addr, addr, 2); gen_qemu_ld16u(ctx, t0, addr); - tcg_gen_shli_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0, 16); - tcg_gen_or_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gprh[rD(ctx->opcode)], t0); + tcg_gen_shli_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0, 16); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rD(ctx->opcode)], t0); tcg_temp_free(tcg_ctx, t0); } @@ -756,54 +759,58 @@ static inline void gen_op_evstdd(DisasContext *ctx, TCGv addr) static inline void gen_op_evstdw(DisasContext *ctx, TCGv addr) { - gen_qemu_st32(ctx, cpu_gprh[rS(ctx->opcode)], addr); + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; + gen_qemu_st32(ctx, tcg_ctx->cpu_gprh[rS(ctx->opcode)], addr); gen_addr_add(ctx, addr, addr, 4); - gen_qemu_st32(ctx, cpu_gpr[rS(ctx->opcode)], addr); + gen_qemu_st32(ctx, tcg_ctx->cpu_gpr[rS(ctx->opcode)], addr); } static inline void gen_op_evstdh(DisasContext *ctx, TCGv addr) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); - tcg_gen_shri_tl(tcg_ctx, t0, cpu_gprh[rS(ctx->opcode)], 16); + tcg_gen_shri_tl(tcg_ctx, t0, tcg_ctx->cpu_gprh[rS(ctx->opcode)], 16); gen_qemu_st16(ctx, t0, addr); gen_addr_add(ctx, addr, addr, 2); - gen_qemu_st16(ctx, cpu_gprh[rS(ctx->opcode)], addr); + gen_qemu_st16(ctx, tcg_ctx->cpu_gprh[rS(ctx->opcode)], addr); gen_addr_add(ctx, addr, addr, 2); - tcg_gen_shri_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], 16); + tcg_gen_shri_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], 16); gen_qemu_st16(ctx, t0, addr); tcg_temp_free(tcg_ctx, t0); gen_addr_add(ctx, addr, addr, 2); - gen_qemu_st16(ctx, cpu_gpr[rS(ctx->opcode)], addr); + gen_qemu_st16(ctx, tcg_ctx->cpu_gpr[rS(ctx->opcode)], addr); } static inline void gen_op_evstwhe(DisasContext *ctx, TCGv addr) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); - tcg_gen_shri_tl(tcg_ctx, t0, cpu_gprh[rS(ctx->opcode)], 16); + tcg_gen_shri_tl(tcg_ctx, t0, tcg_ctx->cpu_gprh[rS(ctx->opcode)], 16); gen_qemu_st16(ctx, t0, addr); gen_addr_add(ctx, addr, addr, 2); - tcg_gen_shri_tl(tcg_ctx, t0, cpu_gpr[rS(ctx->opcode)], 16); + tcg_gen_shri_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[rS(ctx->opcode)], 16); gen_qemu_st16(ctx, t0, addr); tcg_temp_free(tcg_ctx, t0); } static inline void gen_op_evstwho(DisasContext *ctx, TCGv addr) { - gen_qemu_st16(ctx, cpu_gprh[rS(ctx->opcode)], addr); + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; + gen_qemu_st16(ctx, tcg_ctx->cpu_gprh[rS(ctx->opcode)], addr); gen_addr_add(ctx, addr, addr, 2); - gen_qemu_st16(ctx, cpu_gpr[rS(ctx->opcode)], addr); + gen_qemu_st16(ctx, tcg_ctx->cpu_gpr[rS(ctx->opcode)], addr); } static inline void gen_op_evstwwe(DisasContext *ctx, TCGv addr) { - gen_qemu_st32(ctx, cpu_gprh[rS(ctx->opcode)], addr); + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; + gen_qemu_st32(ctx, tcg_ctx->cpu_gprh[rS(ctx->opcode)], addr); } static inline void gen_op_evstwwo(DisasContext *ctx, TCGv addr) { - gen_qemu_st32(ctx, cpu_gpr[rS(ctx->opcode)], addr); + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; + gen_qemu_st32(ctx, tcg_ctx->cpu_gpr[rS(ctx->opcode)], addr); } #define GEN_SPEOP_LDST(name, opc2, sh) \ @@ -924,9 +931,9 @@ static inline void gen_##name(DisasContext *ctx) \ { \ TCGContext *tcg_ctx = ctx->uc->tcg_ctx; \ TCGv_i32 t0 = tcg_temp_new_i32(tcg_ctx); \ - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); \ gen_helper_##name(tcg_ctx, t0, tcg_ctx->cpu_env, t0); \ - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); \ + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); \ tcg_temp_free_i32(tcg_ctx, t0); \ } #define GEN_SPEFPUOP_CONV_32_64(name) \ @@ -937,7 +944,7 @@ static inline void gen_##name(DisasContext *ctx) \ TCGv_i32 t1 = tcg_temp_new_i32(tcg_ctx); \ gen_load_gpr64(tcg_ctx, t0, rB(ctx->opcode)); \ gen_helper_##name(tcg_ctx, t1, tcg_ctx->cpu_env, t0); \ - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t1); \ + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t1); \ tcg_temp_free_i64(tcg_ctx, t0); \ tcg_temp_free_i32(tcg_ctx, t1); \ } @@ -947,7 +954,7 @@ static inline void gen_##name(DisasContext *ctx) \ TCGContext *tcg_ctx = ctx->uc->tcg_ctx; \ TCGv_i64 t0 = tcg_temp_new_i64(tcg_ctx); \ TCGv_i32 t1 = tcg_temp_new_i32(tcg_ctx); \ - tcg_gen_trunc_tl_i32(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); \ gen_helper_##name(tcg_ctx, t0, tcg_ctx->cpu_env, t1); \ gen_store_gpr64(tcg_ctx, rD(ctx->opcode), t0); \ tcg_temp_free_i64(tcg_ctx, t0); \ @@ -974,10 +981,10 @@ static inline void gen_##name(DisasContext *ctx) \ } \ t0 = tcg_temp_new_i32(tcg_ctx); \ t1 = tcg_temp_new_i32(tcg_ctx); \ - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); \ - tcg_gen_trunc_tl_i32(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); \ gen_helper_##name(tcg_ctx, t0, tcg_ctx->cpu_env, t0, t1); \ - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], t0); \ + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], t0); \ \ tcg_temp_free_i32(tcg_ctx, t0); \ tcg_temp_free_i32(tcg_ctx, t1); \ @@ -1012,9 +1019,9 @@ static inline void gen_##name(DisasContext *ctx) \ t0 = tcg_temp_new_i32(tcg_ctx); \ t1 = tcg_temp_new_i32(tcg_ctx); \ \ - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); \ - tcg_gen_trunc_tl_i32(tcg_ctx, t1, cpu_gpr[rB(ctx->opcode)]); \ - gen_helper_##name(tcg_ctx, cpu_crf[crfD(ctx->opcode)], tcg_ctx->cpu_env, t0, t1); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); \ + tcg_gen_trunc_tl_i32(tcg_ctx, t1, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); \ + gen_helper_##name(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], tcg_ctx->cpu_env, t0, t1); \ \ tcg_temp_free_i32(tcg_ctx, t0); \ tcg_temp_free_i32(tcg_ctx, t1); \ @@ -1032,7 +1039,7 @@ static inline void gen_##name(DisasContext *ctx) \ t1 = tcg_temp_new_i64(tcg_ctx); \ gen_load_gpr64(tcg_ctx, t0, rA(ctx->opcode)); \ gen_load_gpr64(tcg_ctx, t1, rB(ctx->opcode)); \ - gen_helper_##name(tcg_ctx, cpu_crf[crfD(ctx->opcode)], tcg_ctx->cpu_env, t0, t1); \ + gen_helper_##name(tcg_ctx, tcg_ctx->cpu_crf[crfD(ctx->opcode)], tcg_ctx->cpu_env, t0, t1); \ tcg_temp_free_i64(tcg_ctx, t0); \ tcg_temp_free_i64(tcg_ctx, t1); \ } @@ -1050,9 +1057,9 @@ static inline void gen_evfsabs(DisasContext *ctx) gen_exception(ctx, POWERPC_EXCP_SPEU); return; } - tcg_gen_andi_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], ~0x80000000); - tcg_gen_andi_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)], + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rA(ctx->opcode)], ~0x80000000); } @@ -1063,9 +1070,9 @@ static inline void gen_evfsnabs(DisasContext *ctx) gen_exception(ctx, POWERPC_EXCP_SPEU); return; } - tcg_gen_ori_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], + tcg_gen_ori_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], 0x80000000); - tcg_gen_ori_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)], + tcg_gen_ori_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rA(ctx->opcode)], 0x80000000); } @@ -1076,9 +1083,9 @@ static inline void gen_evfsneg(DisasContext *ctx) gen_exception(ctx, POWERPC_EXCP_SPEU); return; } - tcg_gen_xori_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], + tcg_gen_xori_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], 0x80000000); - tcg_gen_xori_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)], + tcg_gen_xori_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rA(ctx->opcode)], 0x80000000); } @@ -1131,7 +1138,7 @@ static inline void gen_efsabs(DisasContext *ctx) gen_exception(ctx, POWERPC_EXCP_SPEU); return; } - tcg_gen_andi_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], (target_long)~0x80000000LL); } @@ -1142,7 +1149,7 @@ static inline void gen_efsnabs(DisasContext *ctx) gen_exception(ctx, POWERPC_EXCP_SPEU); return; } - tcg_gen_ori_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], + tcg_gen_ori_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], 0x80000000); } @@ -1153,7 +1160,7 @@ static inline void gen_efsneg(DisasContext *ctx) gen_exception(ctx, POWERPC_EXCP_SPEU); return; } - tcg_gen_xori_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], + tcg_gen_xori_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], 0x80000000); } @@ -1207,8 +1214,8 @@ static inline void gen_efdabs(DisasContext *ctx) gen_exception(ctx, POWERPC_EXCP_SPEU); return; } - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - tcg_gen_andi_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)], + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_andi_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rA(ctx->opcode)], ~0x80000000); } @@ -1219,8 +1226,8 @@ static inline void gen_efdnabs(DisasContext *ctx) gen_exception(ctx, POWERPC_EXCP_SPEU); return; } - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - tcg_gen_ori_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)], + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_ori_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rA(ctx->opcode)], 0x80000000); } @@ -1231,8 +1238,8 @@ static inline void gen_efdneg(DisasContext *ctx) gen_exception(ctx, POWERPC_EXCP_SPEU); return; } - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - tcg_gen_xori_tl(tcg_ctx, cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)], + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)]); + tcg_gen_xori_tl(tcg_ctx, tcg_ctx->cpu_gprh[rD(ctx->opcode)], tcg_ctx->cpu_gprh[rA(ctx->opcode)], 0x80000000); } diff --git a/qemu/target/ppc/translate/vmx-impl.inc.c b/qemu/target/ppc/translate/vmx-impl.inc.c index 9d4211dd6e..f64f4c6d51 100644 --- a/qemu/target/ppc/translate/vmx-impl.inc.c +++ b/qemu/target/ppc/translate/vmx-impl.inc.c @@ -411,7 +411,7 @@ static void glue(gen_, name)(DisasContext *ctx) \ return; \ } \ rb = gen_avr_ptr(tcg_ctx, rB(ctx->opcode)); \ - gen_helper_##name(tcg_ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], rb); \ + gen_helper_##name(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], tcg_ctx->cpu_gpr[rA(ctx->opcode)], rb); \ tcg_temp_free_ptr(tcg_ctx, rb); \ } @@ -1134,7 +1134,7 @@ static void glue(gen_, name)(DisasContext *ctx) \ return; \ } \ rb = gen_avr_ptr(tcg_ctx, rB(ctx->opcode)); \ - gen_helper_##name(tcg_ctx, cpu_gpr[rD(ctx->opcode)], rb); \ + gen_helper_##name(tcg_ctx, tcg_ctx->cpu_gpr[rD(ctx->opcode)], rb); \ tcg_temp_free_ptr(tcg_ctx, rb); \ } GEN_VXFORM_NOA(vupkhsb, 7, 8); @@ -1401,7 +1401,7 @@ static void gen_##op(DisasContext *ctx) \ \ ps = tcg_const_i32(tcg_ctx, (ctx->opcode & 0x200) != 0); \ \ - gen_helper_##op(tcg_ctx, cpu_crf[6], rd, ra, rb, ps); \ + gen_helper_##op(tcg_ctx, tcg_ctx->cpu_crf[6], rd, ra, rb, ps); \ \ tcg_temp_free_ptr(tcg_ctx, ra); \ tcg_temp_free_ptr(tcg_ctx, rb); \ @@ -1426,7 +1426,7 @@ static void gen_##op(DisasContext *ctx) \ \ ps = tcg_const_i32(tcg_ctx, (ctx->opcode & 0x200) != 0); \ \ - gen_helper_##op(tcg_ctx, cpu_crf[6], rd, rb, ps); \ + gen_helper_##op(tcg_ctx, tcg_ctx->cpu_crf[6], rd, rb, ps); \ \ tcg_temp_free_ptr(tcg_ctx, rb); \ tcg_temp_free_ptr(tcg_ctx, rd); \ diff --git a/qemu/target/ppc/translate/vsx-impl.inc.c b/qemu/target/ppc/translate/vsx-impl.inc.c index 679da14902..1a28e6c70f 100644 --- a/qemu/target/ppc/translate/vsx-impl.inc.c +++ b/qemu/target/ppc/translate/vsx-impl.inc.c @@ -375,7 +375,7 @@ static void gen_##name(DisasContext *ctx) \ xt = gen_vsr_ptr(tcg_ctx, xT(ctx->opcode)); \ gen_set_access_type(ctx, ACCESS_INT); \ gen_addr_register(ctx, EA); \ - gen_helper_##name(tcg_ctx, tcg_ctx->cpu_env, EA, xt, cpu_gpr[rB(ctx->opcode)]); \ + gen_helper_##name(tcg_ctx, tcg_ctx->cpu_env, EA, xt, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); \ tcg_temp_free(tcg_ctx, EA); \ tcg_temp_free_ptr(tcg_ctx, xt); \ } @@ -608,7 +608,7 @@ static void gen_mfvsrwz(DisasContext *ctx) TCGv_i64 xsh = tcg_temp_new_i64(tcg_ctx); get_cpu_vsrh(tcg_ctx, xsh, xS(ctx->opcode)); tcg_gen_ext32u_i64(tcg_ctx, tmp, xsh); - tcg_gen_trunc_i64_tl(tcg_ctx, cpu_gpr[rA(ctx->opcode)], tmp); + tcg_gen_trunc_i64_tl(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], tmp); tcg_temp_free_i64(tcg_ctx, tmp); tcg_temp_free_i64(tcg_ctx, xsh); } @@ -629,7 +629,7 @@ static void gen_mtvsrwa(DisasContext *ctx) } TCGv_i64 tmp = tcg_temp_new_i64(tcg_ctx); TCGv_i64 xsh = tcg_temp_new_i64(tcg_ctx); - tcg_gen_extu_tl_i64(tcg_ctx, tmp, cpu_gpr[rA(ctx->opcode)]); + tcg_gen_extu_tl_i64(tcg_ctx, tmp, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); tcg_gen_ext32s_i64(tcg_ctx, xsh, tmp); set_cpu_vsrh(tcg_ctx, xT(ctx->opcode), xsh); tcg_temp_free_i64(tcg_ctx, tmp); @@ -652,7 +652,7 @@ static void gen_mtvsrwz(DisasContext *ctx) } TCGv_i64 tmp = tcg_temp_new_i64(tcg_ctx); TCGv_i64 xsh = tcg_temp_new_i64(tcg_ctx); - tcg_gen_extu_tl_i64(tcg_ctx, tmp, cpu_gpr[rA(ctx->opcode)]); + tcg_gen_extu_tl_i64(tcg_ctx, tmp, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); tcg_gen_ext32u_i64(tcg_ctx, xsh, tmp); set_cpu_vsrh(tcg_ctx, xT(ctx->opcode), xsh); tcg_temp_free_i64(tcg_ctx, tmp); @@ -677,7 +677,7 @@ static void gen_mfvsrd(DisasContext *ctx) } t0 = tcg_temp_new_i64(tcg_ctx); get_cpu_vsrh(tcg_ctx, t0, xS(ctx->opcode)); - tcg_gen_mov_i64(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0); + tcg_gen_mov_i64(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0); tcg_temp_free_i64(tcg_ctx, t0); } @@ -697,7 +697,7 @@ static void gen_mtvsrd(DisasContext *ctx) } } t0 = tcg_temp_new_i64(tcg_ctx); - tcg_gen_mov_i64(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); + tcg_gen_mov_i64(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); set_cpu_vsrh(tcg_ctx, xT(ctx->opcode), t0); tcg_temp_free_i64(tcg_ctx, t0); } @@ -719,7 +719,7 @@ static void gen_mfvsrld(DisasContext *ctx) } t0 = tcg_temp_new_i64(tcg_ctx); get_cpu_vsrl(tcg_ctx, t0, xS(ctx->opcode)); - tcg_gen_mov_i64(tcg_ctx, cpu_gpr[rA(ctx->opcode)], t0); + tcg_gen_mov_i64(tcg_ctx, tcg_ctx->cpu_gpr[rA(ctx->opcode)], t0); tcg_temp_free_i64(tcg_ctx, t0); } @@ -743,11 +743,11 @@ static void gen_mtvsrdd(DisasContext *ctx) if (!rA(ctx->opcode)) { tcg_gen_movi_i64(tcg_ctx, t0, 0); } else { - tcg_gen_mov_i64(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)]); + tcg_gen_mov_i64(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)]); } set_cpu_vsrh(tcg_ctx, xT(ctx->opcode), t0); - tcg_gen_mov_i64(tcg_ctx, t0, cpu_gpr[rB(ctx->opcode)]); + tcg_gen_mov_i64(tcg_ctx, t0, tcg_ctx->cpu_gpr[rB(ctx->opcode)]); set_cpu_vsrl(tcg_ctx, xT(ctx->opcode), t0); tcg_temp_free_i64(tcg_ctx, t0); } @@ -769,8 +769,8 @@ static void gen_mtvsrws(DisasContext *ctx) } t0 = tcg_temp_new_i64(tcg_ctx); - tcg_gen_deposit_i64(tcg_ctx, t0, cpu_gpr[rA(ctx->opcode)], - cpu_gpr[rA(ctx->opcode)], 32, 32); + tcg_gen_deposit_i64(tcg_ctx, t0, tcg_ctx->cpu_gpr[rA(ctx->opcode)], + tcg_ctx->cpu_gpr[rA(ctx->opcode)], 32, 32); set_cpu_vsrl(tcg_ctx, xT(ctx->opcode), t0); set_cpu_vsrh(tcg_ctx, xT(ctx->opcode), t0); tcg_temp_free_i64(tcg_ctx, t0); @@ -1009,7 +1009,7 @@ static void gen_##name(DisasContext *ctx) \ xa = gen_vsr_ptr(tcg_ctx, xA(ctx->opcode)); \ xb = gen_vsr_ptr(tcg_ctx, xB(ctx->opcode)); \ if ((ctx->opcode >> (31 - 21)) & 1) { \ - gen_helper_##name(tcg_ctx, cpu_crf[6], tcg_ctx->cpu_env, xt, xa, xb); \ + gen_helper_##name(tcg_ctx, tcg_ctx->cpu_crf[6], tcg_ctx->cpu_env, xt, xa, xb); \ } else { \ ignored = tcg_temp_new_i32(tcg_ctx); \ gen_helper_##name(tcg_ctx, ignored, tcg_ctx->cpu_env, xt, xa, xb); \ @@ -1735,7 +1735,7 @@ VSX_EXTRACT_INSERT(xxinsertw) static void gen_xsxexpdp(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv rt = cpu_gpr[rD(ctx->opcode)]; + TCGv rt = tcg_ctx->cpu_gpr[rD(ctx->opcode)]; TCGv_i64 t0; if (unlikely(!ctx->vsx_enabled)) { gen_exception(ctx, POWERPC_EXCP_VSXU); @@ -1777,8 +1777,8 @@ static void gen_xsiexpdp(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i64 xth; - TCGv ra = cpu_gpr[rA(ctx->opcode)]; - TCGv rb = cpu_gpr[rB(ctx->opcode)]; + TCGv ra = tcg_ctx->cpu_gpr[rA(ctx->opcode)]; + TCGv rb = tcg_ctx->cpu_gpr[rB(ctx->opcode)]; TCGv_i64 t0; if (unlikely(!ctx->vsx_enabled)) { @@ -1840,7 +1840,7 @@ static void gen_xsiexpqp(DisasContext *ctx) static void gen_xsxsigdp(DisasContext *ctx) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - TCGv rt = cpu_gpr[rD(ctx->opcode)]; + TCGv rt = tcg_ctx->cpu_gpr[rD(ctx->opcode)]; TCGv_i64 t0, t1, zr, nan, exp; if (unlikely(!ctx->vsx_enabled)) { diff --git a/qemu/target/ppc/translate_init.inc.c b/qemu/target/ppc/translate_init.inc.c index d2fb1974ad..40b1074e27 100644 --- a/qemu/target/ppc/translate_init.inc.c +++ b/qemu/target/ppc/translate_init.inc.c @@ -44,13 +44,14 @@ static void spr_load_dump_spr(TCGContext *tcg_ctx, int sprn) static void spr_read_generic(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_load_spr(tcg_ctx, cpu_gpr[gprn], sprn); + gen_load_spr(tcg_ctx, tcg_ctx->cpu_gpr[gprn], sprn); spr_load_dump_spr(tcg_ctx, sprn); } static void spr_store_dump_spr(int sprn) { #ifdef PPC_DUMP_SPR_ACCESSES + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, sprn); gen_helper_store_dump_spr(tcg_ctx, tcg_ctx->cpu_env, t0); tcg_temp_free_i32(tcg_ctx, t0); @@ -60,7 +61,7 @@ static void spr_store_dump_spr(int sprn) static void spr_write_generic(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_store_spr(tcg_ctx, sprn, cpu_gpr[gprn]); + gen_store_spr(tcg_ctx, sprn, tcg_ctx->cpu_gpr[gprn]); spr_store_dump_spr(sprn); } @@ -69,7 +70,7 @@ static void spr_write_generic32(DisasContext *ctx, int sprn, int gprn) #ifdef TARGET_PPC64 TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); - tcg_gen_ext32u_tl(tcg_ctx, t0, cpu_gpr[gprn]); + tcg_gen_ext32u_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[gprn]); gen_store_spr(tcg_ctx, sprn, t0); tcg_temp_free(tcg_ctx, t0); spr_store_dump_spr(sprn); @@ -84,7 +85,7 @@ static void spr_write_clear(DisasContext *ctx, int sprn, int gprn) TCGv t0 = tcg_temp_new(tcg_ctx); TCGv t1 = tcg_temp_new(tcg_ctx); gen_load_spr(tcg_ctx, t0, sprn); - tcg_gen_neg_tl(tcg_ctx, t1, cpu_gpr[gprn]); + tcg_gen_neg_tl(tcg_ctx, t1, tcg_ctx->cpu_gpr[gprn]); tcg_gen_and_tl(tcg_ctx, t0, t0, t1); gen_store_spr(tcg_ctx, sprn, t0); tcg_temp_free(tcg_ctx, t0); @@ -99,26 +100,27 @@ static void spr_access_nop(DisasContext *ctx, int sprn, int gprn) /* XER */ static void spr_read_xer(DisasContext *ctx, int gprn, int sprn) { - gen_read_xer(ctx, cpu_gpr[gprn]); + TCGContext *tcg_ctx = ctx->uc->tcg_ctx; + gen_read_xer(ctx, tcg_ctx->cpu_gpr[gprn]); } static void spr_write_xer(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_write_xer(tcg_ctx, cpu_gpr[gprn]); + gen_write_xer(tcg_ctx, tcg_ctx->cpu_gpr[gprn]); } /* LR */ static void spr_read_lr(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[gprn], cpu_lr); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_lr); } static void spr_write_lr(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_mov_tl(tcg_ctx, cpu_lr, cpu_gpr[gprn]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_lr, tcg_ctx->cpu_gpr[gprn]); } /* CFAR */ @@ -126,13 +128,13 @@ static void spr_write_lr(DisasContext *ctx, int sprn, int gprn) static void spr_read_cfar(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[gprn], cpu_cfar); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_cfar); } static void spr_write_cfar(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_mov_tl(tcg_ctx, cpu_cfar, cpu_gpr[gprn]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_cfar, tcg_ctx->cpu_gpr[gprn]); } #endif @@ -140,13 +142,13 @@ static void spr_write_cfar(DisasContext *ctx, int sprn, int gprn) static void spr_read_ctr(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_mov_tl(tcg_ctx, cpu_gpr[gprn], cpu_ctr); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_ctr); } static void spr_write_ctr(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_mov_tl(tcg_ctx, cpu_ctr, cpu_gpr[gprn]); + tcg_gen_mov_tl(tcg_ctx, tcg_ctx->cpu_ctr, tcg_ctx->cpu_gpr[gprn]); } /* User read access to SPR */ @@ -158,14 +160,14 @@ static void spr_write_ctr(DisasContext *ctx, int sprn, int gprn) static void spr_read_ureg(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_load_spr(tcg_ctx, cpu_gpr[gprn], sprn + 0x10); + gen_load_spr(tcg_ctx, tcg_ctx->cpu_gpr[gprn], sprn + 0x10); } #if defined(TARGET_PPC64) static void spr_write_ureg(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_store_spr(tcg_ctx, sprn + 0x10, cpu_gpr[gprn]); + gen_store_spr(tcg_ctx, sprn + 0x10, tcg_ctx->cpu_gpr[gprn]); } #endif @@ -178,7 +180,7 @@ static void spr_read_decr(DisasContext *ctx, int gprn, int sprn) if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(tcg_ctx); } - gen_helper_load_decr(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env); + gen_helper_load_decr(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env); if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_stop_exception(ctx); } @@ -194,7 +196,7 @@ static void spr_write_decr(DisasContext *ctx, int sprn, int gprn) if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(tcg_ctx); } - gen_helper_store_decr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_decr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_stop_exception(ctx); } @@ -212,7 +214,7 @@ static void spr_read_tbl(DisasContext *ctx, int gprn, int sprn) if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(tcg_ctx); } - gen_helper_load_tbl(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env); + gen_helper_load_tbl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env); if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_end(tcg_ctx); gen_stop_exception(ctx); @@ -229,7 +231,7 @@ static void spr_read_tbu(DisasContext *ctx, int gprn, int sprn) if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(tcg_ctx); } - gen_helper_load_tbu(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env); + gen_helper_load_tbu(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env); if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_end(tcg_ctx); gen_stop_exception(ctx); @@ -244,14 +246,14 @@ static void spr_read_tbu(DisasContext *ctx, int gprn, int sprn) static void spr_read_atbl(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_load_atbl(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env); + gen_helper_load_atbl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env); } // ATTRIBUTE_UNUSED static void spr_read_atbu(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_load_atbu(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env); + gen_helper_load_atbu(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env); } #endif @@ -262,7 +264,7 @@ static void spr_write_tbl(DisasContext *ctx, int sprn, int gprn) if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(tcg_ctx); } - gen_helper_store_tbl(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_tbl(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_end(tcg_ctx); gen_stop_exception(ctx); @@ -280,7 +282,7 @@ static void spr_write_tbu(DisasContext *ctx, int sprn, int gprn) if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(tcg_ctx); } - gen_helper_store_tbu(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_tbu(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_end(tcg_ctx); gen_stop_exception(ctx); @@ -295,14 +297,14 @@ static void spr_write_tbu(DisasContext *ctx, int sprn, int gprn) static void spr_write_atbl(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_atbl(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_atbl(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } // ATTRIBUTE_UNUSED static void spr_write_atbu(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_atbu(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_atbu(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } #endif @@ -311,13 +313,13 @@ static void spr_write_atbu(DisasContext *ctx, int sprn, int gprn) static void spr_read_purr(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_load_purr(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env); + gen_helper_load_purr(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env); } static void spr_write_purr(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_purr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_purr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } /* HDECR */ @@ -327,7 +329,7 @@ static void spr_read_hdecr(DisasContext *ctx, int gprn, int sprn) if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(tcg_ctx); } - gen_helper_load_hdecr(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env); + gen_helper_load_hdecr(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env); if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_end(tcg_ctx); gen_stop_exception(ctx); @@ -340,7 +342,7 @@ static void spr_write_hdecr(DisasContext *ctx, int sprn, int gprn) if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(tcg_ctx); } - gen_helper_store_hdecr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_hdecr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_end(tcg_ctx); gen_stop_exception(ctx); @@ -350,19 +352,19 @@ static void spr_write_hdecr(DisasContext *ctx, int sprn, int gprn) static void spr_read_vtb(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_load_vtb(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env); + gen_helper_load_vtb(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env); } static void spr_write_vtb(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_vtb(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_vtb(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } static void spr_write_tbu40(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_tbu40(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_tbu40(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } #endif @@ -372,7 +374,7 @@ static void spr_write_tbu40(DisasContext *ctx, int sprn, int gprn) static void spr_read_ibat(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_ld_tl(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env, + tcg_gen_ld_tl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env, offsetof(CPUPPCState, IBAT[sprn & 1][(sprn - SPR_IBAT0U) / 2])); } @@ -380,7 +382,7 @@ static void spr_read_ibat(DisasContext *ctx, int gprn, int sprn) static void spr_read_ibat_h(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_ld_tl(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env, + tcg_gen_ld_tl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env, offsetof(CPUPPCState, IBAT[sprn & 1][((sprn - SPR_IBAT4U) / 2) + 4])); } @@ -389,7 +391,7 @@ static void spr_write_ibatu(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, (sprn - SPR_IBAT0U) / 2); - gen_helper_store_ibatu(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[gprn]); + gen_helper_store_ibatu(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[gprn]); tcg_temp_free_i32(tcg_ctx, t0); } @@ -397,7 +399,7 @@ static void spr_write_ibatu_h(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, ((sprn - SPR_IBAT4U) / 2) + 4); - gen_helper_store_ibatu(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[gprn]); + gen_helper_store_ibatu(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[gprn]); tcg_temp_free_i32(tcg_ctx, t0); } @@ -405,7 +407,7 @@ static void spr_write_ibatl(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, (sprn - SPR_IBAT0L) / 2); - gen_helper_store_ibatl(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[gprn]); + gen_helper_store_ibatl(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[gprn]); tcg_temp_free_i32(tcg_ctx, t0); } @@ -413,7 +415,7 @@ static void spr_write_ibatl_h(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, ((sprn - SPR_IBAT4L) / 2) + 4); - gen_helper_store_ibatl(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[gprn]); + gen_helper_store_ibatl(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[gprn]); tcg_temp_free_i32(tcg_ctx, t0); } @@ -422,7 +424,7 @@ static void spr_write_ibatl_h(DisasContext *ctx, int sprn, int gprn) static void spr_read_dbat(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_ld_tl(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env, + tcg_gen_ld_tl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env, offsetof(CPUPPCState, DBAT[sprn & 1][(sprn - SPR_DBAT0U) / 2])); } @@ -430,7 +432,7 @@ static void spr_read_dbat(DisasContext *ctx, int gprn, int sprn) static void spr_read_dbat_h(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_ld_tl(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env, + tcg_gen_ld_tl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env, offsetof(CPUPPCState, DBAT[sprn & 1][((sprn - SPR_DBAT4U) / 2) + 4])); } @@ -439,7 +441,7 @@ static void spr_write_dbatu(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, (sprn - SPR_DBAT0U) / 2); - gen_helper_store_dbatu(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[gprn]); + gen_helper_store_dbatu(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[gprn]); tcg_temp_free_i32(tcg_ctx, t0); } @@ -447,7 +449,7 @@ static void spr_write_dbatu_h(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, ((sprn - SPR_DBAT4U) / 2) + 4); - gen_helper_store_dbatu(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[gprn]); + gen_helper_store_dbatu(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[gprn]); tcg_temp_free_i32(tcg_ctx, t0); } @@ -455,7 +457,7 @@ static void spr_write_dbatl(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, (sprn - SPR_DBAT0L) / 2); - gen_helper_store_dbatl(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[gprn]); + gen_helper_store_dbatl(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[gprn]); tcg_temp_free_i32(tcg_ctx, t0); } @@ -463,7 +465,7 @@ static void spr_write_dbatl_h(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, ((sprn - SPR_DBAT4L) / 2) + 4); - gen_helper_store_dbatl(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[gprn]); + gen_helper_store_dbatl(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[gprn]); tcg_temp_free_i32(tcg_ctx, t0); } @@ -471,7 +473,7 @@ static void spr_write_dbatl_h(DisasContext *ctx, int sprn, int gprn) static void spr_write_sdr1(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_sdr1(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_sdr1(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } #if defined(TARGET_PPC64) @@ -480,52 +482,52 @@ static void spr_write_sdr1(DisasContext *ctx, int sprn, int gprn) static void spr_write_pidr(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_pidr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_pidr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } static void spr_write_lpidr(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_lpidr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_lpidr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } static void spr_read_hior(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_ld_tl(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env, offsetof(CPUPPCState, excp_prefix)); + tcg_gen_ld_tl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env, offsetof(CPUPPCState, excp_prefix)); } static void spr_write_hior(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[gprn], 0x3FFFFF00000ULL); + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[gprn], 0x3FFFFF00000ULL); tcg_gen_st_tl(tcg_ctx, t0, tcg_ctx->cpu_env, offsetof(CPUPPCState, excp_prefix)); tcg_temp_free(tcg_ctx, t0); } static void spr_write_ptcr(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_ptcr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_ptcr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } static void spr_write_pcr(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_pcr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_pcr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } /* DPDES */ static void spr_read_dpdes(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_load_dpdes(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env); + gen_helper_load_dpdes(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env); } static void spr_write_dpdes(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_dpdes(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_dpdes(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } #endif @@ -534,31 +536,31 @@ static void spr_write_dpdes(DisasContext *ctx, int sprn, int gprn) static void spr_read_601_rtcl(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_load_601_rtcl(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env); + gen_helper_load_601_rtcl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env); } static void spr_read_601_rtcu(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_load_601_rtcu(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env); + gen_helper_load_601_rtcu(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env); } static void spr_write_601_rtcu(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_601_rtcu(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_601_rtcu(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } static void spr_write_601_rtcl(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_601_rtcl(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_601_rtcl(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } static void spr_write_hid0_601(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_hid0_601(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_hid0_601(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); /* Must stop the translation as endianness may have changed */ gen_stop_exception(ctx); } @@ -567,7 +569,7 @@ static void spr_write_hid0_601(DisasContext *ctx, int sprn, int gprn) static void spr_read_601_ubat(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_ld_tl(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env, + tcg_gen_ld_tl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env, offsetof(CPUPPCState, IBAT[sprn & 1][(sprn - SPR_IBAT0U) / 2])); } @@ -576,7 +578,7 @@ static void spr_write_601_ubatu(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, (sprn - SPR_IBAT0U) / 2); - gen_helper_store_601_batl(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[gprn]); + gen_helper_store_601_batl(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[gprn]); tcg_temp_free_i32(tcg_ctx, t0); } @@ -584,7 +586,7 @@ static void spr_write_601_ubatl(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, (sprn - SPR_IBAT0U) / 2); - gen_helper_store_601_batu(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[gprn]); + gen_helper_store_601_batu(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[gprn]); tcg_temp_free_i32(tcg_ctx, t0); } @@ -593,9 +595,9 @@ static void spr_read_40x_pit(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; #ifdef UNICORN_ARCH_POSTFIX - glue(gen_helper_load_40x_pit, UNICORN_ARCH_POSTFIX)(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env); + glue(gen_helper_load_40x_pit, UNICORN_ARCH_POSTFIX)(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env); #else - gen_helper_load_40x_pit(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env); + gen_helper_load_40x_pit(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env); #endif } @@ -603,20 +605,20 @@ static void spr_write_40x_pit(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; #ifdef UNICORN_ARCH_POSTFIX - glue(gen_helper_store_40x_pit, UNICORN_ARCH_POSTFIX)(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + glue(gen_helper_store_40x_pit, UNICORN_ARCH_POSTFIX)(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); #else - gen_helper_store_40x_pit(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_40x_pit(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); #endif } static void spr_write_40x_dbcr0(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_store_spr(tcg_ctx, sprn, cpu_gpr[gprn]); + gen_store_spr(tcg_ctx, sprn, tcg_ctx->cpu_gpr[gprn]); #ifdef UNICORN_ARCH_POSTFIX - glue(gen_helper_store_40x_dbcr0, UNICORN_ARCH_POSTFIX)(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + glue(gen_helper_store_40x_dbcr0, UNICORN_ARCH_POSTFIX)(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); #else - gen_helper_store_40x_dbcr0(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_40x_dbcr0(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); #endif /* We must stop translation as we may have rebooted */ gen_stop_exception(ctx); @@ -626,22 +628,22 @@ static void spr_write_40x_sler(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; #ifdef UNICORN_ARCH_POSTFIX - glue(gen_helper_store_40x_sler, UNICORN_ARCH_POSTFIX)(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + glue(gen_helper_store_40x_sler, UNICORN_ARCH_POSTFIX)(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); #else - gen_helper_store_40x_sler(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_40x_sler(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); #endif } static void spr_write_booke_tcr(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_booke_tcr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_booke_tcr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } static void spr_write_booke_tsr(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_booke_tsr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_booke_tsr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } /* PowerPC 403 specific registers */ @@ -649,7 +651,7 @@ static void spr_write_booke_tsr(DisasContext *ctx, int sprn, int gprn) static void spr_read_403_pbr(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - tcg_gen_ld_tl(tcg_ctx, cpu_gpr[gprn], tcg_ctx->cpu_env, + tcg_gen_ld_tl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], tcg_ctx->cpu_env, offsetof(CPUPPCState, pb[sprn - SPR_403_PBL1])); } @@ -657,7 +659,7 @@ static void spr_write_403_pbr(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, sprn - SPR_403_PBL1); - gen_helper_store_403_pbr(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[gprn]); + gen_helper_store_403_pbr(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[gprn]); tcg_temp_free_i32(tcg_ctx, t0); } @@ -665,7 +667,7 @@ static void spr_write_pir(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[gprn], 0xF); + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[gprn], 0xF); gen_store_spr(tcg_ctx, SPR_PIR, t0); tcg_temp_free(tcg_ctx, t0); } @@ -676,7 +678,7 @@ static void spr_read_spefscr(DisasContext *ctx, int gprn, int sprn) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_temp_new_i32(tcg_ctx); tcg_gen_ld_i32(tcg_ctx, t0, tcg_ctx->cpu_env, offsetof(CPUPPCState, spe_fscr)); - tcg_gen_extu_i32_tl(tcg_ctx, cpu_gpr[gprn], t0); + tcg_gen_extu_i32_tl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], t0); tcg_temp_free_i32(tcg_ctx, t0); } @@ -684,7 +686,7 @@ static void spr_write_spefscr(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_temp_new_i32(tcg_ctx); - tcg_gen_trunc_tl_i32(tcg_ctx, t0, cpu_gpr[gprn]); + tcg_gen_trunc_tl_i32(tcg_ctx, t0, tcg_ctx->cpu_gpr[gprn]); tcg_gen_st_i32(tcg_ctx, t0, tcg_ctx->cpu_env, offsetof(CPUPPCState, spe_fscr)); tcg_temp_free_i32(tcg_ctx, t0); } @@ -695,7 +697,7 @@ static void spr_write_excp_prefix(DisasContext *ctx, int sprn, int gprn) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); tcg_gen_ld_tl(tcg_ctx, t0, tcg_ctx->cpu_env, offsetof(CPUPPCState, ivpr_mask)); - tcg_gen_and_tl(tcg_ctx, t0, t0, cpu_gpr[gprn]); + tcg_gen_and_tl(tcg_ctx, t0, t0, tcg_ctx->cpu_gpr[gprn]); tcg_gen_st_tl(tcg_ctx, t0, tcg_ctx->cpu_env, offsetof(CPUPPCState, excp_prefix)); gen_store_spr(tcg_ctx, sprn, t0); tcg_temp_free(tcg_ctx, t0); @@ -721,7 +723,7 @@ static void spr_write_excp_vector(DisasContext *ctx, int sprn, int gprn) TCGv t0 = tcg_temp_new(tcg_ctx); tcg_gen_ld_tl(tcg_ctx, t0, tcg_ctx->cpu_env, offsetof(CPUPPCState, ivor_mask)); - tcg_gen_and_tl(tcg_ctx, t0, t0, cpu_gpr[gprn]); + tcg_gen_and_tl(tcg_ctx, t0, t0, tcg_ctx->cpu_gpr[gprn]); tcg_gen_st_tl(tcg_ctx, t0, tcg_ctx->cpu_env, offsetof(CPUPPCState, excp_vectors[sprn_offs])); gen_store_spr(tcg_ctx, sprn, t0); tcg_temp_free(tcg_ctx, t0); @@ -1226,7 +1228,7 @@ static void spr_write_amr(DisasContext *ctx, int sprn, int gprn) } /* Mask new bits into t2 */ - tcg_gen_and_tl(tcg_ctx, t2, t1, cpu_gpr[gprn]); + tcg_gen_and_tl(tcg_ctx, t2, t1, tcg_ctx->cpu_gpr[gprn]); /* Load AMR and clear new bits in t0 */ gen_load_spr(tcg_ctx, t0, SPR_AMR); @@ -1258,7 +1260,7 @@ static void spr_write_uamor(DisasContext *ctx, int sprn, int gprn) gen_load_spr(tcg_ctx, t1, SPR_AMOR); /* Mask new bits into t2 */ - tcg_gen_and_tl(tcg_ctx, t2, t1, cpu_gpr[gprn]); + tcg_gen_and_tl(tcg_ctx, t2, t1, tcg_ctx->cpu_gpr[gprn]); /* Load AMR and clear new bits in t0 */ gen_load_spr(tcg_ctx, t0, SPR_UAMOR); @@ -1290,7 +1292,7 @@ static void spr_write_iamr(DisasContext *ctx, int sprn, int gprn) gen_load_spr(tcg_ctx, t1, SPR_AMOR); /* Mask new bits into t2 */ - tcg_gen_and_tl(tcg_ctx, t2, t1, cpu_gpr[gprn]); + tcg_gen_and_tl(tcg_ctx, t2, t1, tcg_ctx->cpu_gpr[gprn]); /* Load AMR and clear new bits in t0 */ gen_load_spr(tcg_ctx, t0, SPR_IAMR); @@ -1350,7 +1352,7 @@ static void spr_read_thrm(DisasContext *ctx, int gprn, int sprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; gen_helper_fixup_thrm(tcg_ctx, tcg_ctx->cpu_env); - gen_load_spr(tcg_ctx, cpu_gpr[gprn], sprn); + gen_load_spr(tcg_ctx, tcg_ctx->cpu_gpr[gprn], sprn); spr_load_dump_spr(tcg_ctx, sprn); } @@ -1720,7 +1722,7 @@ static void spr_write_e500_l1csr0(DisasContext *ctx, int sprn, int gprn) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[gprn], L1CSR0_DCE | L1CSR0_CPE); + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[gprn], L1CSR0_DCE | L1CSR0_CPE); gen_store_spr(tcg_ctx, sprn, t0); tcg_temp_free(tcg_ctx, t0); } @@ -1730,7 +1732,7 @@ static void spr_write_e500_l1csr1(DisasContext *ctx, int sprn, int gprn) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv t0 = tcg_temp_new(tcg_ctx); - tcg_gen_andi_tl(tcg_ctx, t0, cpu_gpr[gprn], L1CSR1_ICE | L1CSR1_CPE); + tcg_gen_andi_tl(tcg_ctx, t0, tcg_ctx->cpu_gpr[gprn], L1CSR1_ICE | L1CSR1_CPE); gen_store_spr(tcg_ctx, sprn, t0); tcg_temp_free(tcg_ctx, t0); } @@ -1738,27 +1740,27 @@ static void spr_write_e500_l1csr1(DisasContext *ctx, int sprn, int gprn) static void spr_write_booke206_mmucsr0(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_booke206_tlbflush(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_booke206_tlbflush(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } static void spr_write_booke_pid(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv_i32 t0 = tcg_const_i32(tcg_ctx, sprn); - gen_helper_booke_setpid(tcg_ctx, tcg_ctx->cpu_env, t0, cpu_gpr[gprn]); + gen_helper_booke_setpid(tcg_ctx, tcg_ctx->cpu_env, t0, tcg_ctx->cpu_gpr[gprn]); tcg_temp_free_i32(tcg_ctx, t0); } static void spr_write_eplc(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_booke_set_eplc(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_booke_set_eplc(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } static void spr_write_epsc(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_booke_set_epsc(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_booke_set_epsc(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } static void gen_spr_usprg3(CPUPPCState *env) @@ -4752,9 +4754,9 @@ static void spr_write_mas73(DisasContext *ctx, int sprn, int gprn) TCGContext *tcg_ctx = ctx->uc->tcg_ctx; TCGv val = tcg_temp_new(tcg_ctx); - tcg_gen_ext32u_tl(tcg_ctx, val, cpu_gpr[gprn]); + tcg_gen_ext32u_tl(tcg_ctx, val, tcg_ctx->cpu_gpr[gprn]); gen_store_spr(tcg_ctx, SPR_BOOKE_MAS3, val); - tcg_gen_shri_tl(tcg_ctx, val, cpu_gpr[gprn], 32); + tcg_gen_shri_tl(tcg_ctx, val, tcg_ctx->cpu_gpr[gprn], 32); gen_store_spr(tcg_ctx, SPR_BOOKE_MAS7, val); tcg_temp_free(tcg_ctx, val); } @@ -4768,7 +4770,7 @@ static void spr_read_mas73(DisasContext *ctx, int gprn, int sprn) gen_load_spr(tcg_ctx, mas7, SPR_BOOKE_MAS7); tcg_gen_shli_tl(tcg_ctx, mas7, mas7, 32); gen_load_spr(tcg_ctx, mas3, SPR_BOOKE_MAS3); - tcg_gen_or_tl(tcg_ctx, cpu_gpr[gprn], mas3, mas7); + tcg_gen_or_tl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], mas3, mas7); tcg_temp_free(tcg_ctx, mas3); tcg_temp_free(tcg_ctx, mas7); } @@ -7424,7 +7426,7 @@ static void spr_read_prev_upper32(DisasContext *ctx, int gprn, int sprn) gen_load_spr(tcg_ctx, spr, sprn - 1); tcg_gen_shri_tl(tcg_ctx, spr_up, spr, 32); - tcg_gen_ext32u_tl(tcg_ctx, cpu_gpr[gprn], spr_up); + tcg_gen_ext32u_tl(tcg_ctx, tcg_ctx->cpu_gpr[gprn], spr_up); tcg_temp_free(tcg_ctx, spr); tcg_temp_free(tcg_ctx, spr_up); @@ -7436,7 +7438,7 @@ static void spr_write_prev_upper32(DisasContext *ctx, int sprn, int gprn) TCGv spr = tcg_temp_new(tcg_ctx); gen_load_spr(tcg_ctx, spr, sprn - 1); - tcg_gen_deposit_tl(tcg_ctx, spr, spr, cpu_gpr[gprn], 32, 32); + tcg_gen_deposit_tl(tcg_ctx, spr, spr, tcg_ctx->cpu_gpr[gprn], 32, 32); gen_store_spr(tcg_ctx, sprn - 1, spr); tcg_temp_free(tcg_ctx, spr); @@ -7747,7 +7749,7 @@ static void spr_write_hmer(DisasContext *ctx, int sprn, int gprn) TCGv hmer = tcg_temp_new(tcg_ctx); gen_load_spr(tcg_ctx, hmer, sprn); - tcg_gen_and_tl(tcg_ctx, hmer, cpu_gpr[gprn], hmer); + tcg_gen_and_tl(tcg_ctx, hmer, tcg_ctx->cpu_gpr[gprn], hmer); gen_store_spr(tcg_ctx, sprn, hmer); spr_store_dump_spr(sprn); tcg_temp_free(tcg_ctx, hmer); @@ -7757,7 +7759,7 @@ static void spr_write_lpcr(DisasContext *ctx, int sprn, int gprn) { TCGContext *tcg_ctx = ctx->uc->tcg_ctx; - gen_helper_store_lpcr(tcg_ctx, tcg_ctx->cpu_env, cpu_gpr[gprn]); + gen_helper_store_lpcr(tcg_ctx, tcg_ctx->cpu_env, tcg_ctx->cpu_gpr[gprn]); } static void gen_spr_970_lpar(CPUPPCState *env) diff --git a/qemu/target/ppc/unicorn.c b/qemu/target/ppc/unicorn.c index 2d61500675..053d58cfe1 100644 --- a/qemu/target/ppc/unicorn.c +++ b/qemu/target/ppc/unicorn.c @@ -108,16 +108,10 @@ static void ppc_release(void *ctx) g_free(fast->table); } - for (i = 0; i < 32; i++) { - g_free(tcg_ctx->cpu_gpr[i]); - } - // g_free(tcg_ctx->cpu_PC); g_free(tcg_ctx->btarget); g_free(tcg_ctx->bcond); g_free(tcg_ctx->cpu_dspctrl); - // g_free(tcg_ctx->tb_ctx.tbs); - if (env->nb_tlb != 0) { switch (env->tlb_type) { case TLB_6XX: