llvm-project
bdddd3e7 - [X86] Apply the data32 mode switch in the Intel matcher (#212417)

Commit
13 days ago
[X86] Apply the data32 mode switch in the Intel matcher (#212417) In .code16, `data32 push 8` in Intel syntax assembled as `pushw $8` with the 66 prefix dropped, and `data32 push 0x1234` truncated the immediate to 16 bits. AT&T syntax gets both right. `ForcedDataPrefix` is set while parsing either syntax, but only `matchAndEmitATTInstruction` switched mode on it, so the Intel path took the operand size from the mode and never saw the prefix. Do the same switch in `matchAndEmitIntelInstruction`. The mode has to go back to 16-bit before the instruction is emitted, otherwise the 32-bit form is emitted without its 66 prefix. That function has several error returns partway through matching, so a scope guard covers those. Encodings after the change match both AT&T syntax and GNU as: ``` data32 push 8 [0x6a,0x08] -> [0x66,0x6a,0x08] data32 push 0x1234 [0x68,0x34,0x12] -> [0x66,0x68,0x34,0x12,0x00,0x00] ``` Fixes #156286
Author
Parents
Loading