diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp index 2e4c72f4f6..27327258b3 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp @@ -5,19 +5,19 @@ #include +#include "Common/Assert.h" +#include "Common/TypeUtils.h" #include "Core/PowerPC/Gekko.h" -#include "Core/PowerPC/PPCTables.h" namespace { -struct GekkoOPTemplate +struct JitArm64OpTemplate { - int opcode; + u32 opcode; JitArm64::Instruction fn; - // GekkoOPInfo opinfo; // Doesn't need opinfo, Interpreter fills it out }; -constexpr std::array primarytable{{ +constexpr std::array s_primary_table{{ {4, &JitArm64::DynaRunTable4}, // RunTable4 {19, &JitArm64::DynaRunTable19}, // RunTable19 {31, &JitArm64::DynaRunTable31}, // RunTable31 @@ -87,7 +87,7 @@ constexpr std::array primarytable{{ // missing: 0, 1, 2, 5, 6, 9, 22, 30, 58, 62 }}; -constexpr std::array table4{{ +constexpr std::array s_table4{{ // SUBOP10 {0, &JitArm64::ps_cmpXX}, // ps_cmpu0 {32, &JitArm64::ps_cmpXX}, // ps_cmpo0 @@ -105,7 +105,7 @@ constexpr std::array table4{{ {1014, &JitArm64::FallBackToInterpreter}, // dcbz_l }}; -constexpr std::array table4_2{{ +constexpr std::array s_table4_2{{ {10, &JitArm64::ps_sumX}, // ps_sum0 {11, &JitArm64::ps_sumX}, // ps_sum1 {12, &JitArm64::ps_arith}, // ps_muls0 @@ -125,14 +125,14 @@ constexpr std::array table4_2{{ {31, &JitArm64::ps_arith}, // ps_nmadd }}; -constexpr std::array table4_3{{ +constexpr std::array s_table4_3{{ {6, &JitArm64::psq_lXX}, // psq_lx {7, &JitArm64::psq_stXX}, // psq_stx {38, &JitArm64::psq_lXX}, // psq_lux {39, &JitArm64::psq_stXX}, // psq_stux }}; -constexpr std::array table19{{ +constexpr std::array s_table19{{ {528, &JitArm64::bcctrx}, // bcctrx {16, &JitArm64::bclrx}, // bclrx {257, &JitArm64::crXXX}, // crand @@ -150,7 +150,7 @@ constexpr std::array table19{{ {50, &JitArm64::rfi}, // rfi }}; -constexpr std::array table31{{ +constexpr std::array s_table31{{ {266, &JitArm64::addx}, // addx {778, &JitArm64::addx}, // addox {10, &JitArm64::addcx}, // addcx @@ -292,7 +292,7 @@ constexpr std::array table31{{ {566, &JitArm64::DoNothing}, // tlbsync }}; -constexpr std::array table59{{ +constexpr std::array s_table59{{ {18, &JitArm64::fp_arith}, // fdivsx {20, &JitArm64::fp_arith}, // fsubsx {21, &JitArm64::fp_arith}, // faddsx @@ -304,7 +304,7 @@ constexpr std::array table59{{ {31, &JitArm64::fp_arith}, // fnmaddsx }}; -constexpr std::array table63{{ +constexpr std::array s_table63{{ {264, &JitArm64::fp_logic}, // fabsx {32, &JitArm64::fcmpX}, // fcmpo {0, &JitArm64::fcmpX}, // fcmpu @@ -323,7 +323,7 @@ constexpr std::array table63{{ {711, &JitArm64::mtfsfx}, // mtfsfx }}; -constexpr std::array table63_2{{ +constexpr std::array s_table63_2{{ {18, &JitArm64::fp_arith}, // fdivx {20, &JitArm64::fp_arith}, // fsubx {21, &JitArm64::fp_arith}, // faddx @@ -336,161 +336,160 @@ constexpr std::array table63_2{{ {31, &JitArm64::fp_arith}, // fnmaddx }}; -constexpr std::array dynaOpTable = [] { +constexpr std::array s_dyna_op_table = []() consteval +{ std::array table{}; + Common::Fill(table, &JitArm64::FallBackToInterpreter); - for (auto& tpl : table) - { - tpl = &JitArm64::FallBackToInterpreter; - } - - for (const auto& tpl : primarytable) + for (auto& tpl : s_primary_table) { + ASSERT(table[tpl.opcode] == &JitArm64::FallBackToInterpreter); table[tpl.opcode] = tpl.fn; } return table; -}(); +} +(); -constexpr std::array dynaOpTable4 = [] { +constexpr std::array s_dyna_op_table4 = []() consteval +{ std::array table{}; + Common::Fill(table, &JitArm64::FallBackToInterpreter); - for (auto& entry : table) + for (u32 i = 0; i < 32; i++) { - entry = &JitArm64::FallBackToInterpreter; - } - - for (int i = 0; i < 32; i++) - { - const int fill = i << 5; - for (const auto& tpl : table4_2) + const u32 fill = i << 5; + for (const auto& tpl : s_table4_2) { - const int op = fill + tpl.opcode; + const u32 op = fill + tpl.opcode; + ASSERT(table[op] == &JitArm64::FallBackToInterpreter); table[op] = tpl.fn; } } - for (int i = 0; i < 16; i++) + for (u32 i = 0; i < 16; i++) { - const int fill = i << 6; - for (const auto& tpl : table4_3) + const u32 fill = i << 6; + for (const auto& tpl : s_table4_3) { - const int op = fill + tpl.opcode; + const u32 op = fill + tpl.opcode; + ASSERT(table[op] == &JitArm64::FallBackToInterpreter); table[op] = tpl.fn; } } - for (const auto& tpl : table4) + for (const auto& tpl : s_table4) { - table[tpl.opcode] = tpl.fn; + const u32 op = tpl.opcode; + ASSERT(table[op] == &JitArm64::FallBackToInterpreter); + table[op] = tpl.fn; } return table; -}(); +} +(); -constexpr std::array dynaOpTable19 = [] { +constexpr std::array s_dyna_op_table19 = []() consteval +{ std::array table{}; + Common::Fill(table, &JitArm64::FallBackToInterpreter); - for (auto& entry : table) - { - entry = &JitArm64::FallBackToInterpreter; - } - - for (const auto& tpl : table19) + for (const auto& tpl : s_table19) { + ASSERT(table[tpl.opcode] == &JitArm64::FallBackToInterpreter); table[tpl.opcode] = tpl.fn; } return table; -}(); +} +(); -constexpr std::array dynaOpTable31 = [] { +constexpr std::array s_dyna_op_table31 = []() consteval +{ std::array table{}; + Common::Fill(table, &JitArm64::FallBackToInterpreter); - for (auto& entry : table) - { - entry = &JitArm64::FallBackToInterpreter; - } - - for (const auto& tpl : table31) + for (const auto& tpl : s_table31) { + ASSERT(table[tpl.opcode] == &JitArm64::FallBackToInterpreter); table[tpl.opcode] = tpl.fn; } return table; -}(); +} +(); -constexpr std::array dynaOpTable59 = [] { +constexpr std::array s_dyna_op_table59 = []() consteval +{ std::array table{}; + Common::Fill(table, &JitArm64::FallBackToInterpreter); - for (auto& entry : table) - { - entry = &JitArm64::FallBackToInterpreter; - } - - for (const auto& tpl : table59) + for (const auto& tpl : s_table59) { + ASSERT(table[tpl.opcode] == &JitArm64::FallBackToInterpreter); table[tpl.opcode] = tpl.fn; } return table; -}(); +} +(); -constexpr std::array dynaOpTable63 = [] { +constexpr std::array s_dyna_op_table63 = []() consteval +{ std::array table{}; + Common::Fill(table, &JitArm64::FallBackToInterpreter); - for (auto& entry : table) - { - entry = &JitArm64::FallBackToInterpreter; - } - - for (const auto& tpl : table63) + for (const auto& tpl : s_table63) { + ASSERT(table[tpl.opcode] == &JitArm64::FallBackToInterpreter); table[tpl.opcode] = tpl.fn; } - for (int i = 0; i < 32; i++) + for (u32 i = 0; i < 32; i++) { - const int fill = i << 5; - for (const auto& tpl : table63_2) + const u32 fill = i << 5; + for (const auto& tpl : s_table63_2) { - const int op = fill + tpl.opcode; + const u32 op = fill + tpl.opcode; + ASSERT(table[op] == &JitArm64::FallBackToInterpreter); table[op] = tpl.fn; } } return table; -}(); +} +(); + } // Anonymous namespace void JitArm64::DynaRunTable4(UGeckoInstruction inst) { - (this->*dynaOpTable4[inst.SUBOP10])(inst); + (this->*s_dyna_op_table4[inst.SUBOP10])(inst); } void JitArm64::DynaRunTable19(UGeckoInstruction inst) { - (this->*dynaOpTable19[inst.SUBOP10])(inst); + (this->*s_dyna_op_table19[inst.SUBOP10])(inst); } void JitArm64::DynaRunTable31(UGeckoInstruction inst) { - (this->*dynaOpTable31[inst.SUBOP10])(inst); + (this->*s_dyna_op_table31[inst.SUBOP10])(inst); } void JitArm64::DynaRunTable59(UGeckoInstruction inst) { - (this->*dynaOpTable59[inst.SUBOP5])(inst); + (this->*s_dyna_op_table59[inst.SUBOP5])(inst); } void JitArm64::DynaRunTable63(UGeckoInstruction inst) { - (this->*dynaOpTable63[inst.SUBOP10])(inst); + (this->*s_dyna_op_table63[inst.SUBOP10])(inst); } void JitArm64::CompileInstruction(PPCAnalyst::CodeOp& op) { - (this->*dynaOpTable[op.inst.OPCD])(op.inst); + (this->*s_dyna_op_table[op.inst.OPCD])(op.inst); GekkoOPInfo* info = op.opinfo; if (info)