fix an x86-64 encoding bug Daniel found.
authorChris Lattner <sabre@nondot.org>
Thu, 18 Mar 2010 20:04:36 +0000 (20:04 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 18 Mar 2010 20:04:36 +0000 (20:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98855 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86MCCodeEmitter.cpp
test/MC/AsmParser/X86/x86_64-new-encoder.s

index 4547a3a33138e6534d063ce5604cc92d06a70b7a..f533b1572c65dcb42dc181c25b21ffa41452923e 100644 (file)
@@ -278,7 +278,10 @@ void X86MCCodeEmitter::EmitMemModRMByte(const MCInst &MI, unsigned Op,
     // Emit the normal disp32 encoding.
     EmitByte(ModRMByte(2, RegOpcodeField, 4), CurByte, OS);
     ForceDisp32 = true;
-  } else if (Disp.getImm() == 0 && BaseReg != X86::EBP) {
+  } else if (Disp.getImm() == 0 &&
+             // Base reg can't be anything that ends up with '5' as the base
+             // reg, it is the magic [*] nomenclature that indicates no base.
+             BaseRegNo != N86::EBP) {
     // Emit no displacement ModR/M byte
     EmitByte(ModRMByte(0, RegOpcodeField, 4), CurByte, OS);
   } else if (isDisp8(Disp.getImm())) {
index 712803e41febc9c2e50708cf222fd4d567dd2b9e..d6d8dde2708541bc4cb8277d4451656841193bf5 100644 (file)
@@ -35,3 +35,7 @@ addq $-424, %rax
 // CHECK:  fixup A - offset: 3, value: _foo@GOTPCREL, kind: reloc_riprel_4byte_movq_load
 movq _foo@GOTPCREL(%rip), %rax
 
+
+// CHECK: movq (%r13,%rax,8), %r13
+// CHECK:  encoding: [0x4d,0x8b,0x6c,0xc5,0x00]
+movq 0x00(%r13,%rax,8),%r13