aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/X86/AsmParser/X86AsmParser.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-06 19:25:43 +0000
committerChris Lattner <sabre@nondot.org>2010-11-06 19:25:43 +0000
commit98c870f87b7f0c996a9ba67003d88d434d6dbcd0 (patch)
tree3f02eb16478f4bae0f26a1164476630369829573 /lib/Target/X86/AsmParser/X86AsmParser.cpp
parentdea546b62339578938a91f05a00a145baf921f6c (diff)
downloadexternal_llvm-98c870f87b7f0c996a9ba67003d88d434d6dbcd0.zip
external_llvm-98c870f87b7f0c996a9ba67003d88d434d6dbcd0.tar.gz
external_llvm-98c870f87b7f0c996a9ba67003d88d434d6dbcd0.tar.bz2
generalize alias support to allow the result of an alias to
add fixed immediate values. Move the aad and aam aliases to use this, and document it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118350 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/AsmParser/X86AsmParser.cpp')
-rw-r--r--lib/Target/X86/AsmParser/X86AsmParser.cpp37
1 files changed, 16 insertions, 21 deletions
diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 4ab25cf..9ab6b56 100644
--- a/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -752,6 +752,22 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
if (getLexer().is(AsmToken::EndOfStatement))
Parser.Lex(); // Consume the EndOfStatement
+ // This is a terrible hack to handle "out[bwl]? %al, (%dx)" ->
+ // "outb %al, %dx". Out doesn't take a memory form, but this is a widely
+ // documented form in various unofficial manuals, so a lot of code uses it.
+ 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 recognize s{hr,ar,hl} $1, <op>. Canonicalize to
// "shift <op>".
if ((Name.startswith("shr") || Name.startswith("sar") ||
@@ -781,20 +797,6 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
X86Operand::CreateImm(One, NameLoc, NameLoc));
}
- // 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") ||
@@ -839,13 +841,6 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
NameLoc, NameLoc));
}
- // FIXME: Hack to handle recognize "aa[dm]" -> "aa[dm] $0xA".
- if ((Name.startswith("aad") || Name.startswith("aam")) &&
- Operands.size() == 1) {
- const MCExpr *A = MCConstantExpr::Create(0xA, getParser().getContext());
- Operands.push_back(X86Operand::CreateImm(A, NameLoc, NameLoc));
- }
-
return false;
}