Skip to content

Commit

Permalink
Merge pull request #1311 from lioncash/op
Browse files Browse the repository at this point in the history
OpcodeDispatcher: Deduplicate OpToIndex definition
  • Loading branch information
Sonicadvance1 authored Oct 13, 2021
2 parents b1ab252 + c9621da commit 031fa8a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 55 deletions.
28 changes: 1 addition & 27 deletions External/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,7 @@ desc: Handles x86/64 ops to IR, no-pf opt, local-flags opt

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

Expand Down
30 changes: 2 additions & 28 deletions Source/Tests/UnitTestGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ desc: Brute forces generation of tests for x86/64, incomplete, unused right now
#include <FEXCore/Debug/X86Tables.h>
#include <FEXCore/Utils/LogManager.h>

using FEXCore::X86Tables::OpToIndex;

constexpr std::array<std::pair<int16_t, int16_t>, 3> Disp8Ranges = {{
{static_cast<int16_t>(-16), 16},
{static_cast<int16_t>(-128), static_cast<int16_t>(-112)},
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 031fa8a

Please sign in to comment.