This is an archive of the discontinued LLVM Phabricator instance.

[X86] Add segment and address-size override prefixes
ClosedPublic

Authored by void on Jan 14 2021, 2:38 PM.

Details

Summary

X86 allows for the "addr32" and "addr16" address size override prefixes.
Also, these and the segment override prefixes should be recognized as
valid prefixes.

Diff Detail

Event Timeline

void created this revision.Jan 14 2021, 2:38 PM
void requested review of this revision.Jan 14 2021, 2:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 14 2021, 2:38 PM
pengfei added a subscriber: skan.Jan 15 2021, 9:12 PM
skan added inline comments.Jan 17 2021, 10:23 PM
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
3263–3269

Hmm, could you capitalize the first char of "isPrefix" by the way?

llvm/lib/Target/X86/X86InstrSystem.td
180–182

A minor suggestion: Add tests to check the predicates "In32BitMode", "In64BitMode" for addr16/32.

llvm/test/MC/X86/addr16-32.s
25

Remove this line.

llvm/test/MC/X86/segment-prefix.s
22

Remove this line.

void updated this revision to Diff 317270.Jan 17 2021, 11:37 PM
void marked 3 inline comments as done.

Fixed variable name and removed excess test lines.

llvm/lib/Target/X86/X86InstrSystem.td
180–182

The tests which include ".code16"/".code32", etc., should be doing this already.

skan added a reviewer: skan.Jan 17 2021, 11:53 PM
skan accepted this revision.Jan 18 2021, 12:17 AM

LGTM. Before this patch, we could only write code like

CS
insl

addr32/addr16 and CS/DS/ES/FS/GS/SS are prefixes, so they should be allowed to be written before the instruction in the same line, and GNU-AS does support this syntax.
One behavior different from GNU-AS is that as rejects es and ss in 64-bit mode, but this has beyond the purpose of this patch.

This revision is now accepted and ready to land.Jan 18 2021, 12:17 AM
This revision was automatically updated to reflect the committed changes.