[llvm] 50c45e0 - [TableGen] Move some vectors into place instead of copying them.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 1 15:49:52 PDT 2023
Author: Craig Topper
Date: 2023-04-01T15:41:29-07:00
New Revision: 50c45e0ac7386ead60422181193c19c85e15424e
URL: https://github.com/llvm/llvm-project/commit/50c45e0ac7386ead60422181193c19c85e15424e
DIFF: https://github.com/llvm/llvm-project/commit/50c45e0ac7386ead60422181193c19c85e15424e.diff
LOG: [TableGen] Move some vectors into place instead of copying them.
Added:
Modified:
llvm/utils/TableGen/DAGISelEmitter.cpp
llvm/utils/TableGen/DAGISelMatcher.h
llvm/utils/TableGen/DAGISelMatcherOpt.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/DAGISelEmitter.cpp b/llvm/utils/TableGen/DAGISelEmitter.cpp
index cf8e3f2675716..eaf7f7f9f0a3a 100644
--- a/llvm/utils/TableGen/DAGISelEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelEmitter.cpp
@@ -165,7 +165,7 @@ void DAGISelEmitter::run(raw_ostream &OS) {
// Convert each variant of each pattern into a Matcher.
Records.startTimer("Convert to matchers");
- std::vector<Matcher*> PatternMatchers;
+ SmallVector<Matcher *, 0> PatternMatchers;
for (const PatternToMatch *PTM : Patterns) {
for (unsigned Variant = 0; ; ++Variant) {
if (Matcher *M = ConvertPatternToMatcher(*PTM, Variant, CGP))
@@ -176,7 +176,7 @@ void DAGISelEmitter::run(raw_ostream &OS) {
}
std::unique_ptr<Matcher> TheMatcher =
- std::make_unique<ScopeMatcher>(PatternMatchers);
+ std::make_unique<ScopeMatcher>(std::move(PatternMatchers));
Records.startTimer("Optimize matchers");
OptimizeMatcher(TheMatcher, CGP);
diff --git a/llvm/utils/TableGen/DAGISelMatcher.h b/llvm/utils/TableGen/DAGISelMatcher.h
index c9094f5675e63..f883bf3f2b9a4 100644
--- a/llvm/utils/TableGen/DAGISelMatcher.h
+++ b/llvm/utils/TableGen/DAGISelMatcher.h
@@ -194,9 +194,8 @@ class Matcher {
class ScopeMatcher : public Matcher {
SmallVector<Matcher*, 4> Children;
public:
- ScopeMatcher(ArrayRef<Matcher *> children)
- : Matcher(Scope), Children(children.begin(), children.end()) {
- }
+ ScopeMatcher(SmallVectorImpl<Matcher *> &&children)
+ : Matcher(Scope), Children(std::move(children)) {}
~ScopeMatcher() override;
unsigned getNumChildren() const { return Children.size(); }
@@ -478,8 +477,9 @@ class CheckOpcodeMatcher : public Matcher {
class SwitchOpcodeMatcher : public Matcher {
SmallVector<std::pair<const SDNodeInfo*, Matcher*>, 8> Cases;
public:
- SwitchOpcodeMatcher(ArrayRef<std::pair<const SDNodeInfo*, Matcher*> > cases)
- : Matcher(SwitchOpcode), Cases(cases.begin(), cases.end()) {}
+ SwitchOpcodeMatcher(
+ SmallVectorImpl<std::pair<const SDNodeInfo *, Matcher *>> &&cases)
+ : Matcher(SwitchOpcode), Cases(std::move(cases)) {}
~SwitchOpcodeMatcher() override;
static bool classof(const Matcher *N) {
@@ -528,8 +528,9 @@ class CheckTypeMatcher : public Matcher {
class SwitchTypeMatcher : public Matcher {
SmallVector<std::pair<MVT::SimpleValueType, Matcher*>, 8> Cases;
public:
- SwitchTypeMatcher(ArrayRef<std::pair<MVT::SimpleValueType, Matcher*> > cases)
- : Matcher(SwitchType), Cases(cases.begin(), cases.end()) {}
+ SwitchTypeMatcher(
+ SmallVectorImpl<std::pair<MVT::SimpleValueType, Matcher *>> &&cases)
+ : Matcher(SwitchType), Cases(std::move(cases)) {}
~SwitchTypeMatcher() override;
static bool classof(const Matcher *N) {
diff --git a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
index 764b86c97dbf8..7dfd425f9010f 100644
--- a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
@@ -324,8 +324,8 @@ static void FactorNodes(std::unique_ptr<Matcher> &InputMatcherPtr) {
delete EqualMatchers[i];
EqualMatchers[i] = Tmp;
}
-
- Shared->setNext(new ScopeMatcher(EqualMatchers));
+
+ Shared->setNext(new ScopeMatcher(std::move(EqualMatchers)));
// Recursively factor the newly created node.
FactorNodes(Shared->getNextPtr());
@@ -400,8 +400,8 @@ static void FactorNodes(std::unique_ptr<Matcher> &InputMatcherPtr) {
Cases.push_back(std::make_pair(&COM->getOpcode(), COM->takeNext()));
delete COM;
}
-
- MatcherPtr.reset(new SwitchOpcodeMatcher(Cases));
+
+ MatcherPtr.reset(new SwitchOpcodeMatcher(std::move(Cases)));
return;
}
@@ -427,9 +427,9 @@ static void FactorNodes(std::unique_ptr<Matcher> &InputMatcherPtr) {
SM->resetChild(SM->getNumChildren()-1, MatcherWithoutCTM);
continue;
}
-
- Matcher *Entries[2] = { PrevMatcher, MatcherWithoutCTM };
- Cases[Entry-1].second = new ScopeMatcher(Entries);
+
+ SmallVector<Matcher *, 2> Entries = {PrevMatcher, MatcherWithoutCTM};
+ Cases[Entry - 1].second = new ScopeMatcher(std::move(Entries));
continue;
}
@@ -448,7 +448,7 @@ static void FactorNodes(std::unique_ptr<Matcher> &InputMatcherPtr) {
}
if (Cases.size() != 1) {
- MatcherPtr.reset(new SwitchTypeMatcher(Cases));
+ MatcherPtr.reset(new SwitchTypeMatcher(std::move(Cases)));
} else {
// If we factored and ended up with one case, create it now.
MatcherPtr.reset(new CheckTypeMatcher(Cases[0].first, 0));
More information about the llvm-commits
mailing list