JIT: Make compilation functions a part of the JIT classes

This commit is contained in:
Lioncash 2017-02-08 03:57:13 -05:00
parent 96e83b5d54
commit 5da7d700ca
12 changed files with 71 additions and 64 deletions

View File

@ -874,7 +874,7 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBloc
fpr.BindToRegister(reg, true, false); fpr.BindToRegister(reg, true, false);
} }
Jit64Tables::CompileInstruction(*this, ops[i]); CompileInstruction(ops[i]);
if (jo.memcheck && (opinfo->flags & FL_LOADSTORE)) if (jo.memcheck && (opinfo->flags & FL_LOADSTORE))
{ {

View File

@ -31,22 +31,6 @@
class Jit64 : public Jitx86Base class Jit64 : public Jitx86Base
{ {
private:
void AllocStack();
void FreeStack();
GPRRegCache gpr{*this};
FPURegCache fpr{*this};
// The default code buffer. We keep it around to not have to alloc/dealloc a
// large chunk of memory for each recompiled block.
PPCAnalyst::CodeBuffer code_buffer;
Jit64AsmRoutineManager asm_routines;
bool m_enable_blr_optimization;
bool m_cleanup_after_stackfault;
u8* m_stack;
public: public:
Jit64() : code_buffer(32000) {} Jit64() : code_buffer(32000) {}
~Jit64() {} ~Jit64() {}
@ -248,4 +232,22 @@ public:
void dcbx(UGeckoInstruction inst); void dcbx(UGeckoInstruction inst);
void eieio(UGeckoInstruction inst); void eieio(UGeckoInstruction inst);
private:
void CompileInstruction(PPCAnalyst::CodeOp& op);
void AllocStack();
void FreeStack();
GPRRegCache gpr{*this};
FPURegCache fpr{*this};
// The default code buffer. We keep it around to not have to alloc/dealloc a
// large chunk of memory for each recompiled block.
PPCAnalyst::CodeBuffer code_buffer;
Jit64AsmRoutineManager asm_routines;
bool m_enable_blr_optimization;
bool m_cleanup_after_stackfault;
u8* m_stack;
}; };

View File

@ -358,25 +358,26 @@ static GekkoOPTemplate table63_2[] = {
{31, &Jit64::fmaddXX}, // fnmaddx {31, &Jit64::fmaddXX}, // fnmaddx
}; };
namespace Jit64Tables void Jit64::CompileInstruction(PPCAnalyst::CodeOp& op)
{ {
void CompileInstruction(Jit64& jit, PPCAnalyst::CodeOp& op) (this->*dynaOpTable[op.inst.OPCD])(op.inst);
{
(jit.*dynaOpTable[op.inst.OPCD])(op.inst);
GekkoOPInfo* info = op.opinfo; GekkoOPInfo* info = op.opinfo;
if (info) if (info)
{ {
#ifdef OPLOG #ifdef OPLOG
if (!strcmp(info->opname, OP_TO_LOG)) // "mcrfs" if (!strcmp(info->opname, OP_TO_LOG)) // "mcrfs"
{ {
rsplocations.push_back(jit.js.compilerPC); rsplocations.push_back(js.compilerPC);
} }
#endif #endif
info->compileCount++; info->compileCount++;
info->lastUse = jit.js.compilerPC; info->lastUse = js.compilerPC;
} }
} }
namespace Jit64Tables
{
void InitTables() void InitTables()
{ {
// once initialized, tables are read-only // once initialized, tables are read-only

View File

@ -13,6 +13,5 @@ struct CodeOp;
namespace Jit64Tables namespace Jit64Tables
{ {
void CompileInstruction(Jit64& jit, PPCAnalyst::CodeOp& op);
void InitTables(); void InitTables();
} }

View File

@ -640,7 +640,7 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBloc
ibuild.EmitBreakPointCheck(ibuild.EmitIntConst(ops[i].address)); ibuild.EmitBreakPointCheck(ibuild.EmitIntConst(ops[i].address));
} }
JitILTables::CompileInstruction(*this, ops[i]); CompileInstruction(ops[i]);
if (jo.memcheck && (opinfo->flags & FL_LOADSTORE)) if (jo.memcheck && (opinfo->flags & FL_LOADSTORE))
{ {

View File

@ -77,4 +77,7 @@ public:
void DynaRunTable31(UGeckoInstruction _inst) override; void DynaRunTable31(UGeckoInstruction _inst) override;
void DynaRunTable59(UGeckoInstruction _inst) override; void DynaRunTable59(UGeckoInstruction _inst) override;
void DynaRunTable63(UGeckoInstruction _inst) override; void DynaRunTable63(UGeckoInstruction _inst) override;
private:
void CompileInstruction(PPCAnalyst::CodeOp& op);
}; };

View File

@ -376,30 +376,31 @@ static GekkoOPTemplate table63_2[] = {
{31, &JitIL::fmaddXX}, //"fnmaddx", OPTYPE_FPU, FL_RC_BIT_F}}, {31, &JitIL::fmaddXX}, //"fnmaddx", OPTYPE_FPU, FL_RC_BIT_F}},
}; };
namespace JitILTables void JitIL::CompileInstruction(PPCAnalyst::CodeOp& op)
{ {
void CompileInstruction(JitIL& jit, PPCAnalyst::CodeOp& op) (this->*dynaOpTable[op.inst.OPCD])(op.inst);
{
(jit.*dynaOpTable[op.inst.OPCD])(op.inst);
GekkoOPInfo* info = op.opinfo; GekkoOPInfo* info = op.opinfo;
if (info) if (info)
{ {
#ifdef OPLOG #ifdef OPLOG
if (!strcmp(info->opname, OP_TO_LOG)) // "mcrfs" if (!strcmp(info->opname, OP_TO_LOG)) // "mcrfs"
{ {
rsplocations.push_back(jit.js.compilerPC); rsplocations.push_back(js.compilerPC);
} }
#endif #endif
info->compileCount++; info->compileCount++;
info->lastUse = jit.js.compilerPC; info->lastUse = js.compilerPC;
} }
else else
{ {
PanicAlert("Tried to compile illegal (or unknown) instruction %08x, at %08x", op.inst.hex, PanicAlert("Tried to compile illegal (or unknown) instruction %08x, at %08x", op.inst.hex,
jit.js.compilerPC); js.compilerPC);
} }
} }
namespace JitILTables
{
void InitTables() void InitTables()
{ {
// once initialized, tables are read-only // once initialized, tables are read-only

View File

@ -13,6 +13,5 @@ struct CodeOp;
namespace JitILTables namespace JitILTables
{ {
void CompileInstruction(JitIL& jit, PPCAnalyst::CodeOp& op);
void InitTables(); void InitTables();
} }

View File

@ -846,7 +846,7 @@ void JitArm64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBlock*
js.firstFPInstructionFound = true; js.firstFPInstructionFound = true;
} }
JitArm64Tables::CompileInstruction(*this, ops[i]); CompileInstruction(ops[i]);
if (!MergeAllowedNextInstructions(1) || js.op[1].opinfo->type != OPTYPE_INTEGER) if (!MergeAllowedNextInstructions(1) || js.op[1].opinfo->type != OPTYPE_INTEGER)
FlushCarry(); FlushCarry();

View File

@ -172,29 +172,7 @@ private:
const u8* slowmem_code; const u8* slowmem_code;
}; };
// <Fastmem fault location, slowmem handler location> void CompileInstruction(PPCAnalyst::CodeOp& op);
std::map<const u8*, FastmemArea> m_fault_to_handler;
std::map<SlowmemHandler, const u8*> m_handler_to_loc;
Arm64GPRCache gpr;
Arm64FPRCache fpr;
JitArm64BlockCache blocks{*this};
PPCAnalyst::CodeBuffer code_buffer;
ARM64FloatEmitter m_float_emit;
Arm64Gen::ARM64CodeBlock farcode;
u8* nearcode; // Backed up when we switch to far code.
// Do we support cycle counter profiling?
bool m_supports_cycle_counter;
bool m_enable_blr_optimization;
bool m_cleanup_after_stackfault = false;
u8* m_stack_base = nullptr;
u8* m_stack_pointer = nullptr;
u8* m_saved_stack_pointer = nullptr;
void EmitResetCycleCounters(); void EmitResetCycleCounters();
void EmitGetCycles(Arm64Gen::ARM64Reg reg); void EmitGetCycles(Arm64Gen::ARM64Reg reg);
@ -260,4 +238,28 @@ private:
void reg_imm(u32 d, u32 a, u32 value, u32 (*do_op)(u32, u32), void reg_imm(u32 d, u32 a, u32 value, u32 (*do_op)(u32, u32),
void (ARM64XEmitter::*op)(ARM64Reg, ARM64Reg, u64, ARM64Reg), bool Rc = false); void (ARM64XEmitter::*op)(ARM64Reg, ARM64Reg, u64, ARM64Reg), bool Rc = false);
// <Fastmem fault location, slowmem handler location>
std::map<const u8*, FastmemArea> m_fault_to_handler;
std::map<SlowmemHandler, const u8*> m_handler_to_loc;
Arm64GPRCache gpr;
Arm64FPRCache fpr;
JitArm64BlockCache blocks{*this};
PPCAnalyst::CodeBuffer code_buffer;
ARM64FloatEmitter m_float_emit;
Arm64Gen::ARM64CodeBlock farcode;
u8* nearcode; // Backed up when we switch to far code.
// Do we support cycle counter profiling?
bool m_supports_cycle_counter;
bool m_enable_blr_optimization;
bool m_cleanup_after_stackfault = false;
u8* m_stack_base = nullptr;
u8* m_stack_pointer = nullptr;
u8* m_saved_stack_pointer = nullptr;
}; };

