[PATCH] D11337: Fix bug in ins and outs operand order

Marina Yatsina marina.yatsina at intel.com
Sun Jul 19 01:51:38 PDT 2015


myatsina created this revision.
myatsina added reviewers: rnk, dwmw2.
myatsina added a subscriber: llvm-commits.
myatsina set the repository for this revision to rL LLVM.

The order of the operands for intel syntax is reverse to the order of the operands for AT&T syntax:
ins mem8/16/32, DX
outs DX, mem8/12/32
Current implementation causes "invalid operand for instruction" error for MS inline assembly.

Repository:
  rL LLVM

http://reviews.llvm.org/D11337

Files:
  lib/Target/X86/AsmParser/X86AsmParser.cpp
  test/MC/X86/intel-syntax.s

Index: test/MC/X86/intel-syntax.s
===================================================================
--- test/MC/X86/intel-syntax.s
+++ test/MC/X86/intel-syntax.s
@@ -665,3 +665,17 @@
 
 // CHECK: cmpnless %xmm1, %xmm0
 cmpnless xmm0, xmm1
+
+insb
+insw
+insd
+// CHECK: insb %dx, %es:(%rdi)
+// CHECK: insw %dx, %es:(%rdi)
+// CHECK: insl %dx, %es:(%rdi)
+
+outsb
+outsw
+outsd
+// CHECK: outsb (%rsi), %dx
+// CHECK: outsw (%rsi), %dx
+// CHECK: outsl (%rsi), %dx
\ No newline at end of file
Index: lib/Target/X86/AsmParser/X86AsmParser.cpp
===================================================================
--- lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -2229,8 +2229,8 @@
       (Name == "insb" || Name == "insw" || Name == "insl" ||
        Name == "insd" )) {
     if (isParsingIntelSyntax()) {
+      Operands.push_back(DefaultMemDIOperand(NameLoc));
       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));
@@ -2242,8 +2242,8 @@
       (Name == "outsb" || Name == "outsw" || Name == "outsl" ||
        Name == "outsd" )) {
     if (isParsingIntelSyntax()) {
+      Operands.push_back(X86Operand::CreateReg(X86::DX, NameLoc, NameLoc));
       Operands.push_back(DefaultMemSIOperand(NameLoc));
-      Operands.push_back(X86Operand::CreateReg(X86::DX, NameLoc, NameLoc));
     } else {
       Operands.push_back(DefaultMemSIOperand(NameLoc));
       Operands.push_back(X86Operand::CreateReg(X86::DX, NameLoc, NameLoc));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11337.30110.patch
Type: text/x-patch
Size: 1702 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150719/0a4e6890/attachment.bin>


More information about the llvm-commits mailing list