This is an archive of the discontinued LLVM Phabricator instance.

[X86] Error on using h-registers with REX prefix in the assembler instead of leaving it to a fatal error in the encoder.
ClosedPublic

Authored by craig.topper on Oct 20 2020, 4:33 PM.

Diff Detail

Event Timeline

craig.topper created this revision.Oct 20 2020, 4:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 20 2020, 4:33 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
craig.topper requested review of this revision.Oct 20 2020, 4:33 PM
pengfei added inline comments.Oct 20 2020, 6:28 PM
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
3632

It seems X86MCCodeEmitter::emitREXPrefix has more detailed check for each form. Especially, the commens says "Emit REX prefix ... 2) non-default operand size". Is it not covered by this case?

craig.topper added inline comments.Oct 20 2020, 6:53 PM
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
3632

I'm not sure what the difference is between "1) 64-bit instructions" and "2) non-default operand size".

I think the form code is just mapping registers to different bits in the REX prefix. I don't think the assembler error needs to care about the exact bits, just that some bit will be affected by the operands. But I might be wrong.

Skip the REX prefix check if encoding is VEX/EVEX/XOP.

pengfei accepted this revision.Oct 20 2020, 7:43 PM

LGTM. Thanks.

This revision is now accepted and ready to land.Oct 20 2020, 7:43 PM
This revision was landed with ongoing or failed builds.Oct 20 2020, 9:57 PM
This revision was automatically updated to reflect the committed changes.
MaskRay added inline comments.Oct 20 2020, 10:33 PM
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
3641

LG.

minor nit: https://llvm.org/docs/CodingStandards.html#error-and-warning-messages the majority of error messages don't end with a period.