summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2014-01-22 15:08:55 +0000
committerDavid Woodhouse <dwmw2@infradead.org>2014-01-22 15:08:55 +0000
commit0ff018e5007ca00066af588b48160fd08c5cf95c (patch)
tree4203e8f792bfbb8a2e1833b7f553673f90a6c048
parentaf588b9f0eb5b113e459918737a855be8782e112 (diff)
downloadllvm-0ff018e5007ca00066af588b48160fd08c5cf95c.tar.gz
llvm-0ff018e5007ca00066af588b48160fd08c5cf95c.tar.bz2
llvm-0ff018e5007ca00066af588b48160fd08c5cf95c.tar.xz
[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
-rw-r--r--lib/Target/X86/AsmParser/X86AsmParser.cpp21
-rw-r--r--lib/Target/X86/X86InstrSystem.td9
-rw-r--r--test/MC/X86/index-operations.s5
-rw-r--r--test/MC/X86/x86-16.s6
-rw-r--r--test/MC/X86/x86-32.s6
-rw-r--r--test/MC/X86/x86-64.s6
6 files changed, 31 insertions, 22 deletions
diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp
index a23f5a298a..56896a7a35 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 6177d17b8f..e1b008e7fa 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 85bae21eae..9f69b0b784 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 a147cddb85..1f87c8159f 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 cb5a36a125..bebaa65227 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 f676351836..bb81d2a002 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)