llvm.org GIT mirror llvm / 8621789
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 Evan Cheng 13 years ago
1 changed file(s) with 18 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
10391039 for (unsigned i = 0; i != NumValues; ++i) {
10401040 TreePatternNode *Dest = Pat->getChild(i);
10411041 if (!Dest->isLeaf())
1042 I->error("set destination should be a virtual register!");
1042 I->error("set destination should be a register!");
10431043
10441044 DefInit *Val = dynamic_cast(Dest->getLeafValue());
10451045 if (!Val)
1046 I->error("set destination should be a virtual register!");
1047
1048 if (!Val->getDef()->isSubClassOf("RegisterClass"))
1049 I->error("set destination should be a virtual register!");
1046 I->error("set destination should be a register!");
1047
1048 if (!Val->getDef()->isSubClassOf("RegisterClass") &&
1049 !Val->getDef()->isSubClassOf("Register"))
1050 I->error("set destination should be a register!");
10501051 if (Dest->getName().empty())
10511052 I->error("set destination must have a name!");
10521053 if (InstResults.count(Dest->getName()))
17251726 std::ostream &OS;
17261727 // Node to name mapping
17271728 std::map VariableMap;
1728 // Name of the inner most node which produces a chain.
1729 std::string InnerChain;
17301729 // Names of all the folded nodes which produce chains.
17311730 std::vector FoldedChains;
1731 bool FoundChain;
17321732 bool InFlag;
17331733 unsigned TmpNo;
17341734
17361736 PatternCodeEmitter(DAGISelEmitter &ise, TreePatternNode *lhs,
17371737 unsigned PatNum, std::ostream &os) :
17381738 ISE(ise), LHS(lhs), PatternNo(PatNum), OS(os),
1739 InFlag(false), TmpNo(0) {};
1739 FoundChain(false), InFlag(false), TmpNo(0) {};
17401740
17411741 /// EmitMatchCode - Emit a matcher for N, going to the label for PatternNo
17421742 /// if the match fails. At this point, we already know that the opcode for N
17751775
17761776 // Emit code to load the child nodes and match their contents recursively.
17771777 unsigned OpNo = 0;
1778 if (NodeHasChain(N, ISE)) {
1778 bool HasChain = NodeHasChain(N, ISE);
1779 if (HasChain) {
17791780 OpNo = 1;
17801781 if (!isRoot) {
17811782 const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator());
17841785 OS << " if (CodeGenMap.count(" << RootName
17851786 << ".getValue(" << CInfo.getNumResults() << "))) goto P"
17861787 << PatternNo << "Fail; // Already selected for a chain use?\n";
1787 }
1788 if (InnerChain.empty()) {
1789 OS << " SDOperand " << RootName << "0 = " << RootName
1790 << ".getOperand(0);\n";
1791 InnerChain = RootName + "0";
17921788 }
17931789 }
17941790
18611857 }
18621858 }
18631859
1860 if (HasChain) {
1861 if (!FoundChain) {
1862 OS << " SDOperand Chain = " << RootName << ".getOperand(0);\n";
1863 FoundChain = true;
1864 }
1865 }
1866
18641867 // If there is a node predicate for this, emit the call.
18651868 if (!N->getPredicateFn().empty())
18661869 OS << " if (!" << N->getPredicateFn() << "(" << RootName
19871990
19881991 // Emit all the chain and CopyToReg stuff.
19891992 if (II.hasCtrlDep)
1990 OS << " SDOperand Chain = Select(" << InnerChain << ");\n";
1993 OS << " Chain = Select(Chain);\n";
19911994 EmitCopyToRegs(LHS, "N", II.hasCtrlDep);
19921995
19931996 const DAGInstruction &Inst = ISE.getInstruction(Op);