my work on adding segment registers to LEA missed the
authorChris Lattner <sabre@nondot.org>
Tue, 13 Jul 2010 04:23:55 +0000 (04:23 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 13 Jul 2010 04:23:55 +0000 (04:23 +0000)
disassembler.  Remove some code from the disassembler to
compensate, unbreaking disassembly of lea's.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108226 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/Disassembler/X86Disassembler.cpp
test/MC/Disassembler/simple-tests.txt

index 8a5a6308704aa7edf7b08e2dccb1f7bd0f2b98a8..09f1584ce4d96c7ea229c2c3be527c185a4b4b88 100644 (file)
@@ -252,13 +252,8 @@ static bool translateRMRegister(MCInst &mcInst,
 /// @param mcInst       - The MCInst to append to.
 /// @param insn         - The instruction to extract Mod, R/M, and SIB fields
 ///                       from.
-/// @param sr           - Whether or not to emit the segment register.  The
-///                       LEA instruction does not expect a segment-register
-///                       operand.
 /// @return             - 0 on success; nonzero otherwise
-static bool translateRMMemory(MCInst &mcInst,
-                              InternalInstruction &insn,
-                              bool sr) {
+static bool translateRMMemory(MCInst &mcInst, InternalInstruction &insn) {
   // Addresses in an MCInst are represented as five operands:
   //   1. basereg       (register)  The R/M base, or (if there is a SIB) the 
   //                                SIB base
@@ -385,10 +380,7 @@ static bool translateRMMemory(MCInst &mcInst,
   mcInst.addOperand(scaleAmount);
   mcInst.addOperand(indexReg);
   mcInst.addOperand(displacement);
-  
-  if (sr)
-    mcInst.addOperand(segmentReg);
-  
+  mcInst.addOperand(segmentReg);
   return false;
 }
 
@@ -439,9 +431,8 @@ static bool translateRM(MCInst &mcInst,
   case TYPE_M1616:
   case TYPE_M1632:
   case TYPE_M1664:
-    return translateRMMemory(mcInst, insn, true);
   case TYPE_LEA:
-    return translateRMMemory(mcInst, insn, false);
+    return translateRMMemory(mcInst, insn);
   }
 }
   
index 369aa9ac0837e26f7910f04b6a5b32256ece3d12..dcc3763b7b7deea5b9e544fe4f4c44fb57c390b2 100644 (file)
@@ -57,3 +57,6 @@
 
 # CHECK: movq  %cr0, %rcx
 0x0f 0x20 0xc1
+
+# CHECK: leal  4(%rsp), %ecx
+0x8d 0x4c 0x24 0x04 
\ No newline at end of file