Changes in directory llvm/utils/TableGen:
DAGISelEmitter.cpp updated: 1.94 -> 1.95 --- Log message: Bug fix: finding the correct incoming chain for pattern with nested src operand. And a minor change to make output code slightly more readible. --- Diffs of the changes: (+17 -14) DAGISelEmitter.cpp | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.94 llvm/utils/TableGen/DAGISelEmitter.cpp:1.95 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.94 Fri Dec 9 20:36:00 2005 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon Dec 12 13:37:43 2005 @@ -1040,14 +1040,15 @@ 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<DefInit*>(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 @@ std::ostream &OS; // Node to name mapping std::map<std::string,std::string> 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<std::string> FoldedChains; + bool FoundChain; bool InFlag; unsigned TmpNo; @@ -1737,7 +1737,7 @@ 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 @@ // 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 @@ << ".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 @@ } } + 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 @@ // 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); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits