/* Include definitions for instructions classes and implementations flags */
//#define DO_SINGLE_STEP
//#define PPC_DEBUG_DISAS
-//#define DEBUG_MEMORY_ACCESSES
//#define DO_PPC_STATISTICS
//#define OPTIMIZE_FPRF_UPDATE
/*** Addressing modes ***/
/* Register indirect with immediate index : EA = (rA|0) + SIMM */
-static always_inline void gen_addr_imm_index (DisasContext *ctx,
+static always_inline void gen_addr_imm_index (TCGv EA,
+ DisasContext *ctx,
target_long maskl)
{
target_long simm = SIMM(ctx->opcode);
simm &= ~maskl;
- if (rA(ctx->opcode) == 0) {
- tcg_gen_movi_tl(cpu_T[0], simm);
- } else {
- tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
- if (likely(simm != 0))
- tcg_gen_addi_tl(cpu_T[0], cpu_T[0], simm);
- }
-#ifdef DEBUG_MEMORY_ACCESSES
- gen_op_print_mem_EA();
-#endif
+ if (rA(ctx->opcode) == 0)
+ tcg_gen_movi_tl(EA, simm);
+ else if (likely(simm != 0))
+ tcg_gen_addi_tl(EA, cpu_gpr[rA(ctx->opcode)], simm);
+ else
+ tcg_gen_mov_tl(EA, cpu_gpr[rA(ctx->opcode)]);
}
-static always_inline void gen_addr_reg_index (DisasContext *ctx)
+static always_inline void gen_addr_reg_index (TCGv EA,
+ DisasContext *ctx)
{
- if (rA(ctx->opcode) == 0) {
- tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rB(ctx->opcode)]);
- } else {
- tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
- tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
- tcg_gen_add_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
- }
-#ifdef DEBUG_MEMORY_ACCESSES
- gen_op_print_mem_EA();
-#endif
+ if (rA(ctx->opcode) == 0)
+ tcg_gen_mov_tl(EA, cpu_gpr[rB(ctx->opcode)]);
+ else
+ tcg_gen_add_tl(EA, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
}
-static always_inline void gen_addr_register (DisasContext *ctx)
+static always_inline void gen_addr_register (TCGv EA,
+ DisasContext *ctx)
{
- if (rA(ctx->opcode) == 0) {
- tcg_gen_movi_tl(cpu_T[0], 0);
- } else {
- tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
- }
-#ifdef DEBUG_MEMORY_ACCESSES
- gen_op_print_mem_EA();
-#endif
+ if (rA(ctx->opcode) == 0)
+ tcg_gen_movi_tl(EA, 0);
+ else
+ tcg_gen_mov_tl(EA, cpu_gpr[rA(ctx->opcode)]);
}
#if defined(TARGET_PPC64)
#define GEN_LD(width, opc, type) \
GEN_HANDLER(l##width, opc, 0xFF, 0xFF, 0x00000000, type) \
{ \
- gen_addr_imm_index(ctx, 0); \
+ gen_addr_imm_index(cpu_T[0], ctx, 0); \
op_ldst(l##width); \
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[1]); \
}
return; \
} \
if (type == PPC_64B) \
- gen_addr_imm_index(ctx, 0x03); \
+ gen_addr_imm_index(cpu_T[0], ctx, 0x03); \
else \
- gen_addr_imm_index(ctx, 0); \
+ gen_addr_imm_index(cpu_T[0], ctx, 0); \
op_ldst(l##width); \
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[1]); \
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
GEN_EXCP_INVAL(ctx); \
return; \
} \
- gen_addr_reg_index(ctx); \
+ gen_addr_reg_index(cpu_T[0], ctx); \
op_ldst(l##width); \
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[1]); \
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
#define GEN_LDX(width, opc2, opc3, type) \
GEN_HANDLER(l##width##x, 0x1F, opc2, opc3, 0x00000001, type) \
{ \
- gen_addr_reg_index(ctx); \
+ gen_addr_reg_index(cpu_T[0], ctx); \
op_ldst(l##width); \
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[1]); \
}
return;
}
}
- gen_addr_imm_index(ctx, 0x03);
+ gen_addr_imm_index(cpu_T[0], ctx, 0x03);
if (ctx->opcode & 0x02) {
/* lwa (lwau is undefined) */
op_ldst(lwa);
GEN_EXCP(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_LE);
return;
}
- gen_addr_imm_index(ctx, 0x0F);
+ gen_addr_imm_index(cpu_T[0], ctx, 0x0F);
op_ldst(ld);
tcg_gen_mov_tl(cpu_gpr[rd], cpu_T[1]);
tcg_gen_addi_tl(cpu_T[0], cpu_T[0], 8);
#define GEN_ST(width, opc, type) \
GEN_HANDLER(st##width, opc, 0xFF, 0xFF, 0x00000000, type) \
{ \
- gen_addr_imm_index(ctx, 0); \
+ gen_addr_imm_index(cpu_T[0], ctx, 0); \
tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]); \
op_ldst(st##width); \
}
return; \
} \
if (type == PPC_64B) \
- gen_addr_imm_index(ctx, 0x03); \
+ gen_addr_imm_index(cpu_T[0], ctx, 0x03); \
else \
- gen_addr_imm_index(ctx, 0); \
+ gen_addr_imm_index(cpu_T[0], ctx, 0); \
tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]); \
op_ldst(st##width); \
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
GEN_EXCP_INVAL(ctx); \
return; \
} \
- gen_addr_reg_index(ctx); \
+ gen_addr_reg_index(cpu_T[0], ctx); \
tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]); \
op_ldst(st##width); \
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
#define GEN_STX(width, opc2, opc3, type) \
GEN_HANDLER(st##width##x, 0x1F, opc2, opc3, 0x00000001, type) \
{ \
- gen_addr_reg_index(ctx); \
+ gen_addr_reg_index(cpu_T[0], ctx); \
tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]); \
op_ldst(st##width); \
}
GEN_EXCP(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_LE);
return;
}
- gen_addr_imm_index(ctx, 0x03);
+ gen_addr_imm_index(cpu_T[0], ctx, 0x03);
tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rs]);
op_ldst(std);
tcg_gen_addi_tl(cpu_T[0], cpu_T[0], 8);
return;
}
}
- gen_addr_imm_index(ctx, 0x03);
+ gen_addr_imm_index(cpu_T[0], ctx, 0x03);
tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rs]);
op_ldst(std);
if (Rc(ctx->opcode))
{
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_imm_index(ctx, 0);
+ gen_addr_imm_index(cpu_T[0], ctx, 0);
op_ldstm(lmw, rD(ctx->opcode));
}
{
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_imm_index(ctx, 0);
+ gen_addr_imm_index(cpu_T[0], ctx, 0);
op_ldstm(stmw, rS(ctx->opcode));
}
}
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_register(ctx);
+ gen_addr_register(cpu_T[0], ctx);
tcg_gen_movi_tl(cpu_T[1], nb);
op_ldsts(lswi, start);
}
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
if (ra == 0) {
ra = rb;
}
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_register(ctx);
+ gen_addr_register(cpu_T[0], ctx);
if (nb == 0)
nb = 32;
tcg_gen_movi_tl(cpu_T[1], nb);
{
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
gen_op_load_xer_bc();
op_ldsts(stsw, rS(ctx->opcode));
}
{
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
op_lwarx();
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[1]);
}
{
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);
op_stwcx();
}
{
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
op_ldarx();
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[1]);
}
{
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);
op_stdcx();
}
GEN_EXCP_NO_FP(ctx); \
return; \
} \
- gen_addr_imm_index(ctx, 0); \
+ gen_addr_imm_index(cpu_T[0], ctx, 0); \
op_ldst(l##width); \
tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]); \
}
GEN_EXCP_INVAL(ctx); \
return; \
} \
- gen_addr_imm_index(ctx, 0); \
+ gen_addr_imm_index(cpu_T[0], ctx, 0); \
op_ldst(l##width); \
tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]); \
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
GEN_EXCP_INVAL(ctx); \
return; \
} \
- gen_addr_reg_index(ctx); \
+ gen_addr_reg_index(cpu_T[0], ctx); \
op_ldst(l##width); \
tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]); \
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
GEN_EXCP_NO_FP(ctx); \
return; \
} \
- gen_addr_reg_index(ctx); \
+ gen_addr_reg_index(cpu_T[0], ctx); \
op_ldst(l##width); \
tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]); \
}
GEN_EXCP_NO_FP(ctx); \
return; \
} \
- gen_addr_imm_index(ctx, 0); \
+ gen_addr_imm_index(cpu_T[0], ctx, 0); \
tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]); \
op_ldst(st##width); \
}
GEN_EXCP_INVAL(ctx); \
return; \
} \
- gen_addr_imm_index(ctx, 0); \
+ gen_addr_imm_index(cpu_T[0], ctx, 0); \
tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]); \
op_ldst(st##width); \
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
GEN_EXCP_INVAL(ctx); \
return; \
} \
- gen_addr_reg_index(ctx); \
+ gen_addr_reg_index(cpu_T[0], ctx); \
tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]); \
op_ldst(st##width); \
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
GEN_EXCP_NO_FP(ctx); \
return; \
} \
- gen_addr_reg_index(ctx); \
+ gen_addr_reg_index(cpu_T[0], ctx); \
tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]); \
op_ldst(st##width); \
}
GEN_HANDLER(dcbf, 0x1F, 0x16, 0x02, 0x03C00001, PPC_CACHE)
{
/* XXX: specification says this is treated as a load by the MMU */
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
op_ldst(lbz);
}
GEN_EXCP_PRIVOPC(ctx);
return;
}
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
/* XXX: specification says this should be treated as a store by the MMU */
op_ldst(lbz);
op_ldst(stb);
GEN_HANDLER(dcbst, 0x1F, 0x16, 0x01, 0x03E00001, PPC_CACHE)
{
/* XXX: specification say this is treated as a load by the MMU */
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
op_ldst(lbz);
}
GEN_HANDLER(dcbz, 0x1F, 0x16, 0x1F, 0x03E00001, PPC_CACHE_DCBZ)
{
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
handler_dcbz(ctx, ctx->dcache_line_size);
gen_op_check_reservation();
}
GEN_HANDLER2(dcbz_970, "dcbz", 0x1F, 0x16, 0x1F, 0x03C00001, PPC_CACHE_DCBZT)
{
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
if (ctx->opcode & 0x00200000)
handler_dcbz(ctx, ctx->dcache_line_size);
else
{
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
op_icbi();
}
GEN_HANDLER(eciwx, 0x1F, 0x16, 0x0D, 0x00000001, PPC_EXTERN)
{
/* Should check EAR[E] & alignment ! */
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
op_eciwx();
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
}
GEN_HANDLER(ecowx, 0x1F, 0x16, 0x09, 0x00000001, PPC_EXTERN)
{
/* Should check EAR[E] & alignment ! */
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);
op_ecowx();
}
int ra = rA(ctx->opcode);
int rb = rB(ctx->opcode);
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
if (ra == 0) {
ra = rb;
}
int ra = rA(ctx->opcode);
int rd = rD(ctx->opcode);
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
gen_op_POWER_mfsri();
tcg_gen_mov_tl(cpu_gpr[rd], cpu_T[0]);
if (ra != 0 && ra != rd)
GEN_EXCP_PRIVOPC(ctx);
return;
}
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
gen_op_POWER_rac();
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
#endif
{
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_imm_index(ctx, 0);
+ gen_addr_imm_index(cpu_T[0], ctx, 0);
op_POWER2_lfq();
tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]);
tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode) + 1], cpu_FT[1]);
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_imm_index(ctx, 0);
+ gen_addr_imm_index(cpu_T[0], ctx, 0);
op_POWER2_lfq();
tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]);
tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode) + 1], cpu_FT[1]);
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
op_POWER2_lfq();
tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]);
tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode) + 1], cpu_FT[1]);
{
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
op_POWER2_lfq();
tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]);
tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode) + 1], cpu_FT[1]);
{
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_imm_index(ctx, 0);
+ gen_addr_imm_index(cpu_T[0], ctx, 0);
tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]);
tcg_gen_mov_i64(cpu_FT[1], cpu_fpr[rS(ctx->opcode) + 1]);
op_POWER2_stfq();
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_imm_index(ctx, 0);
+ gen_addr_imm_index(cpu_T[0], ctx, 0);
tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]);
tcg_gen_mov_i64(cpu_FT[1], cpu_fpr[rS(ctx->opcode) + 1]);
op_POWER2_stfq();
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]);
tcg_gen_mov_i64(cpu_FT[1], cpu_fpr[rS(ctx->opcode) + 1]);
op_POWER2_stfq();
{
/* NIP cannot be restored if the memory exception comes from an helper */
gen_update_nip(ctx, ctx->nip - 4);
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]);
tcg_gen_mov_i64(cpu_FT[1], cpu_fpr[rS(ctx->opcode) + 1]);
op_POWER2_stfq();
GEN_EXCP_PRIVOPC(ctx);
return;
}
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
/* Use the same micro-ops as for tlbie */
#if defined(TARGET_PPC64)
if (ctx->sf_mode)
GEN_EXCP_PRIVOPC(ctx);
return;
}
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
op_ldst(lwz);
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
#endif
GEN_EXCP_PRIVOPC(ctx);
return;
}
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
gen_op_4xx_tlbsx();
if (Rc(ctx->opcode))
gen_op_4xx_tlbsx_check();
GEN_EXCP_PRIVOPC(ctx);
return;
}
- gen_addr_reg_index(ctx);
+ gen_addr_reg_index(cpu_T[0], ctx);
gen_op_440_tlbsx();
if (Rc(ctx->opcode))
gen_op_4xx_tlbsx_check();
GEN_EXCP_NO_VR(ctx); \
return; \
} \
- gen_addr_reg_index(ctx); \
+ gen_addr_reg_index(cpu_T[0], ctx); \
op_vr_ldst(vr_l##name); \
gen_store_avr(rD(ctx->opcode), 0); \
}
GEN_EXCP_NO_VR(ctx); \
return; \
} \
- gen_addr_reg_index(ctx); \
+ gen_addr_reg_index(cpu_T[0], ctx); \
gen_load_avr(0, rS(ctx->opcode)); \
op_vr_ldst(vr_st##name); \
}
GEN_EXCP_NO_AP(ctx); \
return; \
} \
- gen_addr_reg_index(ctx); \
+ gen_addr_reg_index(cpu_T[0], ctx); \
op_spe_ldst(spe_l##name); \
gen_store_gpr64(rD(ctx->opcode), cpu_T64[1]); \
}
GEN_EXCP_NO_AP(ctx); \
return; \
} \
- gen_addr_reg_index(ctx); \
+ gen_addr_reg_index(cpu_T[0], ctx); \
gen_load_gpr64(cpu_T64[1], rS(ctx->opcode)); \
op_spe_ldst(spe_st##name); \
}