1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

resolve a fixme and simplify code by moving insertion of the

EmitMergeInputChainsMatcher node up into EmitResultCode.  This
doesn't have much of an effect on the generated code, the X86
table is exactly the same size.

llvm-svn: 97514
This commit is contained in:
Chris Lattner 2010-03-01 22:46:42 +00:00
parent 14ef40723a
commit 4fb9708649

View File

@ -80,10 +80,6 @@ namespace {
/// second is the recorded slot number the input pattern match saved it in. /// second is the recorded slot number the input pattern match saved it in.
SmallVector<std::pair<Record*, unsigned>, 2> PhysRegInputs; SmallVector<std::pair<Record*, unsigned>, 2> PhysRegInputs;
/// EmittedMergeInputChains - For nodes that match patterns involving
/// chains, is set to true if we emitted the "MergeInputChains" operation.
bool EmittedMergeInputChains;
/// Matcher - This is the top level of the generated matcher, the result. /// Matcher - This is the top level of the generated matcher, the result.
Matcher *TheMatcher; Matcher *TheMatcher;
@ -141,7 +137,7 @@ namespace {
MatcherGen::MatcherGen(const PatternToMatch &pattern, MatcherGen::MatcherGen(const PatternToMatch &pattern,
const CodeGenDAGPatterns &cgp) const CodeGenDAGPatterns &cgp)
: Pattern(pattern), CGP(cgp), NextRecordedOperandNo(0), : Pattern(pattern), CGP(cgp), NextRecordedOperandNo(0),
EmittedMergeInputChains(false), TheMatcher(0), CurPredicate(0) { TheMatcher(0), CurPredicate(0) {
// We need to produce the matcher tree for the patterns source pattern. To do // We need to produce the matcher tree for the patterns source pattern. To do
// this we need to match the structure as well as the types. To do the type // this we need to match the structure as well as the types. To do the type
// matching, we want to figure out the fewest number of type checks we need to // matching, we want to figure out the fewest number of type checks we need to
@ -693,19 +689,6 @@ EmitResultInstructionAsOperand(const TreePatternNode *N,
++ChildNo; ++ChildNo;
} }
// Nodes that match patterns with (potentially multiple) chain inputs have to
// merge them together into a token factor.
if (NodeHasChain && !EmittedMergeInputChains) {
// FIXME2: Move this out of emitresult to a top level place.
assert(!MatchedChainNodes.empty() &&
"How can this node have chain if no inputs do?");
// Otherwise, we have to emit an operation to merge the input chains and
// set this as the current input chain.
AddMatcher(new EmitMergeInputChainsMatcher
(MatchedChainNodes.data(), MatchedChainNodes.size()));
EmittedMergeInputChains = true;
}
// If this node has an input flag or explicitly specified input physregs, we // If this node has an input flag or explicitly specified input physregs, we
// need to add chained and flagged copyfromreg nodes and materialize the flag // need to add chained and flagged copyfromreg nodes and materialize the flag
// input. // input.
@ -819,6 +802,13 @@ void MatcherGen::EmitResultOperand(const TreePatternNode *N,
} }
void MatcherGen::EmitResultCode() { void MatcherGen::EmitResultCode() {
// Patterns that match nodes with (potentially multiple) chain inputs have to
// merge them together into a token factor. This informs the generated code
// what all the chained nodes are.
if (!MatchedChainNodes.empty())
AddMatcher(new EmitMergeInputChainsMatcher
(MatchedChainNodes.data(), MatchedChainNodes.size()));
// Codegen the root of the result pattern, capturing the resulting values. // Codegen the root of the result pattern, capturing the resulting values.
SmallVector<unsigned, 8> Ops; SmallVector<unsigned, 8> Ops;
EmitResultOperand(Pattern.getDstPattern(), Ops); EmitResultOperand(Pattern.getDstPattern(), Ops);