This is an archive of the discontinued LLVM Phabricator instance.

Visibly fail if attempting to encode register AH,BH,CH,DH in a REX-prefixed instruction.
ClosedPublic

Authored by dougk on Sep 30 2015, 4:33 PM.

Details

Summary

Ideally this could be caught in the asm parser, but that would essentially require that the parser ask the emitter if there is a valid encoding.
So the next best thing is to fail in the emitter rather than encode something that is not the instruction the user wrote.

Fixes PR25003

Diff Detail

Event Timeline

dougk updated this revision to Diff 36160.Sep 30 2015, 4:33 PM
dougk retitled this revision from to Visibly fail if attempting to encode register AH,BH,CH,DH in a REX-prefixed instruction..
dougk updated this object.
dougk added reviewers: craig.topper, chandlerc.
dougk added a subscriber: llvm-commits.
craig.topper added inline comments.Oct 8 2015, 9:14 PM
lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
76

The HasRex argument to this function isn't used by the body.

1138

I feel like you can just detect the error inside of DetermineREXPrefix rather than thread the EmittedREX everywhere. It examines every operand already to calculate the REX prefix bits. While examining every operand for REX can it also see if any are high registers and at the end if the REX is non-zero and any of the registers was a high register throw the error there?

craig.topper added inline comments.Oct 8 2015, 9:23 PM
lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
1138

In fact you could probably just detect it while that function looks for SPL, BPL, SIL, or DIL.

dougk updated this revision to Diff 39845.Nov 10 2015, 12:32 PM

Simpler fix per Craig Topper

craig.topper accepted this revision.Nov 10 2015, 7:17 PM
craig.topper edited edge metadata.

LGTM

This revision is now accepted and ready to land.Nov 10 2015, 7:17 PM
dougk closed this revision.Nov 11 2015, 8:34 AM