Skip to content

Commit

Permalink
X86Tables: Remove function wraps from VEX tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonicadvance1 committed Sep 17, 2024
1 parent dbca441 commit e6512fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
34 changes: 13 additions & 21 deletions FEXCore/Source/Interface/Core/OpcodeDispatcher/VEXTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,24 @@
#include "Interface/Core/OpcodeDispatcher.h"

namespace FEXCore::IR {
consteval inline void VEXTable_Install(auto& FinalTable) {
#define OPD(map_select, pp, opcode) (((map_select - 1) << 10) | (pp << 8) | (opcode))
constexpr std::tuple<uint16_t, uint8_t, FEXCore::X86Tables::OpDispatchPtr> Table[] = {
{OPD(2, 0b00, 0xF2), 1, &OpDispatchBuilder::ANDNBMIOp}, {OPD(2, 0b00, 0xF5), 1, &OpDispatchBuilder::BZHI},
{OPD(2, 0b10, 0xF5), 1, &OpDispatchBuilder::PEXT}, {OPD(2, 0b11, 0xF5), 1, &OpDispatchBuilder::PDEP},
{OPD(2, 0b11, 0xF6), 1, &OpDispatchBuilder::MULX}, {OPD(2, 0b00, 0xF7), 1, &OpDispatchBuilder::BEXTRBMIOp},
{OPD(2, 0b01, 0xF7), 1, &OpDispatchBuilder::BMI2Shift}, {OPD(2, 0b10, 0xF7), 1, &OpDispatchBuilder::BMI2Shift},
{OPD(2, 0b11, 0xF7), 1, &OpDispatchBuilder::BMI2Shift},
constexpr std::tuple<uint16_t, uint8_t, FEXCore::X86Tables::OpDispatchPtr> OpDispatch_VEXTable[] = {
{OPD(2, 0b00, 0xF2), 1, &OpDispatchBuilder::ANDNBMIOp}, {OPD(2, 0b00, 0xF5), 1, &OpDispatchBuilder::BZHI},
{OPD(2, 0b10, 0xF5), 1, &OpDispatchBuilder::PEXT}, {OPD(2, 0b11, 0xF5), 1, &OpDispatchBuilder::PDEP},
{OPD(2, 0b11, 0xF6), 1, &OpDispatchBuilder::MULX}, {OPD(2, 0b00, 0xF7), 1, &OpDispatchBuilder::BEXTRBMIOp},
{OPD(2, 0b01, 0xF7), 1, &OpDispatchBuilder::BMI2Shift}, {OPD(2, 0b10, 0xF7), 1, &OpDispatchBuilder::BMI2Shift},
{OPD(2, 0b11, 0xF7), 1, &OpDispatchBuilder::BMI2Shift},

{OPD(3, 0b11, 0xF0), 1, &OpDispatchBuilder::RORX},
};
{OPD(3, 0b11, 0xF0), 1, &OpDispatchBuilder::RORX},
};
#undef OPD

InstallToTable(FinalTable, Table);
}

consteval inline void VEXGroupTable_Install(auto& FinalTable) {
#define OPD(group, pp, opcode) (((group - X86Tables::InstType::TYPE_VEX_GROUP_12) << 4) | (pp << 3) | (opcode))
constexpr std::tuple<uint8_t, uint8_t, X86Tables::OpDispatchPtr> Table[] = {
{OPD(X86Tables::InstType::TYPE_VEX_GROUP_17, 0, 0b001), 1, &OpDispatchBuilder::BLSRBMIOp},
{OPD(X86Tables::InstType::TYPE_VEX_GROUP_17, 0, 0b010), 1, &OpDispatchBuilder::BLSMSKBMIOp},
{OPD(X86Tables::InstType::TYPE_VEX_GROUP_17, 0, 0b011), 1, &OpDispatchBuilder::BLSIBMIOp},
};
constexpr std::tuple<uint8_t, uint8_t, X86Tables::OpDispatchPtr> OpDispatch_VEXGroupTable[] = {
{OPD(X86Tables::InstType::TYPE_VEX_GROUP_17, 0, 0b001), 1, &OpDispatchBuilder::BLSRBMIOp},
{OPD(X86Tables::InstType::TYPE_VEX_GROUP_17, 0, 0b010), 1, &OpDispatchBuilder::BLSMSKBMIOp},
{OPD(X86Tables::InstType::TYPE_VEX_GROUP_17, 0, 0b011), 1, &OpDispatchBuilder::BLSIBMIOp},
};
#undef OPD

InstallToTable(FinalTable, Table);
}

} // namespace FEXCore::IR
4 changes: 2 additions & 2 deletions FEXCore/Source/Interface/Core/X86Tables/VEXTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ std::array<X86InstInfo, MAX_VEX_TABLE_SIZE> VEXTableOps = []() consteval {

GenerateTable(&Table.at(0), VEXTable, std::size(VEXTable));

FEXCore::IR::VEXTable_Install(Table);
IR::InstallToTable(Table, IR::OpDispatch_VEXTable);
return Table;
}();

Expand Down Expand Up @@ -524,7 +524,7 @@ std::array<X86InstInfo, MAX_VEX_GROUP_TABLE_SIZE> VEXTableGroupOps = []() conste

GenerateTable(&Table.at(0), VEXGroupTable, std::size(VEXGroupTable));

FEXCore::IR::VEXGroupTable_Install(Table);
IR::InstallToTable(Table, IR::OpDispatch_VEXGroupTable);
return Table;
}();
}

0 comments on commit e6512fb

Please sign in to comment.