diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp index dbb96a8394..2127b1f62d 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp @@ -484,7 +484,7 @@ void Jit64::mtcrf(UGeckoInstruction inst) } else { - MOV(64, R(RSCRATCH2), ImmPtr(m_crTable)); + MOV(64, R(RSCRATCH2), ImmPtr(m_crTable.data())); gpr.Lock(inst.RS); gpr.BindToRegister(inst.RS, true, false); for (int i = 0; i < 8; i++) @@ -531,7 +531,7 @@ void Jit64::mcrxr(UGeckoInstruction inst) // [SO OV CA 0] << 3 SHL(32, R(RSCRATCH), Imm8(4)); - MOV(64, R(RSCRATCH2), ImmPtr(m_crTable)); + MOV(64, R(RSCRATCH2), ImmPtr(m_crTable.data())); MOV(64, R(RSCRATCH), MRegSum(RSCRATCH, RSCRATCH2)); MOV(64, PPCSTATE(cr_val[inst.CRFD]), R(RSCRATCH)); @@ -623,7 +623,7 @@ void Jit64::mcrfs(UGeckoInstruction inst) } AND(32, R(RSCRATCH), Imm32(mask)); MOV(32, PPCSTATE(fpscr), R(RSCRATCH)); - LEA(64, RSCRATCH, M(&m_crTable)); + LEA(64, RSCRATCH, M(m_crTable.data())); MOV(64, R(RSCRATCH), MComplex(RSCRATCH, RSCRATCH2, SCALE_8, 0)); MOV(64, PPCSTATE(cr_val[inst.CRFD]), R(RSCRATCH)); } diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_SystemRegisters.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_SystemRegisters.cpp index 7ee288e5d0..e683c2f0a5 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_SystemRegisters.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_SystemRegisters.cpp @@ -102,7 +102,7 @@ void JitArm64::mcrxr(UGeckoInstruction inst) // [SO OV CA 0] << 3 LSL(WA, WA, 4); - MOVP2R(XB, m_crTable); + MOVP2R(XB, m_crTable.data()); LDR(XB, XB, XA); STR(INDEX_UNSIGNED, XB, PPC_REG, PPCSTATE_OFF(cr_val[inst.CRFD])); @@ -636,7 +636,7 @@ void JitArm64::mtcrf(UGeckoInstruction inst) ARM64Reg XA = EncodeRegTo64(WA); ARM64Reg WB = gpr.GetReg(); ARM64Reg XB = EncodeRegTo64(WB); - MOVP2R(XB, m_crTable); + MOVP2R(XB, m_crTable.data()); for (int i = 0; i < 8; ++i) { if ((crm & (0x80 >> i)) != 0) diff --git a/Source/Core/Core/PowerPC/PPCTables.cpp b/Source/Core/Core/PowerPC/PPCTables.cpp index c932a5d608..fda50310d9 100644 --- a/Source/Core/Core/PowerPC/PPCTables.cpp +++ b/Source/Core/Core/PowerPC/PPCTables.cpp @@ -2,8 +2,12 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "Core/PowerPC/PPCTables.h" + #include +#include #include +#include #include #include "Common/CommonTypes.h" @@ -13,25 +17,24 @@ #include "Core/PowerPC/Interpreter/Interpreter.h" #include "Core/PowerPC/Interpreter/Interpreter_Tables.h" #include "Core/PowerPC/JitInterface.h" -#include "Core/PowerPC/PPCTables.h" #include "Core/PowerPC/PowerPC.h" -GekkoOPInfo* m_infoTable[64]; -GekkoOPInfo* m_infoTable4[1024]; -GekkoOPInfo* m_infoTable19[1024]; -GekkoOPInfo* m_infoTable31[1024]; -GekkoOPInfo* m_infoTable59[32]; -GekkoOPInfo* m_infoTable63[1024]; +std::array m_infoTable; +std::array m_infoTable4; +std::array m_infoTable19; +std::array m_infoTable31; +std::array m_infoTable59; +std::array m_infoTable63; -GekkoOPInfo* m_allInstructions[512]; -int m_numInstructions; +std::array m_allInstructions; +size_t m_numInstructions; -const u64 m_crTable[16] = { +const std::array m_crTable = {{ PPCCRToInternal(0x0), PPCCRToInternal(0x1), PPCCRToInternal(0x2), PPCCRToInternal(0x3), PPCCRToInternal(0x4), PPCCRToInternal(0x5), PPCCRToInternal(0x6), PPCCRToInternal(0x7), PPCCRToInternal(0x8), PPCCRToInternal(0x9), PPCCRToInternal(0xA), PPCCRToInternal(0xB), PPCCRToInternal(0xC), PPCCRToInternal(0xD), PPCCRToInternal(0xE), PPCCRToInternal(0xF), -}; +}}; GekkoOPInfo* GetOpInfo(UGeckoInstruction _inst) { @@ -152,7 +155,7 @@ void PrintInstructionRunCounts() typedef std::pair OpInfo; std::vector temp; temp.reserve(m_numInstructions); - for (int i = 0; i < m_numInstructions; ++i) + for (size_t i = 0; i < m_numInstructions; ++i) { GekkoOPInfo* pInst = m_allInstructions[i]; temp.emplace_back(pInst->opname, pInst->runCount); @@ -175,7 +178,7 @@ void LogCompiledInstructions() File::IOFile f(StringFromFormat("%sinst_log%i.txt", File::GetUserPath(D_LOGS_IDX).c_str(), time), "w"); - for (int i = 0; i < m_numInstructions; i++) + for (size_t i = 0; i < m_numInstructions; i++) { GekkoOPInfo* pInst = m_allInstructions[i]; if (pInst->compileCount > 0) @@ -186,7 +189,7 @@ void LogCompiledInstructions() } f.Open(StringFromFormat("%sinst_not%i.txt", File::GetUserPath(D_LOGS_IDX).c_str(), time), "w"); - for (int i = 0; i < m_numInstructions; i++) + for (size_t i = 0; i < m_numInstructions; i++) { GekkoOPInfo* pInst = m_allInstructions[i]; if (pInst->compileCount == 0) diff --git a/Source/Core/Core/PowerPC/PPCTables.h b/Source/Core/Core/PowerPC/PPCTables.h index 1b564d6475..eada803ef5 100644 --- a/Source/Core/Core/PowerPC/PPCTables.h +++ b/Source/Core/Core/PowerPC/PPCTables.h @@ -4,6 +4,9 @@ #pragma once +#include +#include + #include "Core/PowerPC/Gekko.h" #include "Core/PowerPC/Interpreter/Interpreter.h" @@ -92,16 +95,15 @@ struct GekkoOPInfo int compileCount; u32 lastUse; }; -extern GekkoOPInfo* m_infoTable[64]; -extern GekkoOPInfo* m_infoTable4[1024]; -extern GekkoOPInfo* m_infoTable19[1024]; -extern GekkoOPInfo* m_infoTable31[1024]; -extern GekkoOPInfo* m_infoTable59[32]; -extern GekkoOPInfo* m_infoTable63[1024]; +extern std::array m_infoTable; +extern std::array m_infoTable4; +extern std::array m_infoTable19; +extern std::array m_infoTable31; +extern std::array m_infoTable59; +extern std::array m_infoTable63; -extern GekkoOPInfo* m_allInstructions[512]; - -extern int m_numInstructions; +extern std::array m_allInstructions; +extern size_t m_numInstructions; GekkoOPInfo* GetOpInfo(UGeckoInstruction _inst); Interpreter::Instruction GetInterpreterOp(UGeckoInstruction _inst); diff --git a/Source/Core/Core/PowerPC/PowerPC.h b/Source/Core/Core/PowerPC/PowerPC.h index c9216c5faf..885b8a5da2 100644 --- a/Source/Core/Core/PowerPC/PowerPC.h +++ b/Source/Core/Core/PowerPC/PowerPC.h @@ -325,7 +325,7 @@ inline u64 PPCCRToInternal(u8 value) } // convert flags into 64-bit CR values with a lookup table -extern const u64 m_crTable[16]; +extern const std::array m_crTable; // Warning: these CR operations are fairly slow since they need to convert from // PowerPC format (4 bit) to our internal 64 bit format. See the definition of