Page MenuHomePhabricator

[X86] .code16: temporarily set Mode32Bit when matching an instruction with the data32 prefix
ClosedPublic

Authored by MaskRay on Oct 2 2020, 9:01 PM.

Details

Summary

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.

Diff Detail

Event Timeline

MaskRay created this revision.Oct 2 2020, 9:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 2 2020, 9:01 PM
MaskRay requested review of this revision.Oct 2 2020, 9:01 PM
MaskRay retitled this revision from [X86] Temporarily set Mode32Bit when matching an instruction with the data32 prefix to [X86] .code16: temporarily set Mode32Bit when matching an instruction with the data32 prefix.Oct 2 2020, 9:02 PM
MaskRay edited the summary of this revision. (Show Details)Oct 2 2020, 9:10 PM
craig.topper added inline comments.Oct 5 2020, 5:11 PM
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
3092

So unlike the previous code we're allowing plain "call" to be selected based on the forced mode?

MaskRay marked an inline comment as done.Oct 5 2020, 5:49 PM
MaskRay added inline comments.
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
3092

Now we match data32 something as one instruction instead of two.

The "call" special case can be dropped. Generalizing the suffix replacement is tricky and requires a think about the "bwlq" suffix rules on 3842.

This revision is now accepted and ready to land.Oct 5 2020, 11:35 PM
This revision was landed with ongoing or failed builds.Oct 6 2020, 8:32 AM
This revision was automatically updated to reflect the committed changes.
MaskRay marked an inline comment as done.
MaskRay edited the summary of this revision. (Show Details)Oct 6 2020, 8:34 AM