Frontend: Handle VEX RXB bits

These are equivalent to the REX prefix's RXB bits, except that they're
in 1's complement form.

These are trivial to handle and fix usages of the upper range of
registers for ModRM encoded fields.

To ensure that we have coverage for this, I've altered the BEXTR test to
make use of R14 and R15.
This commit is contained in:
lioncash 2021-11-17 14:29:50 -05:00
parent c63c5fb664
commit 77c969b424
2 changed files with 18 additions and 5 deletions

View File

@ -775,6 +775,11 @@ bool Decoder::NormalOpHeader(FEXCore::X86Tables::X86InstInfo const *Info, uint16
const uint8_t Byte1 = ReadByte();
DecodedHeader options{};
if ((Byte1 & 0b10000000) == 0) {
LOGMAN_THROW_A(CTX->Config.Is64BitMode, "VEX.R shouldn't be 0 in 32-bit mode!");
DecodeInst->Flags |= DecodeFlags::FLAG_REX_XGPR_R;
}
if (Op == 0xC5) { // Two byte VEX
pp = Byte1 & 0b11;
options.vvvv = 15 - ((Byte1 & 0b01111000) >> 3);
@ -785,6 +790,13 @@ bool Decoder::NormalOpHeader(FEXCore::X86Tables::X86InstInfo const *Info, uint16
map_select = Byte1 & 0b11111;
options.vvvv = 15 - ((Byte2 & 0b01111000) >> 3);
options.w = (Byte2 & 0b10000000) != 0;
if ((Byte1 & 0b01000000) == 0) {
LOGMAN_THROW_A(CTX->Config.Is64BitMode, "VEX.X shouldn't be 0 in 32-bit mode!");
DecodeInst->Flags |= DecodeFlags::FLAG_REX_XGPR_X;
}
if (CTX->Config.Is64BitMode && (Byte1 & 0b00100000) == 0) {
DecodeInst->Flags |= DecodeFlags::FLAG_REX_XGPR_B;
}
if (!(map_select >= 1 && map_select <= 3)) {
LogMan::Msg::E("We don't understand a map_select of: %d", map_select);
return false;

View File

@ -1,18 +1,19 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0x7F",
"RBX": "0",
"RDX": "0xFF",
"RSI": "0"
"RSI": "0",
"R14": "0x7F",
"R15": "0x838"
}
}
%endif
; General extraction
mov rax, 0x7FFFFFFFFFFFFFFF
mov rbx, 0x838 ; Start at bit 56 and extract 8 bits
bextr rax, rax, rbx ; This results in 0x7F being placed into RAX
mov r14, 0x7FFFFFFFFFFFFFFF
mov r15, 0x838 ; Start at bit 56 and extract 8 bits
bextr r14, r14, r15 ; This results in 0x7F being placed into RAX
; Extraction with 0 bits should clear the destination
mov rbx, -1