add a terrible hack to allow out with dx is parens, a gas bug.
authorChris Lattner <sabre@nondot.org>
Tue, 14 Sep 2010 23:34:29 +0000 (23:34 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 14 Sep 2010 23:34:29 +0000 (23:34 +0000)
This fixes PR8114

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113894 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/AsmParser/X86AsmParser.cpp
test/MC/AsmParser/X86/x86_instructions.s

index 6a664ad4ce1c718b96b99d630ebeaf13333cab27..dae7d1298eb4eaeff91eee568eb96d14778cfd70 100644 (file)
@@ -857,6 +857,20 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
     std::swap(Operands[1], Operands[2]);
   }
   
+  // FIXME: Hack to handle "out[bwl]? %al, (%dx)" -> "outb %al, %dx".
+  if ((Name == "outb" || Name == "outw" || Name == "outl" || Name == "out") &&
+      Operands.size() == 3) {
+    X86Operand &Op = *(X86Operand*)Operands.back();
+    if (Op.isMem() && Op.Mem.SegReg == 0 &&
+        isa<MCConstantExpr>(Op.Mem.Disp) &&
+        cast<MCConstantExpr>(Op.Mem.Disp)->getValue() == 0 &&
+        Op.Mem.BaseReg == MatchRegisterName("dx") && Op.Mem.IndexReg == 0) {
+      SMLoc Loc = Op.getEndLoc();
+      Operands.back() = X86Operand::CreateReg(Op.Mem.BaseReg, Loc, Loc);
+      delete &Op;
+    }
+  }
+  
   // FIXME: Hack to handle "f{mul*,add*,sub*,div*} $op, st(0)" the same as
   // "f{mul*,add*,sub*,div*} $op"
   if ((Name.startswith("fmul") || Name.startswith("fadd") ||
index b895de35cce114ed98926075e76fb51c9847b1d4..d4444f895237233c98ad8098a30c5300eba3ea7d 100644 (file)
@@ -200,3 +200,13 @@ inw        %dx
 outb   $0x7f
 outw   %dx
 inl    %dx
+
+
+// PR8114
+// CHECK: outb %al, %dx
+// CHECK: outw %ax, %dx
+// CHECK: outl %eax, %dx
+
+out %al, (%dx)
+out %ax, (%dx)
+outl %eax, (%dx)