From c9621da51c9f36262b695a2075fcf7e783749c47 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 13 Oct 2021 16:18:37 -0400 Subject: [PATCH] OpcodeDispatcher: Deduplicate OpToIndex definition We can just make the one defined in X86Tables visible instead to keep everything in one spot. --- .../Interface/Core/OpcodeDispatcher.cpp | 28 +---------------- Source/Tests/UnitTestGenerator.cpp | 30 ++----------------- 2 files changed, 3 insertions(+), 55 deletions(-) diff --git a/External/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp b/External/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp index da72bc22d..385ab7d42 100644 --- a/External/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp +++ b/External/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp @@ -26,33 +26,7 @@ $end_info$ namespace FEXCore::IR { -auto OpToIndex = [](uint8_t Op) constexpr -> uint8_t { - switch (Op) { - // Group 1 - case 0x80: return 0; - case 0x81: return 1; - case 0x82: return 2; - case 0x83: return 3; - // Group 2 - case 0xC0: return 0; - case 0xC1: return 1; - case 0xD0: return 2; - case 0xD1: return 3; - case 0xD2: return 4; - case 0xD3: return 5; - // Group 3 - case 0xF6: return 0; - case 0xF7: return 1; - // Group 4 - case 0xFE: return 0; - // Group 5 - case 0xFF: return 0; - // Group 11 - case 0xC6: return 0; - case 0xC7: return 1; - } - return 0; -}; +using X86Tables::OpToIndex; #define OpcodeArgs [[maybe_unused]] FEXCore::X86Tables::DecodedOp Op diff --git a/Source/Tests/UnitTestGenerator.cpp b/Source/Tests/UnitTestGenerator.cpp index 3f84c925a..4fb8d4d1a 100644 --- a/Source/Tests/UnitTestGenerator.cpp +++ b/Source/Tests/UnitTestGenerator.cpp @@ -23,6 +23,8 @@ $end_info$ #include #include +using FEXCore::X86Tables::OpToIndex; + constexpr std::array, 3> Disp8Ranges = {{ {static_cast(-16), 16}, {static_cast(-128), static_cast(-112)}, @@ -79,34 +81,6 @@ uint32_t GetModRMMapping(uint32_t Register) { return Register; }; -auto OpToIndex = [](uint8_t Op) constexpr -> uint8_t { - switch (Op) { - // Group 1 - case 0x80: return 0; - case 0x81: return 1; - case 0x82: return 2; - case 0x83: return 3; - // Group 2 - case 0xC0: return 0; - case 0xC1: return 1; - case 0xD0: return 2; - case 0xD1: return 3; - case 0xD2: return 4; - case 0xD3: return 5; - // Group 3 - case 0xF6: return 0; - case 0xF7: return 1; - // Group 4 - case 0xFE: return 0; - // Group 5 - case 0xFF: return 0; - // Group 11 - case 0xC6: return 0; - case 0xC7: return 1; - } - return 0; -}; - auto PrimaryIndexToOp = [](uint16_t Op) constexpr -> uint32_t { #define OPD(group, prefix, Reg) ((((group) - FEXCore::X86Tables::TYPE_GROUP_1) << 6) | (prefix) << 3 | (Reg)) switch (Op & ~0b111) {