[X86] .code16: temporarily set Mode32Bit when matching an instruction with the data32...
authorFangrui Song <i@maskray.me>
Tue, 6 Oct 2020 15:26:12 +0000 (08:26 -0700)
committerFangrui Song <i@maskray.me>
Tue, 6 Oct 2020 15:32:03 +0000 (08:32 -0700)
commit43c7dc52f12973b306910a161bcf150d70d33504
tree1be7b7e00a8ea6483d317144c87eb82bd615ac03
parent8d2a0c115e245e86bba4ea1c70e6d34b552031a9
[X86] .code16: temporarily set Mode32Bit when matching an instruction with the data32 prefix

PR47632

This allows MC to match `data32 ...` as one instruction instead of two (data32 without insn + insn).

The compatibility with GNU as improves: `data32 ljmp` will be matched as ljmpl.
`data32 lgdt 4(%eax)` will be matched as `lgdtl` (prefixes: 0x67 0x66, instead
of 0x66 0x67).

GNU as supports many other `data32 *w` as `*l`. We currently just hard code
`data32 callw` and `data32 ljmpw`.  Generalizing the suffix replacement is
tricky and requires a think about the "bwlq" appending suffix rules in MatchAndEmitATTInstruction.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D88772
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
llvm/test/MC/X86/data-prefix-fail.s
llvm/test/MC/X86/x86-16.s