<div dir="ltr"><div dir="ltr"><div>I think there's still a bug that I was trying to fix with that hack, but I failed because CheckBaseRegAndIndexRegAndScale allows DX through. This assembles even though it shouldn't</div><div><br></div><div>add (%dx), %ax<br></div><div><br clear="all"><div><div dir="ltr" class="gmail_signature">~Craig</div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 3, 2019 at 1:49 PM Nirav Dave via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: niravd<br>
Date: Thu Jan 3 13:46:30 2019<br>
New Revision: 350355<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=350355&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=350355&view=rev</a><br>
Log:<br>
[X86] Remove terrible DX Register parsing hack in parse operand. NFCI.<br>
<br>
Fold hack special casing of (%dx) operand parsing into the related<br>
hack for out*/in* instruction parsing.<br>
<br>
Modified:<br>
llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp<br>
llvm/trunk/lib/Target/X86/AsmParser/X86Operand.h<br>
<br>
Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=350355&r1=350354&r2=350355&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=350355&r1=350354&r2=350355&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)<br>
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Thu Jan 3 13:46:30 2019<br>
@@ -2240,14 +2240,6 @@ std::unique_ptr<X86Operand> X86AsmParser<br>
if (parseToken(AsmToken::RParen, "unexpected token in memory operand"))<br>
return nullptr;<br>
<br>
- // This is a terrible hack to handle "out[s]?[bwl]? %al, (%dx)" -><br>
- // "outb %al, %dx". Out doesn't take a memory form, but this is a widely<br>
- // documented form in various unofficial manuals, so a lot of code uses it.<br>
- if (BaseReg == X86::DX && IndexReg == 0 && Scale == 1 &&<br>
- SegReg == 0 && isa<MCConstantExpr>(Disp) &&<br>
- cast<MCConstantExpr>(Disp)->getValue() == 0)<br>
- return X86Operand::CreateDXReg(BaseLoc, BaseLoc);<br>
-<br>
StringRef ErrMsg;<br>
if (CheckBaseRegAndIndexRegAndScale(BaseReg, IndexReg, Scale, is64BitMode(),<br>
ErrMsg)) {<br>
<br>
Modified: llvm/trunk/lib/Target/X86/AsmParser/X86Operand.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86Operand.h?rev=350355&r1=350354&r2=350355&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86Operand.h?rev=350355&r1=350354&r2=350355&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/X86/AsmParser/X86Operand.h (original)<br>
+++ llvm/trunk/lib/Target/X86/AsmParser/X86Operand.h Thu Jan 3 13:46:30 2019<br>
@@ -30,7 +30,7 @@ namespace llvm {<br>
/// X86Operand - Instances of this class represent a parsed X86 machine<br>
/// instruction.<br>
struct X86Operand final : public MCParsedAsmOperand {<br>
- enum KindTy { Token, Register, Immediate, Memory, Prefix, DXRegister } Kind;<br>
+ enum KindTy { Token, Register, Immediate, Memory, Prefix } Kind;<br>
<br>
SMLoc StartLoc, EndLoc;<br>
SMLoc OffsetOfLoc;<br>
@@ -118,9 +118,6 @@ struct X86Operand final : public MCParse<br>
case Register:<br>
OS << "Reg:" << X86IntelInstPrinter::getRegisterName(Reg.RegNo);<br>
break;<br>
- case DXRegister:<br>
- OS << "DXReg";<br>
- break;<br>
case Immediate:<br>
PrintImmValue(Imm.Val, "Imm:");<br>
break;<br>
@@ -444,7 +441,10 @@ struct X86Operand final : public MCParse<br>
<br>
bool isPrefix() const { return Kind == Prefix; }<br>
bool isReg() const override { return Kind == Register; }<br>
- bool isDXReg() const { return Kind == DXRegister; }<br>
+ bool isDXReg() const {<br>
+ return Kind == Memory && getMemBaseReg() == X86::DX && !getMemIndexReg() &&<br>
+ getMemScale() == 1;<br>
+ }<br>
<br>
bool isGR32orGR64() const {<br>
return Kind == Register &&<br>
@@ -544,11 +544,6 @@ struct X86Operand final : public MCParse<br>
}<br>
<br>
static std::unique_ptr<X86Operand><br>
- CreateDXReg(SMLoc StartLoc, SMLoc EndLoc) {<br>
- return llvm::make_unique<X86Operand>(DXRegister, StartLoc, EndLoc);<br>
- }<br>
-<br>
- static std::unique_ptr<X86Operand><br>
CreatePrefix(unsigned Prefixes, SMLoc StartLoc, SMLoc EndLoc) {<br>
auto Res = llvm::make_unique<X86Operand>(Prefix, StartLoc, EndLoc);<br>
Res->Pref.Prefixes = Prefixes;<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>