mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-19 09:58:19 +00:00
don't emit useless functions. These were producing
warnings in release-assert builds if there were no cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97428 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5d96eb8671
commit
d20c0bc569
@ -445,64 +445,73 @@ void MatcherTableEmitter::EmitPredicateFunctions(formatted_raw_ostream &OS) {
|
||||
// here into the case stmts.
|
||||
|
||||
// Emit pattern predicates.
|
||||
OS << "bool CheckPatternPredicate(unsigned PredNo) const {\n";
|
||||
OS << " switch (PredNo) {\n";
|
||||
OS << " default: assert(0 && \"Invalid predicate in table?\");\n";
|
||||
for (unsigned i = 0, e = PatternPredicates.size(); i != e; ++i)
|
||||
OS << " case " << i << ": return " << PatternPredicates[i] << ";\n";
|
||||
OS << " }\n";
|
||||
OS << "}\n\n";
|
||||
if (!PatternPredicates.empty()) {
|
||||
OS << "bool CheckPatternPredicate(unsigned PredNo) const {\n";
|
||||
OS << " switch (PredNo) {\n";
|
||||
OS << " default: assert(0 && \"Invalid predicate in table?\");\n";
|
||||
for (unsigned i = 0, e = PatternPredicates.size(); i != e; ++i)
|
||||
OS << " case " << i << ": return " << PatternPredicates[i] << ";\n";
|
||||
OS << " }\n";
|
||||
OS << "}\n\n";
|
||||
}
|
||||
|
||||
|
||||
// Emit Node predicates.
|
||||
OS << "bool CheckNodePredicate(SDNode *N, unsigned PredNo) const {\n";
|
||||
OS << " switch (PredNo) {\n";
|
||||
OS << " default: assert(0 && \"Invalid predicate in table?\");\n";
|
||||
for (unsigned i = 0, e = NodePredicates.size(); i != e; ++i)
|
||||
OS << " case " << i << ": return " << NodePredicates[i] << "(N);\n";
|
||||
OS << " }\n";
|
||||
OS << "}\n\n";
|
||||
if (!NodePredicates.empty()) {
|
||||
OS << "bool CheckNodePredicate(SDNode *N, unsigned PredNo) const {\n";
|
||||
OS << " switch (PredNo) {\n";
|
||||
OS << " default: assert(0 && \"Invalid predicate in table?\");\n";
|
||||
for (unsigned i = 0, e = NodePredicates.size(); i != e; ++i)
|
||||
OS << " case " << i << ": return " << NodePredicates[i] << "(N);\n";
|
||||
OS << " }\n";
|
||||
OS << "}\n\n";
|
||||
}
|
||||
|
||||
// Emit CompletePattern matchers.
|
||||
// FIXME: This should be const.
|
||||
OS << "bool CheckComplexPattern(SDNode *Root, SDValue N,\n";
|
||||
OS << " unsigned PatternNo, SmallVectorImpl<SDValue> &Result) {\n";
|
||||
OS << " switch (PatternNo) {\n";
|
||||
OS << " default: assert(0 && \"Invalid pattern # in table?\");\n";
|
||||
for (unsigned i = 0, e = ComplexPatterns.size(); i != e; ++i) {
|
||||
const ComplexPattern &P = *ComplexPatterns[i];
|
||||
unsigned NumOps = P.getNumOperands();
|
||||
if (!ComplexPatterns.empty()) {
|
||||
OS << "bool CheckComplexPattern(SDNode *Root, SDValue N,\n";
|
||||
OS << " unsigned PatternNo, SmallVectorImpl<SDValue> &Result) {\n";
|
||||
OS << " switch (PatternNo) {\n";
|
||||
OS << " default: assert(0 && \"Invalid pattern # in table?\");\n";
|
||||
for (unsigned i = 0, e = ComplexPatterns.size(); i != e; ++i) {
|
||||
const ComplexPattern &P = *ComplexPatterns[i];
|
||||
unsigned NumOps = P.getNumOperands();
|
||||
|
||||
if (P.hasProperty(SDNPHasChain))
|
||||
++NumOps; // Get the chained node too.
|
||||
|
||||
OS << " case " << i << ":\n";
|
||||
OS << " Result.resize(Result.size()+" << NumOps << ");\n";
|
||||
OS << " return " << P.getSelectFunc();
|
||||
if (P.hasProperty(SDNPHasChain))
|
||||
++NumOps; // Get the chained node too.
|
||||
|
||||
OS << " case " << i << ":\n";
|
||||
OS << " Result.resize(Result.size()+" << NumOps << ");\n";
|
||||
OS << " return " << P.getSelectFunc();
|
||||
|
||||
// FIXME: Temporary hack until old isel dies.
|
||||
if (P.hasProperty(SDNPHasChain))
|
||||
OS << "XXX";
|
||||
|
||||
OS << "(Root, N";
|
||||
for (unsigned i = 0; i != NumOps; ++i)
|
||||
OS << ", Result[Result.size()-" << (NumOps-i) << ']';
|
||||
OS << ");\n";
|
||||
// FIXME: Temporary hack until old isel dies.
|
||||
if (P.hasProperty(SDNPHasChain))
|
||||
OS << "XXX";
|
||||
|
||||
OS << "(Root, N";
|
||||
for (unsigned i = 0; i != NumOps; ++i)
|
||||
OS << ", Result[Result.size()-" << (NumOps-i) << ']';
|
||||
OS << ");\n";
|
||||
}
|
||||
OS << " }\n";
|
||||
OS << "}\n\n";
|
||||
}
|
||||
OS << " }\n";
|
||||
OS << "}\n\n";
|
||||
|
||||
// Emit SDNodeXForm handlers.
|
||||
// FIXME: This should be const.
|
||||
OS << "SDValue RunSDNodeXForm(SDValue V, unsigned XFormNo) {\n";
|
||||
OS << " switch (XFormNo) {\n";
|
||||
OS << " default: assert(0 && \"Invalid xform # in table?\");\n";
|
||||
|
||||
// FIXME: The node xform could take SDValue's instead of SDNode*'s.
|
||||
for (unsigned i = 0, e = NodeXForms.size(); i != e; ++i)
|
||||
OS << " case " << i << ": return Transform_" << NodeXForms[i]->getName()
|
||||
<< "(V.getNode());\n";
|
||||
OS << " }\n";
|
||||
OS << "}\n\n";
|
||||
if (!NodeXForms.empty()) {
|
||||
OS << "SDValue RunSDNodeXForm(SDValue V, unsigned XFormNo) {\n";
|
||||
OS << " switch (XFormNo) {\n";
|
||||
OS << " default: assert(0 && \"Invalid xform # in table?\");\n";
|
||||
|
||||
// FIXME: The node xform could take SDValue's instead of SDNode*'s.
|
||||
for (unsigned i = 0, e = NodeXForms.size(); i != e; ++i)
|
||||
OS << " case " << i << ": return Transform_" << NodeXForms[i]->getName()
|
||||
<< "(V.getNode());\n";
|
||||
OS << " }\n";
|
||||
OS << "}\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
void MatcherTableEmitter::EmitHistogram(formatted_raw_ostream &OS) {
|
||||
|
Loading…
Reference in New Issue
Block a user