View File

@ -367,25 +367,26 @@ static GekkoOPTemplate table63_2[] = {
{31, &JitArm64::fp_arith}, // fnmaddx {31, &JitArm64::fp_arith}, // fnmaddx
}; };
namespace JitArm64Tables void JitArm64::CompileInstruction(PPCAnalyst::CodeOp& op)
{ {
void CompileInstruction(JitArm64& jit, PPCAnalyst::CodeOp& op) (this->*dynaOpTable[op.inst.OPCD])(op.inst);
{
(jit.*dynaOpTable[op.inst.OPCD])(op.inst);
GekkoOPInfo* info = op.opinfo; GekkoOPInfo* info = op.opinfo;
if (info) if (info)
{ {
#ifdef OPLOG #ifdef OPLOG
if (!strcmp(info->opname, OP_TO_LOG)) if (!strcmp(info->opname, OP_TO_LOG))
{ ///"mcrfs" { ///"mcrfs"
rsplocations.push_back(jit.js.compilerPC); rsplocations.push_back(js.compilerPC);
} }
#endif #endif
info->compileCount++; info->compileCount++;
info->lastUse = jit.js.compilerPC; info->lastUse = js.compilerPC;
} }
} }
namespace JitArm64Tables
{
void InitTables() void InitTables()
{ {
// once initialized, tables are read-only // once initialized, tables are read-only

View File

@ -13,6 +13,5 @@ struct CodeOp;
namespace JitArm64Tables namespace JitArm64Tables
{ {
void CompileInstruction(JitArm64& jit, PPCAnalyst::CodeOp& op);
void InitTables(); void InitTables();
} }