OpcodeDispatcher: Handle PDEP

Now all of BMI2 is handled.
This commit is contained in:
lioncash 2021-12-13 13:36:05 -05:00
parent 38eea80b8d
commit 6ff80670b3
4 changed files with 35 additions and 1 deletions

View File

@ -2449,6 +2449,14 @@ void OpDispatchBuilder::MULX(OpcodeArgs) {
StoreResult(GPRClass, Op, Op->Dest, ResultHi, -1);
}
void OpDispatchBuilder::PDEP(OpcodeArgs) {
auto* Input = LoadSource(GPRClass, Op, Op->Src[0], Op->Flags, -1);
auto* Mask = LoadSource(GPRClass, Op, Op->Src[1], Op->Flags, -1);
auto Result = _PDep(Input, Mask);
StoreResult(GPRClass, Op, Op->Dest, Result, -1);
}
void OpDispatchBuilder::PEXT(OpcodeArgs) {
auto* Input = LoadSource(GPRClass, Op, Op->Src[0], Op->Flags, -1);
auto* Mask = LoadSource(GPRClass, Op, Op->Src[1], Op->Flags, -1);
@ -6196,6 +6204,7 @@ constexpr uint16_t PF_F2 = 3;
{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},

View File

@ -338,6 +338,7 @@ public:
void BMI2Shift(OpcodeArgs);
void BZHI(OpcodeArgs);
void MULX(OpcodeArgs);
void PDEP(OpcodeArgs);
void PEXT(OpcodeArgs);
void RORX(OpcodeArgs);

View File

@ -396,7 +396,7 @@ void InitializeVEXTables() {
{OPD(2, 0b00, 0xF5), 1, X86InstInfo{"BZHI", TYPE_INST, FLAGS_MODRM | FLAGS_VEX_2ND_SRC, 0, nullptr}},
// AMD reference manual is incorrect. PEXT actually maps to 0b10, not 0b01.
{OPD(2, 0b10, 0xF5), 1, X86InstInfo{"PEXT", TYPE_INST, FLAGS_MODRM | FLAGS_VEX_1ST_SRC, 0, nullptr}},
{OPD(2, 0b11, 0xF5), 1, X86InstInfo{"PDEP", TYPE_UNDEC, FLAGS_NONE, 0, nullptr}},
{OPD(2, 0b11, 0xF5), 1, X86InstInfo{"PDEP", TYPE_INST, FLAGS_MODRM | FLAGS_VEX_1ST_SRC, 0, nullptr}},
{OPD(2, 0b11, 0xF6), 1, X86InstInfo{"MULX", TYPE_INST, FLAGS_MODRM | FLAGS_VEX_1ST_SRC, 0, nullptr}},

View File

@ -0,0 +1,24 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0x00012567",
"RBX": "0xFF00FFF0",
"RCX": "0x12005670",
"RDX": "0x0801256708012567",
"RSI": "0xFF00FF00FF00FF00",
"RDI": "0x0800010025006700"
}
}
%endif
; 32-bit
mov eax, 0x00012567
mov ebx, 0xFF00FFF0
pdep ecx, eax, ebx
; 64-bit
mov rdx, 0x0801256708012567
mov rsi, 0xFF00FF00FF00FF00
pdep rdi, rdx, rsi
hlt