[PATCH] D13316: Visibly fail if attempting to encode register AH, BH, CH, DH in a REX-prefixed instruction.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 8 21:14:34 PDT 2015


craig.topper added inline comments.

================
Comment at: lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp:77
@@ +76,3 @@
+  unsigned GetX86RegNum(const MCOperand &MO, bool HasREX = false) const {
+    unsigned Reg = MO.getReg();
+    if (X86::GR8_ABCD_HRegClass.contains(Reg))
----------------
The HasRex argument to this function isn't used by the body.

================
Comment at: lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp:1139
@@ -1130,3 +1138,3 @@
   if (is64BitMode(STI)) {
-    if (unsigned REX = DetermineREXPrefix(MI, TSFlags, Desc))
+    if (unsigned REX = DetermineREXPrefix(MI, TSFlags, Desc)) {
       EmitByte(0x40 | REX, CurByte, OS);
----------------
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?


http://reviews.llvm.org/D13316





More information about the llvm-commits mailing list