From 5da7d700ca727a7e553184599d2c1b175c936b01 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 8 Feb 2017 03:57:13 -0500 Subject: [PATCH 1/2] JIT: Make compilation functions a part of the JIT classes --- Source/Core/Core/PowerPC/Jit64/Jit.cpp | 2 +- Source/Core/Core/PowerPC/Jit64/Jit.h | 34 ++++++------- .../Core/Core/PowerPC/Jit64/Jit64_Tables.cpp | 13 ++--- Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h | 1 - Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp | 2 +- Source/Core/Core/PowerPC/Jit64IL/JitIL.h | 3 ++ .../Core/PowerPC/Jit64IL/JitIL_Tables.cpp | 15 +++--- .../Core/Core/PowerPC/Jit64IL/JitIL_Tables.h | 1 - Source/Core/Core/PowerPC/JitArm64/Jit.cpp | 2 +- Source/Core/Core/PowerPC/JitArm64/Jit.h | 48 ++++++++++--------- .../Core/PowerPC/JitArm64/JitArm64_Tables.cpp | 13 ++--- .../Core/PowerPC/JitArm64/JitArm64_Tables.h | 1 - 12 files changed, 71 insertions(+), 64 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index 1ba9d51d27c3..8a424ad8057e 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -874,7 +874,7 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBloc fpr.BindToRegister(reg, true, false); } - Jit64Tables::CompileInstruction(*this, ops[i]); + CompileInstruction(ops[i]); if (jo.memcheck && (opinfo->flags & FL_LOADSTORE)) { diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.h b/Source/Core/Core/PowerPC/Jit64/Jit.h index 1c48da065061..af990d1f1299 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.h +++ b/Source/Core/Core/PowerPC/Jit64/Jit.h @@ -31,22 +31,6 @@ 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: Jit64() : code_buffer(32000) {} ~Jit64() {} @@ -248,4 +232,22 @@ class Jit64 : public Jitx86Base void dcbx(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; }; diff --git a/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.cpp b/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.cpp index 7981d7e33369..93988b44f5e5 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.cpp @@ -358,25 +358,26 @@ static GekkoOPTemplate table63_2[] = { {31, &Jit64::fmaddXX}, // fnmaddx }; -namespace Jit64Tables -{ -void CompileInstruction(Jit64& jit, PPCAnalyst::CodeOp& op) +void Jit64::CompileInstruction(PPCAnalyst::CodeOp& op) { - (jit.*dynaOpTable[op.inst.OPCD])(op.inst); + (this->*dynaOpTable[op.inst.OPCD])(op.inst); + GekkoOPInfo* info = op.opinfo; if (info) { #ifdef OPLOG if (!strcmp(info->opname, OP_TO_LOG)) // "mcrfs" { - rsplocations.push_back(jit.js.compilerPC); + rsplocations.push_back(js.compilerPC); } #endif info->compileCount++; - info->lastUse = jit.js.compilerPC; + info->lastUse = js.compilerPC; } } +namespace Jit64Tables +{ void InitTables() { // once initialized, tables are read-only diff --git a/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h b/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h index 8daa24f3607f..90e1d2b76680 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h +++ b/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h @@ -13,6 +13,5 @@ struct CodeOp; namespace Jit64Tables { -void CompileInstruction(Jit64& jit, PPCAnalyst::CodeOp& op); void InitTables(); } diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp index ba4d8291daf2..e864aefe2b90 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp @@ -640,7 +640,7 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBloc ibuild.EmitBreakPointCheck(ibuild.EmitIntConst(ops[i].address)); } - JitILTables::CompileInstruction(*this, ops[i]); + CompileInstruction(ops[i]); if (jo.memcheck && (opinfo->flags & FL_LOADSTORE)) { diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL.h b/Source/Core/Core/PowerPC/Jit64IL/JitIL.h index 5dd943aa02d9..434c446e98e4 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL.h +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL.h @@ -77,4 +77,7 @@ class JitIL : public JitILBase void DynaRunTable31(UGeckoInstruction _inst) override; void DynaRunTable59(UGeckoInstruction _inst) override; void DynaRunTable63(UGeckoInstruction _inst) override; + +private: + void CompileInstruction(PPCAnalyst::CodeOp& op); }; diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.cpp b/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.cpp index ab69cc52835f..d7fe49d435cc 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.cpp +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.cpp @@ -376,30 +376,31 @@ static GekkoOPTemplate table63_2[] = { {31, &JitIL::fmaddXX}, //"fnmaddx", OPTYPE_FPU, FL_RC_BIT_F}}, }; -namespace JitILTables -{ -void CompileInstruction(JitIL& jit, PPCAnalyst::CodeOp& op) +void JitIL::CompileInstruction(PPCAnalyst::CodeOp& op) { - (jit.*dynaOpTable[op.inst.OPCD])(op.inst); + (this->*dynaOpTable[op.inst.OPCD])(op.inst); + GekkoOPInfo* info = op.opinfo; if (info) { #ifdef OPLOG if (!strcmp(info->opname, OP_TO_LOG)) // "mcrfs" { - rsplocations.push_back(jit.js.compilerPC); + rsplocations.push_back(js.compilerPC); } #endif info->compileCount++; - info->lastUse = jit.js.compilerPC; + info->lastUse = js.compilerPC; } else { PanicAlert("Tried to compile illegal (or unknown) instruction %08x, at %08x", op.inst.hex, - jit.js.compilerPC); + js.compilerPC); } } +namespace JitILTables +{ void InitTables() { // once initialized, tables are read-only diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.h b/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.h index 89c0b766e4ee..a66cfa4188ce 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.h +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.h @@ -13,6 +13,5 @@ struct CodeOp; namespace JitILTables { -void CompileInstruction(JitIL& jit, PPCAnalyst::CodeOp& op); void InitTables(); } diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp index 50cd4f908f0f..dcf13f5672b6 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp @@ -846,7 +846,7 @@ void JitArm64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBlock* js.firstFPInstructionFound = true; } - JitArm64Tables::CompileInstruction(*this, ops[i]); + CompileInstruction(ops[i]); if (!MergeAllowedNextInstructions(1) || js.op[1].opinfo->type != OPTYPE_INTEGER) FlushCarry(); diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.h b/Source/Core/Core/PowerPC/JitArm64/Jit.h index bf2bdc4a4785..7e006432a06b 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.h +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.h @@ -172,29 +172,7 @@ class JitArm64 : public JitBase, public Arm64Gen::ARM64CodeBlock, public CommonA const u8* slowmem_code; }; - // - std::map m_fault_to_handler; - std::map 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 CompileInstruction(PPCAnalyst::CodeOp& op); void EmitResetCycleCounters(); void EmitGetCycles(Arm64Gen::ARM64Reg reg); @@ -260,4 +238,28 @@ class JitArm64 : public JitBase, public Arm64Gen::ARM64CodeBlock, public CommonA void reg_imm(u32 d, u32 a, u32 value, u32 (*do_op)(u32, u32), void (ARM64XEmitter::*op)(ARM64Reg, ARM64Reg, u64, ARM64Reg), bool Rc = false); + + // + std::map m_fault_to_handler; + std::map 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; }; diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp index 85c0072fbdd3..63565589da32 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp @@ -367,25 +367,26 @@ static GekkoOPTemplate table63_2[] = { {31, &JitArm64::fp_arith}, // fnmaddx }; -namespace JitArm64Tables -{ -void CompileInstruction(JitArm64& jit, PPCAnalyst::CodeOp& op) +void JitArm64::CompileInstruction(PPCAnalyst::CodeOp& op) { - (jit.*dynaOpTable[op.inst.OPCD])(op.inst); + (this->*dynaOpTable[op.inst.OPCD])(op.inst); + GekkoOPInfo* info = op.opinfo; if (info) { #ifdef OPLOG if (!strcmp(info->opname, OP_TO_LOG)) { ///"mcrfs" - rsplocations.push_back(jit.js.compilerPC); + rsplocations.push_back(js.compilerPC); } #endif info->compileCount++; - info->lastUse = jit.js.compilerPC; + info->lastUse = js.compilerPC; } } +namespace JitArm64Tables +{ void InitTables() { // once initialized, tables are read-only diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.h b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.h index e351c01feb56..bf1987bf1f9e 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.h +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.h @@ -13,6 +13,5 @@ struct CodeOp; namespace JitArm64Tables { -void CompileInstruction(JitArm64& jit, PPCAnalyst::CodeOp& op); void InitTables(); } From 1ce1304d0f011d574eb5e942f4c4479dcaa0596c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 8 Feb 2017 04:27:04 -0500 Subject: [PATCH 2/2] CPU Backends: Make each CPU backend responsible for initializing its own instruction tables Previously, all of the internals that handled how the instruction tables are initialized were exposed externally. However, this can all be made private to each CPU backend. If each backend has an Init() function, then this is where the instruction tables should be initialized, it shouldn't be the responsibility of external code to ensure internal validity. This allows for getting rid of all the table initialization shenanigans within JitInterface and PPCTables. --- Source/Core/Core/Core.vcxproj | 3 -- Source/Core/Core/Core.vcxproj.filters | 9 ----- .../Core/PowerPC/Interpreter/Interpreter.cpp | 1 + .../Core/PowerPC/Interpreter/Interpreter.h | 2 ++ .../Interpreter/Interpreter_Tables.cpp | 36 +++++++++---------- .../PowerPC/Interpreter/Interpreter_Tables.h | 10 ------ Source/Core/Core/PowerPC/Jit64/Jit.cpp | 5 +-- Source/Core/Core/PowerPC/Jit64/Jit.h | 10 +++--- .../Core/Core/PowerPC/Jit64/Jit64_Tables.cpp | 7 +--- Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h | 17 --------- Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp | 5 +-- Source/Core/Core/PowerPC/Jit64IL/JitIL.h | 4 +-- .../Core/PowerPC/Jit64IL/JitIL_Tables.cpp | 6 +--- .../Core/Core/PowerPC/Jit64IL/JitIL_Tables.h | 17 --------- Source/Core/Core/PowerPC/JitArm64/Jit.cpp | 6 ++-- Source/Core/Core/PowerPC/JitArm64/Jit.h | 1 + .../Core/PowerPC/JitArm64/JitArm64_Tables.cpp | 9 ++--- .../Core/PowerPC/JitArm64/JitArm64_Tables.h | 17 --------- Source/Core/Core/PowerPC/JitInterface.cpp | 29 +-------------- Source/Core/Core/PowerPC/JitInterface.h | 1 - Source/Core/Core/PowerPC/PPCTables.cpp | 10 ------ Source/Core/Core/PowerPC/PPCTables.h | 4 +-- Source/Core/Core/PowerPC/PowerPC.cpp | 6 ++-- 23 files changed, 44 insertions(+), 171 deletions(-) delete mode 100644 Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.h delete mode 100644 Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h delete mode 100644 Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.h delete mode 100644 Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.h diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index 60a6de3fd5bd..e9477f128b31 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -459,13 +459,10 @@ - - - diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters index b96b206c0f64..2578f48fd384 100644 --- a/Source/Core/Core/Core.vcxproj.filters +++ b/Source/Core/Core/Core.vcxproj.filters @@ -931,15 +931,9 @@ PowerPC\Interpreter - - PowerPC\Interpreter - PowerPC\Jit64 - - PowerPC\Jit64 - HW %28Flipper/Hollywood%29\AI - Audio Interface @@ -1252,9 +1246,6 @@ PowerPC\JitIL - - PowerPC\JitIL - PowerPC\Jit64 diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp index fe712ed043e6..fa08d5525206 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp @@ -63,6 +63,7 @@ void Interpreter::RunTable63(UGeckoInstruction inst) void Interpreter::Init() { + InitializeInstructionTables(); m_reserve = false; m_end_block = false; } diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.h b/Source/Core/Core/PowerPC/Interpreter/Interpreter.h index 6f4de8537121..0ce65ba149a9 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.h +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.h @@ -282,6 +282,8 @@ class Interpreter : public CPUCoreBase static u32 Helper_Carry(u32 value1, u32 value2); private: + static void InitializeInstructionTables(); + // flag helper static void Helper_UpdateCR0(u32 value); static void Helper_UpdateCR1(); diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp index 29c41f73ebef..4fb81d6e48fc 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp @@ -6,7 +6,6 @@ #include "Core/PowerPC/Gekko.h" #include "Core/PowerPC/Interpreter/Interpreter.h" -#include "Core/PowerPC/Interpreter/Interpreter_Tables.h" #include "Core/PowerPC/PPCTables.h" struct GekkoOPTemplate @@ -355,8 +354,6 @@ static std::array table63_2 = }}; // clang-format on -namespace InterpreterTables -{ constexpr size_t TotalInstructionFunctionCount() { return primarytable.size() + table4_2.size() + table4_3.size() + table4.size() + table31.size() + @@ -366,7 +363,7 @@ constexpr size_t TotalInstructionFunctionCount() static_assert(TotalInstructionFunctionCount() < m_allInstructions.size(), "m_allInstructions is too small"); -void InitTables() +void Interpreter::InitializeInstructionTables() { // once initialized, tables are read-only static bool initialized = false; @@ -376,22 +373,22 @@ void InitTables() // clear for (int i = 0; i < 64; i++) { - Interpreter::m_op_table[i] = Interpreter::unknown_instruction; + m_op_table[i] = Interpreter::unknown_instruction; m_infoTable[i] = &unknownopinfo; } for (int i = 0; i < 32; i++) { - Interpreter::m_op_table59[i] = Interpreter::unknown_instruction; + m_op_table59[i] = Interpreter::unknown_instruction; m_infoTable59[i] = &unknownopinfo; } for (int i = 0; i < 1024; i++) { - Interpreter::m_op_table4[i] = Interpreter::unknown_instruction; - Interpreter::m_op_table19[i] = Interpreter::unknown_instruction; - Interpreter::m_op_table31[i] = Interpreter::unknown_instruction; - Interpreter::m_op_table63[i] = Interpreter::unknown_instruction; + m_op_table4[i] = Interpreter::unknown_instruction; + m_op_table19[i] = Interpreter::unknown_instruction; + m_op_table31[i] = Interpreter::unknown_instruction; + m_op_table63[i] = Interpreter::unknown_instruction; m_infoTable4[i] = &unknownopinfo; m_infoTable19[i] = &unknownopinfo; m_infoTable31[i] = &unknownopinfo; @@ -400,7 +397,7 @@ void InitTables() for (auto& tpl : primarytable) { - Interpreter::m_op_table[tpl.opcode] = tpl.Inst; + m_op_table[tpl.opcode] = tpl.Inst; m_infoTable[tpl.opcode] = &tpl.opinfo; } @@ -410,7 +407,7 @@ void InitTables() for (auto& tpl : table4_2) { int op = fill + tpl.opcode; - Interpreter::m_op_table4[op] = tpl.Inst; + m_op_table4[op] = tpl.Inst; m_infoTable4[op] = &tpl.opinfo; } } @@ -421,7 +418,7 @@ void InitTables() for (auto& tpl : table4_3) { int op = fill + tpl.opcode; - Interpreter::m_op_table4[op] = tpl.Inst; + m_op_table4[op] = tpl.Inst; m_infoTable4[op] = &tpl.opinfo; } } @@ -429,35 +426,35 @@ void InitTables() for (auto& tpl : table4) { int op = tpl.opcode; - Interpreter::m_op_table4[op] = tpl.Inst; + m_op_table4[op] = tpl.Inst; m_infoTable4[op] = &tpl.opinfo; } for (auto& tpl : table31) { int op = tpl.opcode; - Interpreter::m_op_table31[op] = tpl.Inst; + m_op_table31[op] = tpl.Inst; m_infoTable31[op] = &tpl.opinfo; } for (auto& tpl : table19) { int op = tpl.opcode; - Interpreter::m_op_table19[op] = tpl.Inst; + m_op_table19[op] = tpl.Inst; m_infoTable19[op] = &tpl.opinfo; } for (auto& tpl : table59) { int op = tpl.opcode; - Interpreter::m_op_table59[op] = tpl.Inst; + m_op_table59[op] = tpl.Inst; m_infoTable59[op] = &tpl.opinfo; } for (auto& tpl : table63) { int op = tpl.opcode; - Interpreter::m_op_table63[op] = tpl.Inst; + m_op_table63[op] = tpl.Inst; m_infoTable63[op] = &tpl.opinfo; } @@ -467,7 +464,7 @@ void InitTables() for (auto& tpl : table63_2) { int op = fill + tpl.opcode; - Interpreter::m_op_table63[op] = tpl.Inst; + m_op_table63[op] = tpl.Inst; m_infoTable63[op] = &tpl.opinfo; } } @@ -494,4 +491,3 @@ void InitTables() initialized = true; } -} // namespace InterpreterTables diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.h b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.h deleted file mode 100644 index ce7796bf2d3e..000000000000 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2008 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#pragma once - -namespace InterpreterTables -{ -void InitTables(); -} diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index 8a424ad8057e..83bfb5239c48 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "Core/PowerPC/Jit64/Jit.h" + #include #include @@ -22,8 +24,6 @@ #include "Core/HW/GPFifo.h" #include "Core/HW/ProcessorInterface.h" #include "Core/PatchEngine.h" -#include "Core/PowerPC/Jit64/Jit.h" -#include "Core/PowerPC/Jit64/Jit64_Tables.h" #include "Core/PowerPC/Jit64/JitAsm.h" #include "Core/PowerPC/Jit64/JitRegCache.h" #include "Core/PowerPC/Jit64Common/FarCodeCache.h" @@ -216,6 +216,7 @@ bool Jit64::HandleFault(uintptr_t access_address, SContext* ctx) void Jit64::Init() { + InitializeInstructionTables(); EnableBlockLink(); jo.optimizeGatherPipe = true; diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.h b/Source/Core/Core/PowerPC/Jit64/Jit.h index af990d1f1299..4fe96f5bfcb7 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.h +++ b/Source/Core/Core/PowerPC/Jit64/Jit.h @@ -35,17 +35,14 @@ class Jit64 : public Jitx86Base Jit64() : code_buffer(32000) {} ~Jit64() {} void Init() override; - - void EnableOptimization(); - - void EnableBlockLink(); - void Shutdown() override; bool HandleFault(uintptr_t access_address, SContext* ctx) override; - bool HandleStackFault() override; + void EnableOptimization(); + void EnableBlockLink(); + // Jit! void Jit(u32 em_address) override; @@ -234,6 +231,7 @@ class Jit64 : public Jitx86Base void eieio(UGeckoInstruction inst); private: + static void InitializeInstructionTables(); void CompileInstruction(PPCAnalyst::CodeOp& op); void AllocStack(); diff --git a/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.cpp b/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.cpp index 93988b44f5e5..5e2d3d51b69c 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.cpp @@ -4,7 +4,6 @@ #include "Core/PowerPC/Jit64/Jit.h" #include "Core/PowerPC/Gekko.h" -#include "Core/PowerPC/Jit64/Jit64_Tables.h" static Jit64::Instruction dynaOpTable[64]; static Jit64::Instruction dynaOpTable4[1024]; @@ -376,9 +375,7 @@ void Jit64::CompileInstruction(PPCAnalyst::CodeOp& op) } } -namespace Jit64Tables -{ -void InitTables() +void Jit64::InitializeInstructionTables() { // once initialized, tables are read-only static bool initialized = false; @@ -471,5 +468,3 @@ void InitTables() initialized = true; } - -} // namespace diff --git a/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h b/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h deleted file mode 100644 index 90e1d2b76680..000000000000 --- a/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2008 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#pragma once - -class Jit64; - -namespace PPCAnalyst -{ -struct CodeOp; -} - -namespace Jit64Tables -{ -void InitTables(); -} diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp index e864aefe2b90..af1f022852ca 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "Core/PowerPC/Jit64IL/JitIL.h" + #include #include // For profiling #include @@ -19,8 +21,6 @@ #include "Core/HW/CPU.h" #include "Core/PatchEngine.h" #include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h" -#include "Core/PowerPC/Jit64IL/JitIL.h" -#include "Core/PowerPC/Jit64IL/JitIL_Tables.h" #include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/Profiler.h" @@ -255,6 +255,7 @@ static void Shutdown() void JitIL::Init() { + InitializeInstructionTables(); EnableBlockLink(); jo.optimizeGatherPipe = true; diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL.h b/Source/Core/Core/PowerPC/Jit64IL/JitIL.h index 434c446e98e4..168f0f2ccc54 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL.h +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL.h @@ -35,11 +35,10 @@ class JitIL : public JitILBase // Initialization, etc void Init() override; + void Shutdown() override; void EnableBlockLink(); - void Shutdown() override; - // Jit! void Jit(u32 em_address) override; @@ -79,5 +78,6 @@ class JitIL : public JitILBase void DynaRunTable63(UGeckoInstruction _inst) override; private: + static void InitializeInstructionTables(); void CompileInstruction(PPCAnalyst::CodeOp& op); }; diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.cpp b/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.cpp index d7fe49d435cc..03a80c6aaf25 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.cpp +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.cpp @@ -4,7 +4,6 @@ #include "Core/PowerPC/Jit64IL/JitIL.h" #include "Core/PowerPC/Gekko.h" -#include "Core/PowerPC/Jit64IL/JitIL_Tables.h" #include "Core/PowerPC/PPCTables.h" static JitIL::Instruction dynaOpTable[64]; @@ -399,9 +398,7 @@ void JitIL::CompileInstruction(PPCAnalyst::CodeOp& op) } } -namespace JitILTables -{ -void InitTables() +void JitIL::InitializeInstructionTables() { // once initialized, tables are read-only static bool initialized = false; @@ -494,4 +491,3 @@ void InitTables() initialized = true; } -} diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.h b/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.h deleted file mode 100644 index a66cfa4188ce..000000000000 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2008 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#pragma once - -class JitIL; - -namespace PPCAnalyst -{ -struct CodeOp; -} - -namespace JitILTables -{ -void InitTables(); -} diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp index dcf13f5672b6..1771ee79bcd1 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "Core/PowerPC/JitArm64/Jit.h" + #include #include "Common/Arm64Emitter.h" @@ -19,9 +21,7 @@ #include "Core/HW/Memmap.h" #include "Core/HW/ProcessorInterface.h" #include "Core/PatchEngine.h" -#include "Core/PowerPC/JitArm64/Jit.h" #include "Core/PowerPC/JitArm64/JitArm64_RegCache.h" -#include "Core/PowerPC/JitArm64/JitArm64_Tables.h" #include "Core/PowerPC/JitInterface.h" #include "Core/PowerPC/Profiler.h" @@ -47,6 +47,8 @@ static bool HasCycleCounters() void JitArm64::Init() { + InitializeInstructionTables(); + size_t child_code_size = SConfig::GetInstance().bMMU ? FARCODE_SIZE_MMU : FARCODE_SIZE; AllocCodeSpace(CODE_SIZE + child_code_size); AddChildCodeSpace(&farcode, child_code_size); diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.h b/Source/Core/Core/PowerPC/JitArm64/Jit.h index 7e006432a06b..efbc2bb759bc 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.h +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.h @@ -172,6 +172,7 @@ class JitArm64 : public JitBase, public Arm64Gen::ARM64CodeBlock, public CommonA const u8* slowmem_code; }; + static void InitializeInstructionTables(); void CompileInstruction(PPCAnalyst::CodeOp& op); void EmitResetCycleCounters(); diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp index 63565589da32..0ae6d63e515b 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp @@ -2,10 +2,9 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/PowerPC/JitArm64/JitArm64_Tables.h" +#include "Core/PowerPC/JitArm64/Jit.h" #include "Core/PowerPC/Gekko.h" -#include "Core/PowerPC/JitArm64/Jit.h" #include "Core/PowerPC/JitInterface.h" #include "Core/PowerPC/PPCAnalyst.h" #include "Core/PowerPC/PPCTables.h" @@ -385,9 +384,7 @@ void JitArm64::CompileInstruction(PPCAnalyst::CodeOp& op) } } -namespace JitArm64Tables -{ -void InitTables() +void JitArm64::InitializeInstructionTables() { // once initialized, tables are read-only static bool initialized = false; @@ -480,5 +477,3 @@ void InitTables() initialized = true; } - -} // namespace diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.h b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.h deleted file mode 100644 index bf1987bf1f9e..000000000000 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2008 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#pragma once - -class JitArm64; - -namespace PPCAnalyst -{ -struct CodeOp; -} - -namespace JitArm64Tables -{ -void InitTables(); -} diff --git a/Source/Core/Core/PowerPC/JitInterface.cpp b/Source/Core/Core/PowerPC/JitInterface.cpp index d32678a8bd4b..0eaa4f1cc1b7 100644 --- a/Source/Core/Core/PowerPC/JitInterface.cpp +++ b/Source/Core/Core/PowerPC/JitInterface.cpp @@ -22,14 +22,11 @@ #if _M_X86 #include "Core/PowerPC/Jit64/Jit.h" -#include "Core/PowerPC/Jit64/Jit64_Tables.h" #include "Core/PowerPC/Jit64IL/JitIL.h" -#include "Core/PowerPC/Jit64IL/JitIL_Tables.h" #endif #if _M_ARM_64 #include "Core/PowerPC/JitArm64/Jit.h" -#include "Core/PowerPC/JitArm64/JitArm64_Tables.h" #endif namespace JitInterface @@ -70,31 +67,7 @@ CPUCoreBase* InitJitCore(int core) g_jit->Init(); return ptr; } -void InitTables(int core) -{ - switch (core) - { -#if _M_X86 - case PowerPC::CORE_JIT64: - Jit64Tables::InitTables(); - break; - case PowerPC::CORE_JITIL64: - JitILTables::InitTables(); - break; -#endif -#if _M_ARM_64 - case PowerPC::CORE_JITARM64: - JitArm64Tables::InitTables(); - break; -#endif - case PowerPC::CORE_CACHEDINTERPRETER: - // has no tables - break; - default: - PanicAlert("Unrecognizable cpu_core: %d", core); - break; - } -} + CPUCoreBase* GetCore() { return g_jit; diff --git a/Source/Core/Core/PowerPC/JitInterface.h b/Source/Core/Core/PowerPC/JitInterface.h index 01fd6bf91118..f2d4cdaa93b3 100644 --- a/Source/Core/Core/PowerPC/JitInterface.h +++ b/Source/Core/Core/PowerPC/JitInterface.h @@ -22,7 +22,6 @@ enum class ExceptionType void DoState(PointerWrap& p); CPUCoreBase* InitJitCore(int core); -void InitTables(int core); CPUCoreBase* GetCore(); // Debugging diff --git a/Source/Core/Core/PowerPC/PPCTables.cpp b/Source/Core/Core/PowerPC/PPCTables.cpp index fda50310d9ad..e27c949799a7 100644 --- a/Source/Core/Core/PowerPC/PPCTables.cpp +++ b/Source/Core/Core/PowerPC/PPCTables.cpp @@ -15,7 +15,6 @@ #include "Common/StringUtil.h" #include "Core/PowerPC/Interpreter/Interpreter.h" -#include "Core/PowerPC/Interpreter/Interpreter_Tables.h" #include "Core/PowerPC/JitInterface.h" #include "Core/PowerPC/PowerPC.h" @@ -110,15 +109,6 @@ bool UsesFPU(UGeckoInstruction inst) return (info->flags & FL_USE_FPU) != 0; } -void InitTables(int cpu_core) -{ - // Interpreter ALWAYS needs to be initialized - InterpreterTables::InitTables(); - - if (cpu_core != PowerPC::CORE_INTERPRETER) - JitInterface::InitTables(cpu_core); -} - #define OPLOG #define OP_TO_LOG "mtfsb0x" diff --git a/Source/Core/Core/PowerPC/PPCTables.h b/Source/Core/Core/PowerPC/PPCTables.h index eada803ef542..7b15bce2a00f 100644 --- a/Source/Core/Core/PowerPC/PPCTables.h +++ b/Source/Core/Core/PowerPC/PPCTables.h @@ -110,7 +110,6 @@ Interpreter::Instruction GetInterpreterOp(UGeckoInstruction _inst); namespace PPCTables { -void InitTables(int cpu_core); bool IsValidInstruction(UGeckoInstruction _instCode); bool UsesFPU(UGeckoInstruction _inst); @@ -118,5 +117,4 @@ void CountInstruction(UGeckoInstruction _inst); void PrintInstructionRunCounts(); void LogCompiledInstructions(); const char* GetInstructionName(UGeckoInstruction _inst); - -} // namespace +} // namespace PPCTables diff --git a/Source/Core/Core/PowerPC/PowerPC.cpp b/Source/Core/Core/PowerPC/PowerPC.cpp index 2beeb3751784..7cb616fbc9f7 100644 --- a/Source/Core/Core/PowerPC/PowerPC.cpp +++ b/Source/Core/Core/PowerPC/PowerPC.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "Core/PowerPC/PowerPC.h" + #include "Common/Assert.h" #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" @@ -18,8 +20,6 @@ #include "Core/PowerPC/CPUCoreBase.h" #include "Core/PowerPC/Interpreter/Interpreter.h" #include "Core/PowerPC/JitInterface.h" -#include "Core/PowerPC/PPCTables.h" -#include "Core/PowerPC/PowerPC.h" namespace PowerPC { @@ -148,8 +148,6 @@ static void ResetRegisters() static void InitializeCPUCore(int cpu_core) { - PPCTables::InitTables(cpu_core); - // We initialize the interpreter because // it is used on boot and code window independently. s_interpreter->Init();