[X86] Don't print 'dword ptr' or 'qword ptr' on the operand to some of the LEA varian...
authorCraig Topper <craig.topper@gmail.com>
Thu, 8 Jan 2015 07:41:30 +0000 (07:41 +0000)
committerCraig Topper <craig.topper@gmail.com>
Thu, 8 Jan 2015 07:41:30 +0000 (07:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225432 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/InstPrinter/X86ATTInstPrinter.h
lib/Target/X86/InstPrinter/X86IntelInstPrinter.h
lib/Target/X86/X86InstrArithmetic.td
lib/Target/X86/X86InstrInfo.td
test/MC/Disassembler/X86/intel-syntax-32.txt
test/MC/Disassembler/X86/intel-syntax.txt
test/MC/Disassembler/X86/simple-tests.txt
utils/TableGen/X86RecognizableInstr.cpp

index 245e78face45ec16368cd727bca0e0f6b82287fc..649dc84a0cfcd09675284d07d2d7e6b80d09890b 100644 (file)
@@ -53,6 +53,10 @@ public:
   void printMemOffset(const MCInst *MI, unsigned OpNo, raw_ostream &OS);
   void printRoundingControl(const MCInst *MI, unsigned Op, raw_ostream &OS);
 
+  void printanymem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
+    printMemReference(MI, OpNo, O);
+  }
+
   void printopaquemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
     printMemReference(MI, OpNo, O);
   }
index b97f152f86a8661ae1a8137e18a94027b476cede..641423d56d03adb3e938cb2e94d0f7a54263de46 100644 (file)
@@ -44,6 +44,10 @@ public:
   void printDstIdx(const MCInst *MI, unsigned OpNo, raw_ostream &O);
   void printRoundingControl(const MCInst *MI, unsigned Op, raw_ostream &OS);
 
+  void printanymem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
+    printMemReference(MI, OpNo, O);
+  }
+
   void printopaquemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
     O << "opaque ptr ";
     printMemReference(MI, OpNo, O);
index 57efd7e1525e716fc96ec74430bd1512424ef724..78efc4d5711116ed21e8167c1ad49c5dd95cd14f 100644 (file)
 let SchedRW = [WriteLEA] in {
 let hasSideEffects = 0 in
 def LEA16r   : I<0x8D, MRMSrcMem,
-                 (outs GR16:$dst), (ins i32mem:$src),
+                 (outs GR16:$dst), (ins anymem:$src),
                  "lea{w}\t{$src|$dst}, {$dst|$src}", [], IIC_LEA_16>, OpSize16;
 let isReMaterializable = 1 in
 def LEA32r   : I<0x8D, MRMSrcMem,
-                 (outs GR32:$dst), (ins i32mem:$src),
+                 (outs GR32:$dst), (ins anymem:$src),
                  "lea{l}\t{$src|$dst}, {$dst|$src}",
                  [(set GR32:$dst, lea32addr:$src)], IIC_LEA>,
                  OpSize32, Requires<[Not64BitMode]>;
index 069b48896b523502b577ff353cd95dba83f3e8d8..4903a730955f991846dc59ceddddf4ad216b31ee 100644 (file)
@@ -300,6 +300,8 @@ class X86VMemOperand<RegisterClass RC, string printMethod,
   let MIOperandInfo = (ops ptr_rc, i8imm, RC, i32imm, i8imm);
 }
 
+def anymem : X86MemOperand<"printanymem">;
+
 def opaque32mem : X86MemOperand<"printopaquemem">;
 def opaque48mem : X86MemOperand<"printopaquemem">;
 def opaque80mem : X86MemOperand<"printopaquemem">;
@@ -640,14 +642,14 @@ def i64i8imm   : Operand<i64> {
 }
 
 def lea64_32mem : Operand<i32> {
-  let PrintMethod = "printi32mem";
+  let PrintMethod = "printanymem";
   let MIOperandInfo = (ops GR64, i8imm, GR64_NOSP, i32imm, i8imm);
   let ParserMatchClass = X86MemAsmOperand;
 }
 
 // Memory operands that use 64-bit pointers in both ILP32 and LP64.
 def lea64mem : Operand<i64> {
-  let PrintMethod = "printi64mem";
+  let PrintMethod = "printanymem";
   let MIOperandInfo = (ops GR64, i8imm, GR64_NOSP, i32imm, i8imm);
   let ParserMatchClass = X86MemAsmOperand;
 }
