From: Evan Cheng Date: Mon, 12 Dec 2005 19:37:43 +0000 (+0000) Subject: Bug fix: finding the correct incoming chain for pattern with nested src operand.... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8621789fccec5a89eab3c94c0a7e3e048964dfe0;p=oota-llvm.git Bug fix: finding the correct incoming chain for pattern with nested src operand. And a minor change to make output code slightly more readible. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24669 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index 05a9c626be3..bcb28a628e6 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -1040,14 +1040,15 @@ FindPatternInputsAndOutputs(TreePattern *I, TreePatternNode *Pat, for (unsigned i = 0; i != NumValues; ++i) { TreePatternNode *Dest = Pat->getChild(i); if (!Dest->isLeaf()) - I->error("set destination should be a virtual register!"); + I->error("set destination should be a register!"); DefInit *Val = dynamic_cast(Dest->getLeafValue()); if (!Val) - I->error("set destination should be a virtual register!"); + I->error("set destination should be a register!"); - if (!Val->getDef()->isSubClassOf("RegisterClass")) - I->error("set destination should be a virtual register!"); + if (!Val->getDef()->isSubClassOf("RegisterClass") && + !Val->getDef()->isSubClassOf("Register")) + I->error("set destination should be a register!"); if (Dest->getName().empty()) I->error("set destination must have a name!"); if (InstResults.count(Dest->getName())) @@ -1726,10 +1727,9 @@ private: std::ostream &OS; // Node to name mapping std::map VariableMap; - // Name of the inner most node which produces a chain. - std::string InnerChain; // Names of all the folded nodes which produce chains. std::vector FoldedChains; + bool FoundChain; bool InFlag; unsigned TmpNo; @@ -1737,7 +1737,7 @@ public: PatternCodeEmitter(DAGISelEmitter &ise, TreePatternNode *lhs, unsigned PatNum, std::ostream &os) : ISE(ise), LHS(lhs), PatternNo(PatNum), OS(os), - InFlag(false), TmpNo(0) {}; + FoundChain(false), InFlag(false), TmpNo(0) {}; /// EmitMatchCode - Emit a matcher for N, going to the label for PatternNo /// if the match fails. At this point, we already know that the opcode for N @@ -1776,7 +1776,8 @@ public: // Emit code to load the child nodes and match their contents recursively. unsigned OpNo = 0; - if (NodeHasChain(N, ISE)) { + bool HasChain = NodeHasChain(N, ISE); + if (HasChain) { OpNo = 1; if (!isRoot) { const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator()); @@ -1786,11 +1787,6 @@ public: << ".getValue(" << CInfo.getNumResults() << "))) goto P" << PatternNo << "Fail; // Already selected for a chain use?\n"; } - if (InnerChain.empty()) { - OS << " SDOperand " << RootName << "0 = " << RootName - << ".getOperand(0);\n"; - InnerChain = RootName + "0"; - } } for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) { @@ -1862,6 +1858,13 @@ public: } } + if (HasChain) { + if (!FoundChain) { + OS << " SDOperand Chain = " << RootName << ".getOperand(0);\n"; + FoundChain = true; + } + } + // If there is a node predicate for this, emit the call. if (!N->getPredicateFn().empty()) OS << " if (!" << N->getPredicateFn() << "(" << RootName @@ -1988,7 +1991,7 @@ public: // Emit all the chain and CopyToReg stuff. if (II.hasCtrlDep) - OS << " SDOperand Chain = Select(" << InnerChain << ");\n"; + OS << " Chain = Select(Chain);\n"; EmitCopyToRegs(LHS, "N", II.hasCtrlDep); const DAGInstruction &Inst = ISE.getInstruction(Op);