diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-11-06 19:25:43 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-11-06 19:25:43 +0000 |
| commit | b6f8e8248d7f3540f739f696ec73534f7d9fcaf4 (patch) | |
| tree | 2c801fdc13fe78886e5921f460e387914f125bd5 /llvm/lib | |
| parent | 161bf7de25c6505917741ee32a0a2aad2099bd1d (diff) | |
| download | bcm5719-llvm-b6f8e8248d7f3540f739f696ec73534f7d9fcaf4.tar.gz bcm5719-llvm-b6f8e8248d7f3540f739f696ec73534f7d9fcaf4.zip | |
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.
llvm-svn: 118350
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp | 37 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86InstrInfo.td | 4 |
2 files changed, 20 insertions, 21 deletions
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index 4ab25cf4bf8..9ab6b56c8f0 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/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; } diff --git a/llvm/lib/Target/X86/X86InstrInfo.td b/llvm/lib/Target/X86/X86InstrInfo.td index 125da18600e..7fec0141ce4 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.td +++ b/llvm/lib/Target/X86/X86InstrInfo.td @@ -1367,6 +1367,10 @@ defm : IntegerCondCodeMnemonicAlias<"cmov", "q">; // Assembler Instruction Aliases //===----------------------------------------------------------------------===// +// aad/aam default to base 10 if no operand is specified. +def : InstAlias<"aad", (AAD8i8 10)>; +def : InstAlias<"aam", (AAM8i8 10)>; + // clr aliases. def : InstAlias<"clrb $reg", (XOR8rr GR8 :$reg, GR8 :$reg)>; def : InstAlias<"clrw $reg", (XOR16rr GR16:$reg, GR16:$reg)>; |

