[llvm] 551bfca - [TableGen] Make TreePatternNode::InlinePatternFragments a static method. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 00:18:19 PDT 2023
Author: Craig Topper
Date: 2023-04-10T00:17:29-07:00
New Revision: 551bfca86fca34ef34d4d6b32a741e8dfe00e74e
URL: https://github.com/llvm/llvm-project/commit/551bfca86fca34ef34d4d6b32a741e8dfe00e74e
DIFF: https://github.com/llvm/llvm-project/commit/551bfca86fca34ef34d4d6b32a741e8dfe00e74e.diff
LOG: [TableGen] Make TreePatternNode::InlinePatternFragments a static method. NFC
Previously we were passing 'this' and the std::shared_ptr version
of 'this'. This replaces all uses of 'this' with the shared_ptr and
makes the method static.
Added:
Modified:
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/utils/TableGen/CodeGenDAGPatterns.h
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
index fd120e17a596..81821a41bd79 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -2077,25 +2077,25 @@ void TreePatternNode::InlinePatternFragments(
if (TP.hasError())
return;
- if (isLeaf()) {
+ if (T->isLeaf()) {
OutAlternatives.push_back(T); // nothing to do.
return;
}
- Record *Op = getOperator();
+ Record *Op = T->getOperator();
if (!Op->isSubClassOf("PatFrags")) {
- if (getNumChildren() == 0) {
+ if (T->getNumChildren() == 0) {
OutAlternatives.push_back(T);
return;
}
// Recursively inline children nodes.
std::vector<std::vector<TreePatternNodePtr> > ChildAlternatives;
- ChildAlternatives.resize(getNumChildren());
- for (unsigned i = 0, e = getNumChildren(); i != e; ++i) {
- TreePatternNodePtr Child = getChildShared(i);
- Child->InlinePatternFragments(Child, TP, ChildAlternatives[i]);
+ ChildAlternatives.resize(T->getNumChildren());
+ for (unsigned i = 0, e = T->getNumChildren(); i != e; ++i) {
+ TreePatternNodePtr Child = T->getChildShared(i);
+ InlinePatternFragments(Child, TP, ChildAlternatives[i]);
// If there are no alternatives for any child, there are no
// alternatives for this expression as whole.
if (ChildAlternatives[i].empty())
@@ -2120,18 +2120,18 @@ void TreePatternNode::InlinePatternFragments(
for (unsigned i = 0, e = ChildAlternatives.size(); i != e; ++i)
NewChildren.push_back(ChildAlternatives[i][Idxs[i]]);
TreePatternNodePtr R = std::make_shared<TreePatternNode>(
- getOperator(), std::move(NewChildren), getNumTypes());
+ T->getOperator(), std::move(NewChildren), T->getNumTypes());
// Copy over properties.
- R->setName(getName());
- R->setNamesAsPredicateArg(getNamesAsPredicateArg());
- R->setPredicateCalls(getPredicateCalls());
- R->setGISelFlagsRecord(getGISelFlagsRecord());
- R->setTransformFn(getTransformFn());
- for (unsigned i = 0, e = getNumTypes(); i != e; ++i)
- R->setType(i, getExtType(i));
- for (unsigned i = 0, e = getNumResults(); i != e; ++i)
- R->setResultIndex(i, getResultIndex(i));
+ R->setName(T->getName());
+ R->setNamesAsPredicateArg(T->getNamesAsPredicateArg());
+ R->setPredicateCalls(T->getPredicateCalls());
+ R->setGISelFlagsRecord(T->getGISelFlagsRecord());
+ R->setTransformFn(T->getTransformFn());
+ for (unsigned i = 0, e = T->getNumTypes(); i != e; ++i)
+ R->setType(i, T->getExtType(i));
+ for (unsigned i = 0, e = T->getNumResults(); i != e; ++i)
+ R->setResultIndex(i, T->getResultIndex(i));
// Register alternative.
OutAlternatives.push_back(R);
@@ -2157,7 +2157,7 @@ void TreePatternNode::InlinePatternFragments(
TreePattern *Frag = TP.getDAGPatterns().getPatternFragment(Op);
// Verify that we are passing the right number of operands.
- if (Frag->getNumArgs() != Children.size()) {
+ if (Frag->getNumArgs() != T->getNumChildren()) {
TP.error("'" + Op->getName() + "' fragment requires " +
Twine(Frag->getNumArgs()) + " operands!");
return;
@@ -2171,7 +2171,7 @@ void TreePatternNode::InlinePatternFragments(
// Compute the map of formal to actual arguments.
std::map<std::string, TreePatternNodePtr> ArgMap;
for (unsigned i = 0, e = Frag->getNumArgs(); i != e; ++i) {
- TreePatternNodePtr Child = getChildShared(i);
+ TreePatternNodePtr Child = T->getChildShared(i);
if (Scope != 0) {
Child = Child->clone();
Child->addNameAsPredicateArg(ScopedName(Scope, Frag->getArgName(i)));
@@ -2192,20 +2192,20 @@ void TreePatternNode::InlinePatternFragments(
// Transfer types. Note that the resolved alternative may have fewer
// (but not more) results than the PatFrags node.
- FragTree->setName(getName());
+ FragTree->setName(T->getName());
for (unsigned i = 0, e = FragTree->getNumTypes(); i != e; ++i)
- FragTree->UpdateNodeType(i, getExtType(i), TP);
+ FragTree->UpdateNodeType(i, T->getExtType(i), TP);
if (Op->isSubClassOf("GISelFlags"))
FragTree->setGISelFlagsRecord(Op);
// Transfer in the old predicates.
- for (const TreePredicateCall &Pred : getPredicateCalls())
+ for (const TreePredicateCall &Pred : T->getPredicateCalls())
FragTree->addPredicateCall(Pred);
// The fragment we inlined could have recursive inlining that is needed. See
// if there are any pattern fragments in it and inline them as needed.
- FragTree->InlinePatternFragments(FragTree, TP, OutAlternatives);
+ InlinePatternFragments(FragTree, TP, OutAlternatives);
}
}
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.h b/llvm/utils/TableGen/CodeGenDAGPatterns.h
index b8159b2b796d..d76f8edd4ab4 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.h
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.h
@@ -816,12 +816,12 @@ class TreePatternNode {
void
SubstituteFormalArguments(std::map<std::string, TreePatternNodePtr> &ArgMap);
- /// InlinePatternFragments - If this pattern refers to any pattern
+ /// InlinePatternFragments - If \p T pattern refers to any pattern
/// fragments, return the set of inlined versions (this can be more than
/// one if a PatFrags record has multiple alternatives).
- void InlinePatternFragments(TreePatternNodePtr T,
- TreePattern &TP,
- std::vector<TreePatternNodePtr> &OutAlternatives);
+ static void
+ InlinePatternFragments(TreePatternNodePtr T, TreePattern &TP,
+ std::vector<TreePatternNodePtr> &OutAlternatives);
/// ApplyTypeConstraints - Apply all of the type constraints relevant to
/// this node and its children in the tree. This returns true if it makes a
More information about the llvm-commits
mailing list