Skip to content

Commit 1c8b0a1

Browse files
committed
Approved by Chris
$ svn merge -c 113894 https://llvm.org/svn/llvm-project/llvm/trunk --- Merging r113894 into '.': U test/MC/AsmParser/X86/x86_instructions.s U lib/Target/X86/AsmParser/X86AsmParser.cpp Log: add a terrible hack to allow out with dx is parens, a gas bug. This fixes PR8114 llvm-svn: 113896
1 parent 7c9f068 commit 1c8b0a1

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,20 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
815815
Operands.erase(Operands.begin() + 1);
816816
}
817817

818+
// FIXME: Hack to handle "out[bwl]? %al, (%dx)" -> "outb %al, %dx".
819+
if ((Name == "outb" || Name == "outw" || Name == "outl" || Name == "out") &&
820+
Operands.size() == 3) {
821+
X86Operand &Op = *(X86Operand*)Operands.back();
822+
if (Op.isMem() && Op.Mem.SegReg == 0 &&
823+
isa<MCConstantExpr>(Op.Mem.Disp) &&
824+
cast<MCConstantExpr>(Op.Mem.Disp)->getValue() == 0 &&
825+
Op.Mem.BaseReg == MatchRegisterName("dx") && Op.Mem.IndexReg == 0) {
826+
SMLoc Loc = Op.getEndLoc();
827+
Operands.back() = X86Operand::CreateReg(Op.Mem.BaseReg, Loc, Loc);
828+
delete &Op;
829+
}
830+
}
831+
818832
// FIXME: Hack to handle "f{mul*,add*,sub*,div*} $op, st(0)" the same as
819833
// "f{mul*,add*,sub*,div*} $op"
820834
if ((Name.startswith("fmul") || Name.startswith("fadd") ||

llvm/test/MC/AsmParser/X86/x86_instructions.s

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,12 @@ imul $12, %eax
164164

165165
// CHECK: imull %ecx, %eax
166166
imull %ecx, %eax
167+
168+
// PR8114
169+
// CHECK: outb %al, %dx
170+
// CHECK: outw %ax, %dx
171+
// CHECK: outl %eax, %dx
172+
173+
out %al, (%dx)
174+
out %ax, (%dx)
175+
outl %eax, (%dx)

0 commit comments

Comments
 (0)