[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.

llvm-svn: 225432
This commit is contained in:
Craig Topper 2015-01-08 07:41:30 +00:00
parent 4535ecb1f3
commit 7c10252943
8 changed files with 63 additions and 5 deletions

View File

@ -53,6 +53,10 @@ public:
void printMemOffset(const MCInst *MI, unsigned OpNo, raw_ostream &OS); void printMemOffset(const MCInst *MI, unsigned OpNo, raw_ostream &OS);
void printRoundingControl(const MCInst *MI, unsigned Op, 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) { void printopaquemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
printMemReference(MI, OpNo, O); printMemReference(MI, OpNo, O);
} }

View File

@ -44,6 +44,10 @@ public:
void printDstIdx(const MCInst *MI, unsigned OpNo, raw_ostream &O); void printDstIdx(const MCInst *MI, unsigned OpNo, raw_ostream &O);
void printRoundingControl(const MCInst *MI, unsigned Op, 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) { void printopaquemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
O << "opaque ptr "; O << "opaque ptr ";
printMemReference(MI, OpNo, O); printMemReference(MI, OpNo, O);

View File

@ -17,11 +17,11 @@
let SchedRW = [WriteLEA] in { let SchedRW = [WriteLEA] in {
let hasSideEffects = 0 in let hasSideEffects = 0 in
def LEA16r : I<0x8D, MRMSrcMem, 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; "lea{w}\t{$src|$dst}, {$dst|$src}", [], IIC_LEA_16>, OpSize16;
let isReMaterializable = 1 in let isReMaterializable = 1 in
def LEA32r : I<0x8D, MRMSrcMem, def LEA32r : I<0x8D, MRMSrcMem,
(outs GR32:$dst), (ins i32mem:$src), (outs GR32:$dst), (ins anymem:$src),
"lea{l}\t{$src|$dst}, {$dst|$src}", "lea{l}\t{$src|$dst}, {$dst|$src}",
[(set GR32:$dst, lea32addr:$src)], IIC_LEA>, [(set GR32:$dst, lea32addr:$src)], IIC_LEA>,
OpSize32, Requires<[Not64BitMode]>; OpSize32, Requires<[Not64BitMode]>;

View File

@ -300,6 +300,8 @@ class X86VMemOperand<RegisterClass RC, string printMethod,
let MIOperandInfo = (ops ptr_rc, i8imm, RC, i32imm, i8imm); let MIOperandInfo = (ops ptr_rc, i8imm, RC, i32imm, i8imm);
} }
def anymem : X86MemOperand<"printanymem">;
def opaque32mem : X86MemOperand<"printopaquemem">; def opaque32mem : X86MemOperand<"printopaquemem">;
def opaque48mem : X86MemOperand<"printopaquemem">; def opaque48mem : X86MemOperand<"printopaquemem">;
def opaque80mem : X86MemOperand<"printopaquemem">; def opaque80mem : X86MemOperand<"printopaquemem">;
@ -640,14 +642,14 @@ def i64i8imm : Operand<i64> {
} }
def lea64_32mem : Operand<i32> { def lea64_32mem : Operand<i32> {
let PrintMethod = "printi32mem"; let PrintMethod = "printanymem";
let MIOperandInfo = (ops GR64, i8imm, GR64_NOSP, i32imm, i8imm); let MIOperandInfo = (ops GR64, i8imm, GR64_NOSP, i32imm, i8imm);
let ParserMatchClass = X86MemAsmOperand; let ParserMatchClass = X86MemAsmOperand;
} }
// Memory operands that use 64-bit pointers in both ILP32 and LP64. // Memory operands that use 64-bit pointers in both ILP32 and LP64.
def lea64mem : Operand<i64> { def lea64mem : Operand<i64> {
let PrintMethod = "printi64mem"; let PrintMethod = "printanymem";
let MIOperandInfo = (ops GR64, i8imm, GR64_NOSP, i32imm, i8imm); let MIOperandInfo = (ops GR64, i8imm, GR64_NOSP, i32imm, i8imm);
let ParserMatchClass = X86MemAsmOperand; let ParserMatchClass = X86MemAsmOperand;
} }

View File

@ -29,3 +29,15 @@
# CHECK: mov dword ptr [878082192], eax # CHECK: mov dword ptr [878082192], eax
0xa3 0x90 0x78 0x56 0x34 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

View File

@ -152,3 +152,23 @@
# CHECK: movabs qword ptr [-6066930261531658096], rax # CHECK: movabs qword ptr [-6066930261531658096], rax
0x48 0xa3 0x90 0x78 0x56 0x34 0x12 0xef 0xcd 0xab 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

View File

@ -90,9 +90,24 @@
# CHECK: movq %cr0, %rcx # CHECK: movq %cr0, %rcx
0x0f 0x20 0xc1 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 # CHECK: leal 4(%rsp), %ecx
0x8d 0x4c 0x24 0x04 0x8d 0x4c 0x24 0x04
# CHECK: leaq 4(%rsp), %rcx
0x48 0x8d 0x4c 0x24 0x04
# CHECK: enter $1, $2 # CHECK: enter $1, $2
0xc8 0x01 0x00 0x02 0xc8 0x01 0x00 0x02

View File

@ -964,6 +964,7 @@ OperandType RecognizableInstr::typeFromString(const std::string &s,
TYPE("lea64mem", TYPE_LEA) TYPE("lea64mem", TYPE_LEA)
TYPE("VR64", TYPE_MM64) TYPE("VR64", TYPE_MM64)
TYPE("i64imm", TYPE_IMMv) TYPE("i64imm", TYPE_IMMv)
TYPE("anymem", TYPE_M)
TYPE("opaque32mem", TYPE_M1616) TYPE("opaque32mem", TYPE_M1616)
TYPE("opaque48mem", TYPE_M1632) TYPE("opaque48mem", TYPE_M1632)
TYPE("opaque80mem", TYPE_M1664) TYPE("opaque80mem", TYPE_M1664)
@ -1176,9 +1177,9 @@ RecognizableInstr::memoryEncodingFromString(const std::string &s,
ENCODING("i256mem", ENCODING_RM) ENCODING("i256mem", ENCODING_RM)
ENCODING("i512mem", ENCODING_RM) ENCODING("i512mem", ENCODING_RM)
ENCODING("f80mem", ENCODING_RM) ENCODING("f80mem", ENCODING_RM)
ENCODING("lea32mem", ENCODING_RM)
ENCODING("lea64_32mem", ENCODING_RM) ENCODING("lea64_32mem", ENCODING_RM)
ENCODING("lea64mem", ENCODING_RM) ENCODING("lea64mem", ENCODING_RM)
ENCODING("anymem", ENCODING_RM)
ENCODING("opaque32mem", ENCODING_RM) ENCODING("opaque32mem", ENCODING_RM)
ENCODING("opaque48mem", ENCODING_RM) ENCODING("opaque48mem", ENCODING_RM)
ENCODING("opaque80mem", ENCODING_RM) ENCODING("opaque80mem", ENCODING_RM)