[llvm] 04e5ea5 - [TableGen] Remove recursive walk of linked list from ContractNodes. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 9 14:24:41 PST 2025
Author: Craig Topper
Date: 2025-02-09T14:23:34-08:00
New Revision: 04e5ea5237da5c49d05cd9499a5f0eb325638cf9
URL: https://github.com/llvm/llvm-project/commit/04e5ea5237da5c49d05cd9499a5f0eb325638cf9
DIFF: https://github.com/llvm/llvm-project/commit/04e5ea5237da5c49d05cd9499a5f0eb325638cf9.diff
LOG: [TableGen] Remove recursive walk of linked list from ContractNodes. NFC
After f9250401ef120a4605ad67bb43d3b25500900498, this function is
tail recursive so it was straightforward to convert this to iteratively
walk the linkd list.
Added:
Modified:
llvm/utils/TableGen/DAGISelMatcherOpt.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
index ed062168dbc6ef..9028a60027ffec 100644
--- a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
@@ -22,275 +22,275 @@ using namespace llvm;
/// ContractNodes - Turn multiple matcher node patterns like 'MoveChild+Record'
/// into single compound nodes like RecordChild.
-static void ContractNodes(std::unique_ptr<Matcher> &MatcherPtr,
+static void ContractNodes(std::unique_ptr<Matcher> &InputMatcherPtr,
const CodeGenDAGPatterns &CGP) {
- // If we reached the end of the chain, we're done.
- Matcher *N = MatcherPtr.get();
- if (!N)
- return;
-
- // If we have a scope node, walk down all of the children.
- if (ScopeMatcher *Scope = dyn_cast<ScopeMatcher>(N)) {
- for (unsigned i = 0, e = Scope->getNumChildren(); i != e; ++i) {
- std::unique_ptr<Matcher> Child(Scope->takeChild(i));
- ContractNodes(Child, CGP);
- Scope->resetChild(i, Child.release());
+ std::unique_ptr<Matcher> *MatcherPtr = &InputMatcherPtr;
+ while (true) {
+ Matcher *N = MatcherPtr->get();
+
+ // If we have a scope node, walk down all of the children.
+ if (auto *Scope = dyn_cast<ScopeMatcher>(N)) {
+ for (unsigned i = 0, e = Scope->getNumChildren(); i != e; ++i) {
+ std::unique_ptr<Matcher> Child(Scope->takeChild(i));
+ ContractNodes(Child, CGP);
+ Scope->resetChild(i, Child.release());
+ }
+ return;
}
- return;
- }
- // If we found a movechild node with a node that comes in a 'foochild' form,
- // transform it.
- if (MoveChildMatcher *MC = dyn_cast<MoveChildMatcher>(N)) {
- Matcher *New = nullptr;
- if (RecordMatcher *RM = dyn_cast<RecordMatcher>(MC->getNext()))
- if (MC->getChildNo() < 8) // Only have RecordChild0...7
- New = new RecordChildMatcher(MC->getChildNo(), RM->getWhatFor(),
- RM->getResultNo());
-
- if (CheckTypeMatcher *CT = dyn_cast<CheckTypeMatcher>(MC->getNext()))
- if (MC->getChildNo() < 8 && // Only have CheckChildType0...7
- CT->getResNo() == 0) // CheckChildType checks res #0
- New = new CheckChildTypeMatcher(MC->getChildNo(), CT->getType());
-
- if (CheckSameMatcher *CS = dyn_cast<CheckSameMatcher>(MC->getNext()))
- if (MC->getChildNo() < 4) // Only have CheckChildSame0...3
- New = new CheckChildSameMatcher(MC->getChildNo(), CS->getMatchNumber());
-
- if (CheckIntegerMatcher *CI = dyn_cast<CheckIntegerMatcher>(MC->getNext()))
- if (MC->getChildNo() < 5) // Only have CheckChildInteger0...4
- New = new CheckChildIntegerMatcher(MC->getChildNo(), CI->getValue());
-
- if (auto *CCC = dyn_cast<CheckCondCodeMatcher>(MC->getNext()))
- if (MC->getChildNo() == 2) // Only have CheckChild2CondCode
- New = new CheckChild2CondCodeMatcher(CCC->getCondCodeName());
-
- if (New) {
- // Insert the new node.
- New->setNext(MatcherPtr.release());
- MatcherPtr.reset(New);
- // Remove the old one.
- MC->setNext(MC->getNext()->takeNext());
- return ContractNodes(MatcherPtr, CGP);
+ // If we found a movechild node with a node that comes in a 'foochild' form,
+ // transform it.
+ if (MoveChildMatcher *MC = dyn_cast<MoveChildMatcher>(N)) {
+ Matcher *New = nullptr;
+ if (RecordMatcher *RM = dyn_cast<RecordMatcher>(MC->getNext()))
+ if (MC->getChildNo() < 8) // Only have RecordChild0...7
+ New = new RecordChildMatcher(MC->getChildNo(), RM->getWhatFor(),
+ RM->getResultNo());
+
+ if (CheckTypeMatcher *CT = dyn_cast<CheckTypeMatcher>(MC->getNext()))
+ if (MC->getChildNo() < 8 && // Only have CheckChildType0...7
+ CT->getResNo() == 0) // CheckChildType checks res #0
+ New = new CheckChildTypeMatcher(MC->getChildNo(), CT->getType());
+
+ if (CheckSameMatcher *CS = dyn_cast<CheckSameMatcher>(MC->getNext()))
+ if (MC->getChildNo() < 4) // Only have CheckChildSame0...3
+ New =
+ new CheckChildSameMatcher(MC->getChildNo(), CS->getMatchNumber());
+
+ if (CheckIntegerMatcher *CI =
+ dyn_cast<CheckIntegerMatcher>(MC->getNext()))
+ if (MC->getChildNo() < 5) // Only have CheckChildInteger0...4
+ New = new CheckChildIntegerMatcher(MC->getChildNo(), CI->getValue());
+
+ if (auto *CCC = dyn_cast<CheckCondCodeMatcher>(MC->getNext()))
+ if (MC->getChildNo() == 2) // Only have CheckChild2CondCode
+ New = new CheckChild2CondCodeMatcher(CCC->getCondCodeName());
+
+ if (New) {
+ // Insert the new node.
+ New->setNext(MatcherPtr->release());
+ MatcherPtr->reset(New);
+ // Remove the old one.
+ MC->setNext(MC->getNext()->takeNext());
+ continue;
+ }
}
- }
- // Turn MoveParent->MoveChild into MoveSibling.
- if (auto *MP = dyn_cast<MoveParentMatcher>(N)) {
- if (auto *MC = dyn_cast<MoveChildMatcher>(MP->getNext())) {
- auto *MS = new MoveSiblingMatcher(MC->getChildNo());
- MS->setNext(MC->takeNext());
- MatcherPtr.reset(MS);
- return ContractNodes(MatcherPtr, CGP);
+ // Turn MoveParent->MoveChild into MoveSibling.
+ if (auto *MP = dyn_cast<MoveParentMatcher>(N)) {
+ if (auto *MC = dyn_cast<MoveChildMatcher>(MP->getNext())) {
+ auto *MS = new MoveSiblingMatcher(MC->getChildNo());
+ MS->setNext(MC->takeNext());
+ MatcherPtr->reset(MS);
+ continue;
+ }
}
- }
- // Uncontract MoveSibling if it will help form other child operations.
- if (auto *MS = dyn_cast<MoveSiblingMatcher>(N)) {
- if (auto *RM = dyn_cast<RecordMatcher>(MS->getNext())) {
- // Turn MoveSibling->Record->MoveParent into MoveParent->RecordChild.
- if (auto *MP = dyn_cast<MoveParentMatcher>(RM->getNext())) {
- if (MS->getSiblingNo() < 8) { // Only have RecordChild0...7
- auto *NewMP = new MoveParentMatcher();
- auto *NewRCM = new RecordChildMatcher(
- MS->getSiblingNo(), RM->getWhatFor(), RM->getResultNo());
- NewMP->setNext(NewRCM);
- NewRCM->setNext(MP->takeNext());
- MatcherPtr.reset(NewMP);
- return ContractNodes(MatcherPtr, CGP);
+ // Uncontract MoveSibling if it will help form other child operations.
+ if (auto *MS = dyn_cast<MoveSiblingMatcher>(N)) {
+ if (auto *RM = dyn_cast<RecordMatcher>(MS->getNext())) {
+ // Turn MoveSibling->Record->MoveParent into MoveParent->RecordChild.
+ if (auto *MP = dyn_cast<MoveParentMatcher>(RM->getNext())) {
+ if (MS->getSiblingNo() < 8) { // Only have RecordChild0...7
+ auto *NewMP = new MoveParentMatcher();
+ auto *NewRCM = new RecordChildMatcher(
+ MS->getSiblingNo(), RM->getWhatFor(), RM->getResultNo());
+ NewMP->setNext(NewRCM);
+ NewRCM->setNext(MP->takeNext());
+ MatcherPtr->reset(NewMP);
+ continue;
+ }
+ }
+
+ // Turn MoveSibling->Record->CheckType->MoveParent into
+ // MoveParent->RecordChild->CheckChildType.
+ if (auto *CT = dyn_cast<CheckTypeMatcher>(RM->getNext())) {
+ if (auto *MP = dyn_cast<MoveParentMatcher>(CT->getNext())) {
+ if (MS->getSiblingNo() < 8 && // Only have CheckChildType0...7
+ CT->getResNo() == 0) { // CheckChildType checks res #0
+ auto *NewMP = new MoveParentMatcher();
+ auto *NewRCM = new RecordChildMatcher(
+ MS->getSiblingNo(), RM->getWhatFor(), RM->getResultNo());
+ auto *NewCCT =
+ new CheckChildTypeMatcher(MS->getSiblingNo(), CT->getType());
+ NewMP->setNext(NewRCM);
+ NewRCM->setNext(NewCCT);
+ NewCCT->setNext(MP->takeNext());
+ MatcherPtr->reset(NewMP);
+ continue;
+ }
+ }
}
}
- // Turn MoveSibling->Record->CheckType->MoveParent into
- // MoveParent->RecordChild->CheckChildType.
- if (auto *CT = dyn_cast<CheckTypeMatcher>(RM->getNext())) {
+ // Turn MoveSibling->CheckType->MoveParent into
+ // MoveParent->CheckChildType.
+ if (auto *CT = dyn_cast<CheckTypeMatcher>(MS->getNext())) {
if (auto *MP = dyn_cast<MoveParentMatcher>(CT->getNext())) {
if (MS->getSiblingNo() < 8 && // Only have CheckChildType0...7
CT->getResNo() == 0) { // CheckChildType checks res #0
auto *NewMP = new MoveParentMatcher();
- auto *NewRCM = new RecordChildMatcher(
- MS->getSiblingNo(), RM->getWhatFor(), RM->getResultNo());
auto *NewCCT =
new CheckChildTypeMatcher(MS->getSiblingNo(), CT->getType());
- NewMP->setNext(NewRCM);
- NewRCM->setNext(NewCCT);
+ NewMP->setNext(NewCCT);
NewCCT->setNext(MP->takeNext());
- MatcherPtr.reset(NewMP);
- return ContractNodes(MatcherPtr, CGP);
+ MatcherPtr->reset(NewMP);
+ continue;
}
}
}
- }
-
- // Turn MoveSibling->CheckType->MoveParent into MoveParent->CheckChildType.
- if (auto *CT = dyn_cast<CheckTypeMatcher>(MS->getNext())) {
- if (auto *MP = dyn_cast<MoveParentMatcher>(CT->getNext())) {
- if (MS->getSiblingNo() < 8 && // Only have CheckChildType0...7
- CT->getResNo() == 0) { // CheckChildType checks res #0
- auto *NewMP = new MoveParentMatcher();
- auto *NewCCT =
- new CheckChildTypeMatcher(MS->getSiblingNo(), CT->getType());
- NewMP->setNext(NewCCT);
- NewCCT->setNext(MP->takeNext());
- MatcherPtr.reset(NewMP);
- return ContractNodes(MatcherPtr, CGP);
- }
- }
- }
-
- // Turn MoveSibling->CheckInteger->MoveParent into
- // MoveParent->CheckChildInteger.
- if (auto *CI = dyn_cast<CheckIntegerMatcher>(MS->getNext())) {
- if (auto *MP = dyn_cast<MoveParentMatcher>(CI->getNext())) {
- if (MS->getSiblingNo() < 5) { // Only have CheckChildInteger0...4
- auto *NewMP = new MoveParentMatcher();
- auto *NewCCI =
- new CheckChildIntegerMatcher(MS->getSiblingNo(), CI->getValue());
- NewMP->setNext(NewCCI);
- NewCCI->setNext(MP->takeNext());
- MatcherPtr.reset(NewMP);
- return ContractNodes(MatcherPtr, CGP);
- }
- }
- // Turn MoveSibling->CheckInteger->CheckType->MoveParent into
- // MoveParent->CheckChildInteger->CheckType.
- if (auto *CT = dyn_cast<CheckTypeMatcher>(CI->getNext())) {
- if (auto *MP = dyn_cast<MoveParentMatcher>(CT->getNext())) {
- if (MS->getSiblingNo() < 5 && // Only have CheckChildInteger0...4
- CT->getResNo() == 0) { // CheckChildType checks res #0
+ // Turn MoveSibling->CheckInteger->MoveParent into
+ // MoveParent->CheckChildInteger.
+ if (auto *CI = dyn_cast<CheckIntegerMatcher>(MS->getNext())) {
+ if (auto *MP = dyn_cast<MoveParentMatcher>(CI->getNext())) {
+ if (MS->getSiblingNo() < 5) { // Only have CheckChildInteger0...4
auto *NewMP = new MoveParentMatcher();
auto *NewCCI = new CheckChildIntegerMatcher(MS->getSiblingNo(),
CI->getValue());
- auto *NewCCT =
- new CheckChildTypeMatcher(MS->getSiblingNo(), CT->getType());
NewMP->setNext(NewCCI);
- NewCCI->setNext(NewCCT);
- NewCCT->setNext(MP->takeNext());
- MatcherPtr.reset(NewMP);
- return ContractNodes(MatcherPtr, CGP);
+ NewCCI->setNext(MP->takeNext());
+ MatcherPtr->reset(NewMP);
+ continue;
}
}
- }
- }
- // Turn MoveSibling->CheckCondCode->MoveParent into
- // MoveParent->CheckChild2CondCode.
- if (auto *CCC = dyn_cast<CheckCondCodeMatcher>(MS->getNext())) {
- if (auto *MP = dyn_cast<MoveParentMatcher>(CCC->getNext())) {
- if (MS->getSiblingNo() == 2) { // Only have CheckChild2CondCode
- auto *NewMP = new MoveParentMatcher();
- auto *NewCCCC =
- new CheckChild2CondCodeMatcher(CCC->getCondCodeName());
- NewMP->setNext(NewCCCC);
- NewCCCC->setNext(MP->takeNext());
- MatcherPtr.reset(NewMP);
- return ContractNodes(MatcherPtr, CGP);
+ // Turn MoveSibling->CheckInteger->CheckType->MoveParent into
+ // MoveParent->CheckChildInteger->CheckType.
+ if (auto *CT = dyn_cast<CheckTypeMatcher>(CI->getNext())) {
+ if (auto *MP = dyn_cast<MoveParentMatcher>(CT->getNext())) {
+ if (MS->getSiblingNo() < 5 && // Only have CheckChildInteger0...4
+ CT->getResNo() == 0) { // CheckChildType checks res #0
+ auto *NewMP = new MoveParentMatcher();
+ auto *NewCCI = new CheckChildIntegerMatcher(MS->getSiblingNo(),
+ CI->getValue());
+ auto *NewCCT =
+ new CheckChildTypeMatcher(MS->getSiblingNo(), CT->getType());
+ NewMP->setNext(NewCCI);
+ NewCCI->setNext(NewCCT);
+ NewCCT->setNext(MP->takeNext());
+ MatcherPtr->reset(NewMP);
+ continue;
+ }
+ }
}
}
- }
- // Turn MoveSibling->CheckSame->MoveParent into
- // MoveParent->CheckChildSame.
- if (auto *CS = dyn_cast<CheckSameMatcher>(MS->getNext())) {
- if (auto *MP = dyn_cast<MoveParentMatcher>(CS->getNext())) {
- if (MS->getSiblingNo() < 4) { // Only have CheckChildSame0...3
- auto *NewMP = new MoveParentMatcher();
- auto *NewCCS = new CheckChildSameMatcher(MS->getSiblingNo(),
- CS->getMatchNumber());
- NewMP->setNext(NewCCS);
- NewCCS->setNext(MP->takeNext());
- MatcherPtr.reset(NewMP);
- return ContractNodes(MatcherPtr, CGP);
+ // Turn MoveSibling->CheckCondCode->MoveParent into
+ // MoveParent->CheckChild2CondCode.
+ if (auto *CCC = dyn_cast<CheckCondCodeMatcher>(MS->getNext())) {
+ if (auto *MP = dyn_cast<MoveParentMatcher>(CCC->getNext())) {
+ if (MS->getSiblingNo() == 2) { // Only have CheckChild2CondCode
+ auto *NewMP = new MoveParentMatcher();
+ auto *NewCCCC =
+ new CheckChild2CondCodeMatcher(CCC->getCondCodeName());
+ NewMP->setNext(NewCCCC);
+ NewCCCC->setNext(MP->takeNext());
+ MatcherPtr->reset(NewMP);
+ continue;
+ }
}
}
- // Turn MoveSibling->CheckSame->CheckType->MoveParent into
- // MoveParent->CheckChildSame->CheckChildType.
- if (auto *CT = dyn_cast<CheckTypeMatcher>(CS->getNext())) {
- if (auto *MP = dyn_cast<MoveParentMatcher>(CT->getNext())) {
- if (MS->getSiblingNo() < 4 && // Only have CheckChildSame0...3
- CT->getResNo() == 0) { // CheckChildType checks res #0
+ // Turn MoveSibling->CheckSame->MoveParent into
+ // MoveParent->CheckChildSame.
+ if (auto *CS = dyn_cast<CheckSameMatcher>(MS->getNext())) {
+ if (auto *MP = dyn_cast<MoveParentMatcher>(CS->getNext())) {
+ if (MS->getSiblingNo() < 4) { // Only have CheckChildSame0...3
auto *NewMP = new MoveParentMatcher();
auto *NewCCS = new CheckChildSameMatcher(MS->getSiblingNo(),
CS->getMatchNumber());
- auto *NewCCT =
- new CheckChildTypeMatcher(MS->getSiblingNo(), CT->getType());
NewMP->setNext(NewCCS);
- NewCCS->setNext(NewCCT);
- NewCCT->setNext(MP->takeNext());
- MatcherPtr.reset(NewMP);
- return ContractNodes(MatcherPtr, CGP);
+ NewCCS->setNext(MP->takeNext());
+ MatcherPtr->reset(NewMP);
+ continue;
+ }
+ }
+
+ // Turn MoveSibling->CheckSame->CheckType->MoveParent into
+ // MoveParent->CheckChildSame->CheckChildType.
+ if (auto *CT = dyn_cast<CheckTypeMatcher>(CS->getNext())) {
+ if (auto *MP = dyn_cast<MoveParentMatcher>(CT->getNext())) {
+ if (MS->getSiblingNo() < 4 && // Only have CheckChildSame0...3
+ CT->getResNo() == 0) { // CheckChildType checks res #0
+ auto *NewMP = new MoveParentMatcher();
+ auto *NewCCS = new CheckChildSameMatcher(MS->getSiblingNo(),
+ CS->getMatchNumber());
+ auto *NewCCT =
+ new CheckChildTypeMatcher(MS->getSiblingNo(), CT->getType());
+ NewMP->setNext(NewCCS);
+ NewCCS->setNext(NewCCT);
+ NewCCT->setNext(MP->takeNext());
+ MatcherPtr->reset(NewMP);
+ continue;
+ }
}
}
}
- }
- // Turn MoveSibling->MoveParent into MoveParent.
- if (isa<MoveParentMatcher>(MS->getNext())) {
- MatcherPtr.reset(MS->takeNext());
- return ContractNodes(MatcherPtr, CGP);
+ // Turn MoveSibling->MoveParent into MoveParent.
+ if (isa<MoveParentMatcher>(MS->getNext())) {
+ MatcherPtr->reset(MS->takeNext());
+ continue;
+ }
}
- }
- // Zap movechild -> moveparent.
- if (MoveChildMatcher *MC = dyn_cast<MoveChildMatcher>(N))
- if (MoveParentMatcher *MP = dyn_cast<MoveParentMatcher>(MC->getNext())) {
- MatcherPtr.reset(MP->takeNext());
- return ContractNodes(MatcherPtr, CGP);
- }
+ // Zap movechild -> moveparent.
+ if (MoveChildMatcher *MC = dyn_cast<MoveChildMatcher>(N))
+ if (MoveParentMatcher *MP = dyn_cast<MoveParentMatcher>(MC->getNext())) {
+ MatcherPtr->reset(MP->takeNext());
+ continue;
+ }
- // Turn EmitNode->CompleteMatch into MorphNodeTo if we can.
- if (EmitNodeMatcher *EN = dyn_cast<EmitNodeMatcher>(N))
- if (CompleteMatchMatcher *CM =
- dyn_cast<CompleteMatchMatcher>(EN->getNext())) {
- // We can only use MorphNodeTo if the result values match up.
- unsigned RootResultFirst = EN->getFirstResultSlot();
- bool ResultsMatch = true;
- for (unsigned i = 0, e = CM->getNumResults(); i != e; ++i)
- if (CM->getResult(i) != RootResultFirst + i)
+ // Turn EmitNode->CompleteMatch into MorphNodeTo if we can.
+ if (EmitNodeMatcher *EN = dyn_cast<EmitNodeMatcher>(N)) {
+ if (CompleteMatchMatcher *CM =
+ dyn_cast<CompleteMatchMatcher>(EN->getNext())) {
+ // We can only use MorphNodeTo if the result values match up.
+ unsigned RootResultFirst = EN->getFirstResultSlot();
+ bool ResultsMatch = true;
+ for (unsigned i = 0, e = CM->getNumResults(); i != e; ++i)
+ if (CM->getResult(i) != RootResultFirst + i)
+ ResultsMatch = false;
+
+ // If the selected node defines a subset of the glue/chain results, we
+ // can't use MorphNodeTo. For example, we can't use MorphNodeTo if the
+ // matched pattern has a chain but the root node doesn't.
+ const PatternToMatch &Pattern = CM->getPattern();
+
+ if (!EN->hasChain() &&
+ Pattern.getSrcPattern().NodeHasProperty(SDNPHasChain, CGP))
ResultsMatch = false;
- // If the selected node defines a subset of the glue/chain results, we
- // can't use MorphNodeTo. For example, we can't use MorphNodeTo if the
- // matched pattern has a chain but the root node doesn't.
- const PatternToMatch &Pattern = CM->getPattern();
-
- if (!EN->hasChain() &&
- Pattern.getSrcPattern().NodeHasProperty(SDNPHasChain, CGP))
- ResultsMatch = false;
-
- // If the matched node has glue and the output root doesn't, we can't
- // use MorphNodeTo.
- //
- // NOTE: Strictly speaking, we don't have to check for glue here
- // because the code in the pattern generator doesn't handle it right. We
- // do it anyway for thoroughness.
- if (!EN->hasOutGlue() &&
- Pattern.getSrcPattern().NodeHasProperty(SDNPOutGlue, CGP))
- ResultsMatch = false;
+ // If the matched node has glue and the output root doesn't, we can't
+ // use MorphNodeTo.
+ //
+ // NOTE: Strictly speaking, we don't have to check for glue here
+ // because the code in the pattern generator doesn't handle it right. We
+ // do it anyway for thoroughness.
+ if (!EN->hasOutGlue() &&
+ Pattern.getSrcPattern().NodeHasProperty(SDNPOutGlue, CGP))
+ ResultsMatch = false;
#if 0
- // If the root result node defines more results than the source root node
- // *and* has a chain or glue input, then we can't match it because it
- // would end up replacing the extra result with the chain/glue.
- if ((EN->hasGlue() || EN->hasChain()) &&
- EN->getNumNonChainGlueVTs() > ... need to get no results reliably ...)
- ResultMatch = false;
+ // If the root result node defines more results than the source root
+ // node *and* has a chain or glue input, then we can't match it because
+ // it would end up replacing the extra result with the chain/glue.
+ if ((EN->hasGlue() || EN->hasChain()) &&
+ EN->getNumNonChainGlueVTs() > ...need to get no results reliably...)
+ ResultMatch = false;
#endif
- if (ResultsMatch) {
- const SmallVectorImpl<MVT::SimpleValueType> &VTs = EN->getVTList();
- const SmallVectorImpl<unsigned> &Operands = EN->getOperandList();
- MatcherPtr.reset(new MorphNodeToMatcher(
- EN->getInstruction(), VTs, Operands, EN->hasChain(),
- EN->hasInGlue(), EN->hasOutGlue(), EN->hasMemRefs(),
- EN->getNumFixedArityOperands(), Pattern));
- return;
+ if (ResultsMatch) {
+ const SmallVectorImpl<MVT::SimpleValueType> &VTs = EN->getVTList();
+ const SmallVectorImpl<unsigned> &Operands = EN->getOperandList();
+ MatcherPtr->reset(new MorphNodeToMatcher(
+ EN->getInstruction(), VTs, Operands, EN->hasChain(),
+ EN->hasInGlue(), EN->hasOutGlue(), EN->hasMemRefs(),
+ EN->getNumFixedArityOperands(), Pattern));
+ return;
+ }
}
-
- // FIXME2: Kill off all the SelectionDAG::SelectNodeTo and getMachineNode
- // variants.
}
// If we have a Record node followed by a CheckOpcode, invert the two nodes.
@@ -299,18 +299,24 @@ static void ContractNodes(std::unique_ptr<Matcher> &MatcherPtr,
// valid on multiple types.
if (isa<RecordMatcher>(N) && isa<CheckOpcodeMatcher>(N->getNext())) {
// Unlink the two nodes from the list.
- Matcher *CheckType = MatcherPtr.release();
+ Matcher *CheckType = MatcherPtr->release();
Matcher *CheckOpcode = CheckType->takeNext();
Matcher *Tail = CheckOpcode->takeNext();
// Relink them.
- MatcherPtr.reset(CheckOpcode);
+ MatcherPtr->reset(CheckOpcode);
CheckOpcode->setNext(CheckType);
CheckType->setNext(Tail);
- return ContractNodes(MatcherPtr, CGP);
+ continue;
}
- ContractNodes(N->getNextPtr(), CGP);
+ // No contractions were performed, go to next node.
+ MatcherPtr = &(MatcherPtr->get()->getNextPtr());
+
+ // If we reached the end of the chain, we're done.
+ if (!MatcherPtr->get())
+ return;
+ }
}
/// FindNodeWithKind - Scan a series of matchers looking for a matcher with a
More information about the llvm-commits
mailing list