index 2298823604aa8872d561990758c5a80f8af850d1..66c87b8bc07b526dc1780b62862b6f33946aec7b 100644 (file)
 
 # CHECK: mov dword ptr [878082192], eax
 0xa3 0x90 0x78 0x56 0x34
+
+# CHECK: lea   cx, [si + 4]
+0x67 0x66 0x8d 0x4c 0x04
+
+# CHECK: lea   ecx, [si + 4]
+0x67 0x8d 0x4c 0x04 
+
+# CHECK: lea   cx, [esp + 4]
+0x66 0x8d 0x4c 0x24 0x04 
+
+# CHECK: lea   ecx, [esp + 4]
+0x8d 0x4c 0x24 0x04 
index 3689525d92fa96eb16cfb05bc4acde2b7bd6cf6a..0a628af02c157eecbc9afa52c5e718ed042c9c03 100644 (file)
 
 # CHECK: movabs qword ptr [-6066930261531658096], rax
 0x48 0xa3 0x90 0x78 0x56 0x34 0x12 0xef 0xcd 0xab
+
+# CHECK: lea   cx, [esp + 4]
+0x67 0x66 0x8d 0x4c 0x24 0x04 
+
+# CHECK: lea   ecx, [esp + 4]
+0x67 0x8d 0x4c 0x24 0x04 
+
+# CHECK: lea   rcx, [esp + 4]
+0x67 0x48 0x8d 0x4c 0x24 0x04 
+
+# CHECK: lea   cx, [rsp + 4]
+0x66 0x8d 0x4c 0x24 0x04 
+
+# CHECK: lea   ecx, [rsp + 4]
+0x8d 0x4c 0x24 0x04 
+
+# CHECK: lea   rcx, [rsp + 4]
+0x48 0x8d 0x4c 0x24 0x04 
+
+
index e6e9c7bc9cc5bd3dc34fa0337f3fbce9fc9e02de..8fab6c9febcb99e0222b40b19cffeb7f5b74c0db 100644 (file)
 # CHECK: movq  %cr0, %rcx
 0x0f 0x20 0xc1
 
+# CHECK: leaw  4(%esp), %cx
+0x67 0x66 0x8d 0x4c 0x24 0x04 
+
+# CHECK: leal  4(%esp), %ecx
+0x67 0x8d 0x4c 0x24 0x04 
+
+# CHECK: leaq  4(%esp), %rcx
+0x67 0x48 0x8d 0x4c 0x24 0x04 
+
+# CHECK: leaw  4(%rsp), %cx
+0x66 0x8d 0x4c 0x24 0x04 
+
 # CHECK: leal  4(%rsp), %ecx
 0x8d 0x4c 0x24 0x04 
 
+# CHECK: leaq  4(%rsp), %rcx
+0x48 0x8d 0x4c 0x24 0x04 
+
 # CHECK: enter $1, $2
 0xc8 0x01 0x00 0x02
 
index 64bbfba9be8bed525a7054cb76bccd5fd3906b94..198ad1090493b763d98c69c918a644b5d7c223f6 100644 (file)
@@ -964,6 +964,7 @@ OperandType RecognizableInstr::typeFromString(const std::string &s,
   TYPE("lea64mem",            TYPE_LEA)
   TYPE("VR64",                TYPE_MM64)
   TYPE("i64imm",              TYPE_IMMv)
+  TYPE("anymem",              TYPE_M)
   TYPE("opaque32mem",         TYPE_M1616)
   TYPE("opaque48mem",         TYPE_M1632)
   TYPE("opaque80mem",         TYPE_M1664)
@@ -1176,9 +1177,9 @@ RecognizableInstr::memoryEncodingFromString(const std::string &s,
   ENCODING("i256mem",         ENCODING_RM)
   ENCODING("i512mem",         ENCODING_RM)
   ENCODING("f80mem",          ENCODING_RM)
-  ENCODING("lea32mem",        ENCODING_RM)
   ENCODING("lea64_32mem",     ENCODING_RM)
   ENCODING("lea64mem",        ENCODING_RM)
+  ENCODING("anymem",          ENCODING_RM)
   ENCODING("opaque32mem",     ENCODING_RM)
   ENCODING("opaque48mem",     ENCODING_RM)
   ENCODING("opaque80mem",     ENCODING_RM)