From 0ff018e5007ca00066af588b48160fd08c5cf95c Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 22 Jan 2014 15:08:55 +0000 Subject: [PATCH] [x86] Allow segment and address-size overrides for INS[BWLQ] (PR9385) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199809 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/AsmParser/X86AsmParser.cpp | 21 +++++++++++---------- lib/Target/X86/X86InstrSystem.td | 9 ++++++--- test/MC/X86/index-operations.s | 5 +++++ test/MC/X86/x86-16.s | 6 +++--- test/MC/X86/x86-32.s | 6 +++--- test/MC/X86/x86-64.s | 6 +++--- 6 files changed, 31 insertions(+), 22 deletions(-) diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index a23f5a298a3..56896a7a359 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -2332,16 +2332,17 @@ ParseInstruction(ParseInstructionInfo &Info, StringRef Name, SMLoc NameLoc, delete &Op; } } - // Transform "ins[bwl] %dx, %es:(%edi)" into "ins[bwl]" - if (Name.startswith("ins") && Operands.size() == 3 && - (Name == "insb" || Name == "insw" || Name == "insl")) { - X86Operand &Op = *(X86Operand*)Operands.begin()[1]; - X86Operand &Op2 = *(X86Operand*)Operands.begin()[2]; - if (Op.isReg() && Op.getReg() == X86::DX && isDstOp(Op2)) { - Operands.pop_back(); - Operands.pop_back(); - delete &Op; - delete &Op2; + + // Append default arguments to "ins[bwld]" + if (Name.startswith("ins") && Operands.size() == 1 && + (Name == "insb" || Name == "insw" || Name == "insl" || + Name == "insd" )) { + if (isParsingIntelSyntax()) { + Operands.push_back(X86Operand::CreateReg(X86::DX, NameLoc, NameLoc)); + Operands.push_back(DefaultMemDIOperand(NameLoc)); + } else { + Operands.push_back(X86Operand::CreateReg(X86::DX, NameLoc, NameLoc)); + Operands.push_back(DefaultMemDIOperand(NameLoc)); } } diff --git a/lib/Target/X86/X86InstrSystem.td b/lib/Target/X86/X86InstrSystem.td index 6177d17b8f3..e1b008e7fad 100644 --- a/lib/Target/X86/X86InstrSystem.td +++ b/lib/Target/X86/X86InstrSystem.td @@ -116,9 +116,12 @@ let Uses = [EAX] in def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i8imm:$port), "out{l}\t{%eax, $port|$port, eax}", [], IIC_OUT_IR>, OpSize16; -def IN8 : I<0x6C, RawFrm, (outs), (ins), "ins{b}", [], IIC_INS>; -def IN16 : I<0x6D, RawFrm, (outs), (ins), "ins{w}", [], IIC_INS>, OpSize; -def IN32 : I<0x6D, RawFrm, (outs), (ins), "ins{l}", [], IIC_INS>, OpSize16; +def IN8 : I<0x6C, RawFrmDst, (outs dstidx8:$dst), (ins), + "insb\t{%dx, $dst|$dst, dx}", [], IIC_INS>; +def IN16 : I<0x6D, RawFrmDst, (outs dstidx16:$dst), (ins), + "insw\t{%dx, $dst|$dst, dx}", [], IIC_INS>, OpSize; +def IN32 : I<0x6D, RawFrmDst, (outs dstidx32:$dst), (ins), + "ins{l|d}\t{%dx, $dst|$dst, dx}", [], IIC_INS>, OpSize16; } // SchedRW //===----------------------------------------------------------------------===// diff --git a/test/MC/X86/index-operations.s b/test/MC/X86/index-operations.s index 85bae21eae1..9f69b0b7849 100644 --- a/test/MC/X86/index-operations.s +++ b/test/MC/X86/index-operations.s @@ -139,3 +139,8 @@ outsw %fs:(%esi), %dx // 64: outsw %fs:(%esi), %dx # encoding: [0x66,0x64,0x67,0x6f] // 32: outsw %fs:(%esi), %dx # encoding: [0x66,0x64,0x6f] // 16: outsw %fs:(%esi), %dx # encoding: [0x64,0x67,0x6f] + +insw %dx, (%edi) +// 64: insw %dx, %es:(%edi) # encoding: [0x66,0x67,0x6d] +// 32: insw %dx, %es:(%edi) # encoding: [0x66,0x6d] +// 16: insw %dx, %es:(%edi) # encoding: [0x67,0x6d] diff --git a/test/MC/X86/x86-16.s b/test/MC/X86/x86-16.s index a147cddb850..1f87c8159f6 100644 --- a/test/MC/X86/x86-16.s +++ b/test/MC/X86/x86-16.s @@ -809,17 +809,17 @@ pshufw $90, %mm4, %mm0 outsl %ds:(%si), %dx outsl (%si), %dx -// CHECK: insb # encoding: [0x6c] +// CHECK: insb %dx, %es:(%di) # encoding: [0x6c] // CHECK: insb insb insb %dx, %es:(%di) -// CHECK: insw # encoding: [0x6d] +// CHECK: insw %dx, %es:(%di) # encoding: [0x6d] // CHECK: insw insw insw %dx, %es:(%di) -// CHECK: insl # encoding: [0x66,0x6d] +// CHECK: insl %dx, %es:(%di) # encoding: [0x66,0x6d] // CHECK: insl insl insl %dx, %es:(%di) diff --git a/test/MC/X86/x86-32.s b/test/MC/X86/x86-32.s index cb5a36a1255..bebaa65227f 100644 --- a/test/MC/X86/x86-32.s +++ b/test/MC/X86/x86-32.s @@ -885,17 +885,17 @@ pshufw $90, %mm4, %mm0 outsl %ds:(%esi), %dx outsl (%esi), %dx -// CHECK: insb # encoding: [0x6c] +// CHECK: insb %dx, %es:(%edi) # encoding: [0x6c] // CHECK: insb insb insb %dx, %es:(%edi) -// CHECK: insw # encoding: [0x66,0x6d] +// CHECK: insw %dx, %es:(%edi) # encoding: [0x66,0x6d] // CHECK: insw insw insw %dx, %es:(%edi) -// CHECK: insl # encoding: [0x6d] +// CHECK: insl %dx, %es:(%edi) # encoding: [0x6d] // CHECK: insl insl insl %dx, %es:(%edi) diff --git a/test/MC/X86/x86-64.s b/test/MC/X86/x86-64.s index f6763518367..bb81d2a0021 100644 --- a/test/MC/X86/x86-64.s +++ b/test/MC/X86/x86-64.s @@ -1070,17 +1070,17 @@ xsetbv // CHECK: xsetbv # encoding: [0x0f,0x01,0xd1] outsl %ds:(%rsi), %dx outsl (%rsi), %dx -// CHECK: insb # encoding: [0x6c] +// CHECK: insb %dx, %es:(%rdi) # encoding: [0x6c] // CHECK: insb insb insb %dx, %es:(%rdi) -// CHECK: insw # encoding: [0x66,0x6d] +// CHECK: insw %dx, %es:(%rdi) # encoding: [0x66,0x6d] // CHECK: insw insw insw %dx, %es:(%rdi) -// CHECK: insl # encoding: [0x6d] +// CHECK: insl %dx, %es:(%rdi) # encoding: [0x6d] // CHECK: insl insl insl %dx, %es:(%rdi) -- 2.34.1