llvm.org GIT mirror llvm / aeb7d4d
Allow set operators with multiple destinations, i.e. (set x, y, (op a, b)). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41861 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 12 years ago
1 changed file(s) with 26 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
675675
676676 // special handling for set, which isn't really an SDNode.
677677 if (getOperator()->getName() == "set") {
678 assert (getNumChildren() == 2 && "Only handle 2 operand set's for now!");
679 bool MadeChange = getChild(0)->ApplyTypeConstraints(TP, NotRegisters);
680 MadeChange |= getChild(1)->ApplyTypeConstraints(TP, NotRegisters);
681
682 // Types of operands must match.
683 MadeChange |= getChild(0)->UpdateNodeType(getChild(1)->getExtTypes(), TP);
684 MadeChange |= getChild(1)->UpdateNodeType(getChild(0)->getExtTypes(), TP);
685 MadeChange |= UpdateNodeType(MVT::isVoid, TP);
678 assert (getNumChildren() >= 2 && "Missing RHS of a set?");
679 unsigned NC = getNumChildren();
680 bool MadeChange = false;
681 for (unsigned i = 0; i < NC-1; ++i) {
682 MadeChange = getChild(i)->ApplyTypeConstraints(TP, NotRegisters);
683 MadeChange |= getChild(NC-1)->ApplyTypeConstraints(TP, NotRegisters);
684
685 // Types of operands must match.
686 MadeChange |= getChild(i)->UpdateNodeType(getChild(NC-1)->getExtTypes(),
687 TP);
688 MadeChange |= getChild(NC-1)->UpdateNodeType(getChild(i)->getExtTypes(),
689 TP);
690 MadeChange |= UpdateNodeType(MVT::isVoid, TP);
691 }
686692 return MadeChange;
687693 } else if (getOperator() == ISE.get_intrinsic_void_sdnode() ||
688694 getOperator() == ISE.get_intrinsic_w_chain_sdnode() ||
13151321 I->error("Input " + DI->getDef()->getName() + " must be named!");
13161322 else if (DI && DI->getDef()->isSubClassOf("Register"))
13171323 InstImpInputs.push_back(DI->getDef());
1324 ;
13181325 }
13191326 return false;
13201327 }
13921399 // Otherwise, this is a set, validate and collect instruction results.
13931400 if (Pat->getNumChildren() == 0)
13941401 I->error("set requires operands!");
1395 else if (Pat->getNumChildren() & 1)
1396 I->error("set requires an even number of operands");
13971402
13981403 if (Pat->getTransformFn())
13991404 I->error("Cannot specify a transform function on a set node!");
14001405
14011406 // Check the set destinations.
1402 unsigned NumValues = Pat->getNumChildren()/2;
1403 for (unsigned i = 0; i != NumValues; ++i) {
1407 unsigned NumDests = Pat->getNumChildren()-1;
1408 for (unsigned i = 0; i != NumDests; ++i) {
14041409 TreePatternNode *Dest = Pat->getChild(i);
14051410 if (!Dest->isLeaf())
14061411 I->error("set destination should be a register!");
14181423 InstResults[Dest->getName()] = Dest;
14191424 } else if (Val->getDef()->isSubClassOf("Register")) {
14201425 InstImpResults.push_back(Val->getDef());
1426 ;
14211427 } else {
14221428 I->error("set destination should be a register!");
14231429 }
1424
1425 // Verify and collect info from the computation.
1426 FindPatternInputsAndOutputs(I, Pat->getChild(i+NumValues),
1427 InstInputs, InstResults,
1428 InstImpInputs, InstImpResults);
1429 }
1430 }
1431
1432 // Verify and collect info from the computation.
1433 FindPatternInputsAndOutputs(I, Pat->getChild(NumDests),
1434 InstInputs, InstResults,
1435 InstImpInputs, InstImpResults);
14301436 }
14311437
14321438 /// ParseInstructions - Parse all of the instructions, inlining and resolving
16431649 TreePatternNode *Pattern = I->getTree(0);
16441650 TreePatternNode *SrcPattern;
16451651 if (Pattern->getOperator()->getName() == "set") {
1646 if (Pattern->getNumChildren() != 2)
1647 continue; // Not a set of a single value (not handled so far)
1648
1649 SrcPattern = Pattern->getChild(1)->clone();
1652 SrcPattern = Pattern->getChild(Pattern->getNumChildren()-1)->clone();
16501653 } else{
16511654 // Not a set (store or something?)
16521655 SrcPattern = Pattern;
27582761 isRoot ? (InstPat ? InstPat->getOnlyTree() : Pattern)
27592762 : (InstPat ? InstPat->getOnlyTree() : NULL);
27602763 if (InstPatNode && InstPatNode->getOperator()->getName() == "set") {
2761 InstPatNode = InstPatNode->getChild(1);
2764 InstPatNode = InstPatNode->getChild(InstPatNode->getNumChildren()-1);
27622765 }
27632766 bool HasVarOps = isRoot && II.hasVariableNumberOfOperands;
27642767 bool HasImpInputs = isRoot && Inst.getNumImpOperands() > 0;