[x86] Allow segment and address-size overrides for INS[BWLQ] (PR9385)
authorDavid Woodhouse <dwmw2@infradead.org>
Wed, 22 Jan 2014 15:08:55 +0000 (15:08 +0000)
committerDavid Woodhouse <dwmw2@infradead.org>
Wed, 22 Jan 2014 15:08:55 +0000 (15:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199809 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/AsmParser/X86AsmParser.cpp
lib/Target/X86/X86InstrSystem.td
test/MC/X86/index-operations.s
test/MC/X86/x86-16.s
test/MC/X86/x86-32.s
test/MC/X86/x86-64.s

index a23f5a298a34078f56c84cc3663fc301b486f3bb..56896a7a359c0339ab276bea171993b558288241 100644 (file)
@@ -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));
     }
   }
 
index 6177d17b8f3ee08511673871cf2d7efe160f395a..e1b008e7fadf0ffd57e65fffb5a19014dcbf350d 100644 (file)
@@ -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
 
 //===----------------------------------------------------------------------===//
index 85bae21eae11db64a9ed292c327803f73027fa19..9f69b0b784991830bd1b7a5e0465d16a16880b79 100644 (file)
@@ -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]
index a147cddb8506ba21363d24196cb60738154dc571..1f87c8159f6732a0409c5bb37c2a69f69fb6c4d7 100644 (file)
@@ -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)
index cb5a36a1255e04e4ef5cc90535ff1391fc745e21..bebaa65227f151cd2ce9ee057024c188a2a98a2f 100644 (file)
@@ -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)
index f67635183675bc288c7e78943f59195a66bbc36d..bb81d2a0021c230a7fa7fec4a3b8fb48dca92f9c 100644 (file)
@@ -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)