forked from OSchip/llvm-project
refactor some code out of OPC_EmitMergeInputChains into a
new helper function. llvm-svn: 97525
This commit is contained in:
parent
d29f2799b7
commit
c1f2e15332
|
@ -1574,7 +1574,34 @@ static void UpdateChainsAndFlags(SDNode *NodeToMatch, SDValue InputChain,
|
||||||
DEBUG(errs() << "ISEL: Match complete!\n");
|
DEBUG(errs() << "ISEL: Match complete!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// HandleMergeInputChains - This implements the OPC_EmitMergeInputChains
|
||||||
|
/// operation for when the pattern matched multiple nodes with chains.
|
||||||
|
static SDValue
|
||||||
|
HandleMergeInputChains(const SmallVectorImpl<SDNode*> &ChainNodesMatched,
|
||||||
|
SelectionDAG *CurDAG) {
|
||||||
|
assert(ChainNodesMatched.size() > 1 &&
|
||||||
|
"Should only happen for multi chain node case");
|
||||||
|
|
||||||
|
// Walk all the chained nodes, adding the input chains if they are not in
|
||||||
|
// ChainedNodes (and this, not in the matched pattern). This is an N^2
|
||||||
|
// algorithm, but # chains is usually 2 here, at most 3 for MSP430.
|
||||||
|
SmallVector<SDValue, 3> InputChains;
|
||||||
|
for (unsigned i = 0, e = ChainNodesMatched.size(); i != e; ++i) {
|
||||||
|
SDValue InChain = ChainNodesMatched[i]->getOperand(0);
|
||||||
|
assert(InChain.getValueType() == MVT::Other && "Not a chain");
|
||||||
|
bool Invalid = false;
|
||||||
|
for (unsigned j = 0; j != e; ++j)
|
||||||
|
Invalid |= ChainNodesMatched[j] == InChain.getNode();
|
||||||
|
if (!Invalid)
|
||||||
|
InputChains.push_back(InChain);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDValue Res;
|
||||||
|
if (InputChains.size() == 1)
|
||||||
|
return InputChains[0];
|
||||||
|
return CurDAG->getNode(ISD::TokenFactor, ChainNodesMatched[0]->getDebugLoc(),
|
||||||
|
MVT::Other, &InputChains[0], InputChains.size());
|
||||||
|
}
|
||||||
|
|
||||||
struct MatchScope {
|
struct MatchScope {
|
||||||
/// FailIndex - If this match fails, this is the index to continue with.
|
/// FailIndex - If this match fails, this is the index to continue with.
|
||||||
|
@ -2027,27 +2054,16 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Walk all the chained nodes, adding the input chains if they are not in
|
// If the inner loop broke out, the match fails.
|
||||||
// ChainedNodes (and this, not in the matched pattern). This is an N^2
|
if (ChainNodesMatched.empty())
|
||||||
// algorithm, but # chains is usually 2 here, at most 3 for MSP430.
|
break;
|
||||||
SmallVector<SDValue, 3> InputChains;
|
|
||||||
for (unsigned i = 0, e = ChainNodesMatched.size(); i != e; ++i) {
|
// Merge the input chains if they are not intra-pattern references.
|
||||||
SDValue InChain = ChainNodesMatched[i]->getOperand(0);
|
InputChain = HandleMergeInputChains(ChainNodesMatched, CurDAG);
|
||||||
assert(InChain.getValueType() == MVT::Other && "Not a chain");
|
|
||||||
bool Invalid = false;
|
if (InputChain.getNode() == 0)
|
||||||
for (unsigned j = 0; j != e; ++j)
|
break; // Failed to merge.
|
||||||
Invalid |= ChainNodesMatched[j] == InChain.getNode();
|
|
||||||
if (!Invalid)
|
|
||||||
InputChains.push_back(InChain);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDValue Res;
|
|
||||||
if (InputChains.size() == 1)
|
|
||||||
InputChain = InputChains[0];
|
|
||||||
else
|
|
||||||
InputChain = CurDAG->getNode(ISD::TokenFactor,
|
|
||||||
NodeToMatch->getDebugLoc(), MVT::Other,
|
|
||||||
&InputChains[0], InputChains.size());
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue