From 2381aeecc35adee36180f40a2b1634f20934600f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 24 Mar 2018 16:31:55 -0400 Subject: [PATCH 1/2] PPCTables: Namespace all exposed functions It's somewhat inconsistent to have two straggler functions outside the namespace. --- .../Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp | 2 +- Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp | 2 +- Source/Core/Core/PowerPC/Jit64/Jit.cpp | 2 +- Source/Core/Core/PowerPC/JitArm64/Jit.cpp | 2 +- Source/Core/Core/PowerPC/JitInterface.cpp | 4 ++-- Source/Core/Core/PowerPC/PPCAnalyst.cpp | 2 +- Source/Core/Core/PowerPC/PPCTables.cpp | 5 +++-- Source/Core/Core/PowerPC/PPCTables.h | 4 ++-- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp b/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp index 50823cf4d7..f441a5b2b0 100644 --- a/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp +++ b/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp @@ -241,7 +241,7 @@ void CachedInterpreter::Jit(u32 address) if (endblock || memcheck) m_code.emplace_back(WritePC, ops[i].address); - m_code.emplace_back(GetInterpreterOp(ops[i].inst), ops[i].inst); + m_code.emplace_back(PPCTables::GetInterpreterOp(ops[i].inst), ops[i].inst); if (memcheck) m_code.emplace_back(CheckDSI, js.downcountAmount); if (endblock) diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp index e0bfdffe17..5a3ae58954 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp @@ -193,7 +193,7 @@ int Interpreter::SingleStepInner() last_pc = PC; PC = NPC; - GekkoOPInfo* opinfo = GetOpInfo(instCode); + const GekkoOPInfo* opinfo = PPCTables::GetOpInfo(instCode); return opinfo->numCycles; } diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index 14c5d9ca75..4c4ae55c42 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -287,7 +287,7 @@ void Jit64::FallBackToInterpreter(UGeckoInstruction inst) MOV(32, PPCSTATE(pc), Imm32(js.compilerPC)); MOV(32, PPCSTATE(npc), Imm32(js.compilerPC + 4)); } - Interpreter::Instruction instr = GetInterpreterOp(inst); + Interpreter::Instruction instr = PPCTables::GetInterpreterOp(inst); ABI_PushRegistersAndAdjustStack({}, 0); ABI_CallFunctionC(instr, inst.hex); ABI_PopRegistersAndAdjustStack({}, 0); diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp index d0eb2ebe2b..3d6c8c1cf9 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp @@ -149,7 +149,7 @@ void JitArm64::FallBackToInterpreter(UGeckoInstruction inst) gpr.Unlock(WA); } - Interpreter::Instruction instr = GetInterpreterOp(inst); + Interpreter::Instruction instr = PPCTables::GetInterpreterOp(inst); MOVI2R(W0, inst.hex); MOVP2R(X30, instr); BLR(X30); diff --git a/Source/Core/Core/PowerPC/JitInterface.cpp b/Source/Core/Core/PowerPC/JitInterface.cpp index d4ec1978a8..35691d2e16 100644 --- a/Source/Core/Core/PowerPC/JitInterface.cpp +++ b/Source/Core/Core/PowerPC/JitInterface.cpp @@ -239,8 +239,8 @@ void CompileExceptionCheck(ExceptionType type) if (type == ExceptionType::FIFOWrite) { // Check in case the code has been replaced since: do we need to do this? - const ::OpType optype = GetOpInfo(PowerPC::HostRead_U32(PC))->type; - if (optype != ::OpType::Store && optype != ::OpType::StoreFP && optype != ::OpType::StorePS) + const OpType optype = PPCTables::GetOpInfo(PowerPC::HostRead_U32(PC))->type; + if (optype != OpType::Store && optype != OpType::StoreFP && optype != OpType::StorePS) return; } exception_addresses->insert(PC); diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/PowerPC/PPCAnalyst.cpp index 8c3423218b..0b74afb499 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/PowerPC/PPCAnalyst.cpp @@ -726,7 +726,7 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, u32 num_inst++; memset(&code[i], 0, sizeof(CodeOp)); - GekkoOPInfo* opinfo = GetOpInfo(inst); + GekkoOPInfo* opinfo = PPCTables::GetOpInfo(inst); code[i].opinfo = opinfo; code[i].address = address; diff --git a/Source/Core/Core/PowerPC/PPCTables.cpp b/Source/Core/Core/PowerPC/PPCTables.cpp index cdd8fb83f1..d1a86bd8a1 100644 --- a/Source/Core/Core/PowerPC/PPCTables.cpp +++ b/Source/Core/Core/PowerPC/PPCTables.cpp @@ -41,6 +41,8 @@ const std::array m_crTable = {{ }}; } // namespace PowerPC +namespace PPCTables +{ GekkoOPInfo* GetOpInfo(UGeckoInstruction _inst) { GekkoOPInfo* info = m_infoTable[_inst.OPCD]; @@ -106,8 +108,7 @@ Interpreter::Instruction GetInterpreterOp(UGeckoInstruction _inst) return Interpreter::m_op_table[_inst.OPCD]; } } -namespace PPCTables -{ + bool UsesFPU(UGeckoInstruction inst) { GekkoOPInfo* const info = GetOpInfo(inst); diff --git a/Source/Core/Core/PowerPC/PPCTables.h b/Source/Core/Core/PowerPC/PPCTables.h index 9ab0bd9bfb..41e9ad235a 100644 --- a/Source/Core/Core/PowerPC/PPCTables.h +++ b/Source/Core/Core/PowerPC/PPCTables.h @@ -105,11 +105,11 @@ extern std::array m_infoTable63; extern std::array m_allInstructions; extern size_t m_numInstructions; +namespace PPCTables +{ GekkoOPInfo* GetOpInfo(UGeckoInstruction _inst); Interpreter::Instruction GetInterpreterOp(UGeckoInstruction _inst); -namespace PPCTables -{ bool IsValidInstruction(UGeckoInstruction _instCode); bool UsesFPU(UGeckoInstruction _inst); From 8a7abd72b4a6153a0caca86d98f63721be8c0427 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 24 Mar 2018 16:42:59 -0400 Subject: [PATCH 2/2] PPCTables: Remove prefixed underscores from parameter names --- Source/Core/Core/PowerPC/PPCTables.cpp | 56 +++++++++++++------------- Source/Core/Core/PowerPC/PPCTables.h | 12 +++--- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Source/Core/Core/PowerPC/PPCTables.cpp b/Source/Core/Core/PowerPC/PPCTables.cpp index d1a86bd8a1..a431d025d5 100644 --- a/Source/Core/Core/PowerPC/PPCTables.cpp +++ b/Source/Core/Core/PowerPC/PPCTables.cpp @@ -43,25 +43,25 @@ const std::array m_crTable = {{ namespace PPCTables { -GekkoOPInfo* GetOpInfo(UGeckoInstruction _inst) +GekkoOPInfo* GetOpInfo(UGeckoInstruction inst) { - GekkoOPInfo* info = m_infoTable[_inst.OPCD]; + const GekkoOPInfo* info = m_infoTable[inst.OPCD]; if (info->type == OpType::Subtable) { - switch (_inst.OPCD) + switch (inst.OPCD) { case 4: - return m_infoTable4[_inst.SUBOP10]; + return m_infoTable4[inst.SUBOP10]; case 19: - return m_infoTable19[_inst.SUBOP10]; + return m_infoTable19[inst.SUBOP10]; case 31: - return m_infoTable31[_inst.SUBOP10]; + return m_infoTable31[inst.SUBOP10]; case 59: - return m_infoTable59[_inst.SUBOP5]; + return m_infoTable59[inst.SUBOP5]; case 63: - return m_infoTable63[_inst.SUBOP10]; + return m_infoTable63[inst.SUBOP10]; default: - ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid subtable op %08x @ %08x", _inst.hex, PC); + ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid subtable op %08x @ %08x", inst.hex, PC); return nullptr; } } @@ -69,32 +69,32 @@ GekkoOPInfo* GetOpInfo(UGeckoInstruction _inst) { if (info->type == OpType::Invalid) { - ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid op %08x @ %08x", _inst.hex, PC); + ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid op %08x @ %08x", inst.hex, PC); return nullptr; } - return m_infoTable[_inst.OPCD]; + return m_infoTable[inst.OPCD]; } } -Interpreter::Instruction GetInterpreterOp(UGeckoInstruction _inst) +Interpreter::Instruction GetInterpreterOp(UGeckoInstruction inst) { - const GekkoOPInfo* info = m_infoTable[_inst.OPCD]; + const GekkoOPInfo* info = m_infoTable[inst.OPCD]; if (info->type == OpType::Subtable) { - switch (_inst.OPCD) + switch (inst.OPCD) { case 4: - return Interpreter::m_op_table4[_inst.SUBOP10]; + return Interpreter::m_op_table4[inst.SUBOP10]; case 19: - return Interpreter::m_op_table19[_inst.SUBOP10]; + return Interpreter::m_op_table19[inst.SUBOP10]; case 31: - return Interpreter::m_op_table31[_inst.SUBOP10]; + return Interpreter::m_op_table31[inst.SUBOP10]; case 59: - return Interpreter::m_op_table59[_inst.SUBOP5]; + return Interpreter::m_op_table59[inst.SUBOP5]; case 63: - return Interpreter::m_op_table63[_inst.SUBOP10]; + return Interpreter::m_op_table63[inst.SUBOP10]; default: - ASSERT_MSG(POWERPC, 0, "GetInterpreterOp - invalid subtable op %08x @ %08x", _inst.hex, PC); + ASSERT_MSG(POWERPC, 0, "GetInterpreterOp - invalid subtable op %08x @ %08x", inst.hex, PC); return nullptr; } } @@ -102,10 +102,10 @@ Interpreter::Instruction GetInterpreterOp(UGeckoInstruction _inst) { if (info->type == OpType::Invalid) { - ASSERT_MSG(POWERPC, 0, "GetInterpreterOp - invalid op %08x @ %08x", _inst.hex, PC); + ASSERT_MSG(POWERPC, 0, "GetInterpreterOp - invalid op %08x @ %08x", inst.hex, PC); return nullptr; } - return Interpreter::m_op_table[_inst.OPCD]; + return Interpreter::m_op_table[inst.OPCD]; } } @@ -126,21 +126,21 @@ std::vector rsplocations; } #endif -const char* GetInstructionName(UGeckoInstruction _inst) +const char* GetInstructionName(UGeckoInstruction inst) { - const GekkoOPInfo* info = GetOpInfo(_inst); + const GekkoOPInfo* info = GetOpInfo(inst); return info ? info->opname : nullptr; } -bool IsValidInstruction(UGeckoInstruction _inst) +bool IsValidInstruction(UGeckoInstruction inst) { - const GekkoOPInfo* info = GetOpInfo(_inst); + const GekkoOPInfo* info = GetOpInfo(inst); return info != nullptr && info->type != OpType::Unknown; } -void CountInstruction(UGeckoInstruction _inst) +void CountInstruction(UGeckoInstruction inst) { - GekkoOPInfo* info = GetOpInfo(_inst); + GekkoOPInfo* info = GetOpInfo(inst); if (info) { info->runCount++; diff --git a/Source/Core/Core/PowerPC/PPCTables.h b/Source/Core/Core/PowerPC/PPCTables.h index 41e9ad235a..f3aa89e290 100644 --- a/Source/Core/Core/PowerPC/PPCTables.h +++ b/Source/Core/Core/PowerPC/PPCTables.h @@ -107,14 +107,14 @@ extern size_t m_numInstructions; namespace PPCTables { -GekkoOPInfo* GetOpInfo(UGeckoInstruction _inst); -Interpreter::Instruction GetInterpreterOp(UGeckoInstruction _inst); +GekkoOPInfo* GetOpInfo(UGeckoInstruction inst); +Interpreter::Instruction GetInterpreterOp(UGeckoInstruction inst); -bool IsValidInstruction(UGeckoInstruction _instCode); -bool UsesFPU(UGeckoInstruction _inst); +bool IsValidInstruction(UGeckoInstruction inst); +bool UsesFPU(UGeckoInstruction inst); -void CountInstruction(UGeckoInstruction _inst); +void CountInstruction(UGeckoInstruction inst); void PrintInstructionRunCounts(); void LogCompiledInstructions(); -const char* GetInstructionName(UGeckoInstruction _inst); +const char* GetInstructionName(UGeckoInstruction inst); } // namespace PPCTables