From 367b67df3e615e00525d455b3f83c1b8627e35c7 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 8 Jan 2015 07:41:30 +0000 Subject: [PATCH] [X86] Don't print 'dword ptr' or 'qword ptr' on the operand to some of the LEA variants in Intel syntax. The memory operand is inherently unsized. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225432 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../X86/InstPrinter/X86ATTInstPrinter.h | 4 ++++ .../X86/InstPrinter/X86IntelInstPrinter.h | 4 ++++ lib/Target/X86/X86InstrArithmetic.td | 4 ++-- lib/Target/X86/X86InstrInfo.td | 6 ++++-- test/MC/Disassembler/X86/intel-syntax-32.txt | 12 +++++++++++ test/MC/Disassembler/X86/intel-syntax.txt | 20 +++++++++++++++++++ test/MC/Disassembler/X86/simple-tests.txt | 15 ++++++++++++++ utils/TableGen/X86RecognizableInstr.cpp | 3 ++- 8 files changed, 63 insertions(+), 5 deletions(-) diff --git a/lib/Target/X86/InstPrinter/X86ATTInstPrinter.h b/lib/Target/X86/InstPrinter/X86ATTInstPrinter.h index 245e78face4..649dc84a0cf 100644 --- a/lib/Target/X86/InstPrinter/X86ATTInstPrinter.h +++ b/lib/Target/X86/InstPrinter/X86ATTInstPrinter.h @@ -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); } diff --git a/lib/Target/X86/InstPrinter/X86IntelInstPrinter.h b/lib/Target/X86/InstPrinter/X86IntelInstPrinter.h index b97f152f86a..641423d56d0 100644 --- a/lib/Target/X86/InstPrinter/X86IntelInstPrinter.h +++ b/lib/Target/X86/InstPrinter/X86IntelInstPrinter.h @@ -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); diff --git a/lib/Target/X86/X86InstrArithmetic.td b/lib/Target/X86/X86InstrArithmetic.td index 57efd7e1525..78efc4d5711 100644 --- a/lib/Target/X86/X86InstrArithmetic.td +++ b/lib/Target/X86/X86InstrArithmetic.td @@ -17,11 +17,11 @@ 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]>; diff --git a/lib/Target/X86/X86InstrInfo.td b/lib/Target/X86/X86InstrInfo.td index 069b48896b5..4903a730955 100644 --- a/lib/Target/X86/X86InstrInfo.td +++ b/lib/Target/X86/X86InstrInfo.td @@ -300,6 +300,8 @@ class X86VMemOperand; + def opaque32mem : X86MemOperand<"printopaquemem">; def opaque48mem : X86MemOperand<"printopaquemem">; def opaque80mem : X86MemOperand<"printopaquemem">; @@ -640,14 +642,14 @@ def i64i8imm : Operand { } def lea64_32mem : Operand { - 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 { - let PrintMethod = "printi64mem"; + let PrintMethod = "printanymem"; let MIOperandInfo = (ops GR64, i8imm, GR64_NOSP, i32imm, i8imm); let ParserMatchClass = X86MemAsmOperand; } diff --git a/test/MC/Disassembler/X86/intel-syntax-32.txt b/test/MC/Disassembler/X86/intel-syntax-32.txt index 2298823604a..66c87b8bc07 100644 --- a/test/MC/Disassembler/X86/intel-syntax-32.txt +++ b/test/MC/Disassembler/X86/intel-syntax-32.txt @@ -29,3 +29,15 @@ # 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 diff --git a/test/MC/Disassembler/X86/intel-syntax.txt b/test/MC/Disassembler/X86/intel-syntax.txt index 3689525d92f..0a628af02c1 100644 --- a/test/MC/Disassembler/X86/intel-syntax.txt +++ b/test/MC/Disassembler/X86/intel-syntax.txt @@ -152,3 +152,23 @@ # 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 + + diff --git a/test/MC/Disassembler/X86/simple-tests.txt b/test/MC/Disassembler/X86/simple-tests.txt index e6e9c7bc9cc..8fab6c9febc 100644 --- a/test/MC/Disassembler/X86/simple-tests.txt +++ b/test/MC/Disassembler/X86/simple-tests.txt @@ -90,9 +90,24 @@ # 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 diff --git a/utils/TableGen/X86RecognizableInstr.cpp b/utils/TableGen/X86RecognizableInstr.cpp index 64bbfba9be8..198ad109049 100644 --- a/utils/TableGen/X86RecognizableInstr.cpp +++ b/utils/TableGen/X86RecognizableInstr.cpp @@ -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) -- 2.34.1