[llvm] 5f8ed1b - [TableGen] Make all the fields in PatternToMatch private. NFCI
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 6 22:49:14 PST 2021
Author: Craig Topper
Date: 2021-02-06T22:34:01-08:00
New Revision: 5f8ed1b2205d4b4aad7e713e0821dc7528d056bb
URL: https://github.com/llvm/llvm-project/commit/5f8ed1b2205d4b4aad7e713e0821dc7528d056bb
DIFF: https://github.com/llvm/llvm-project/commit/5f8ed1b2205d4b4aad7e713e0821dc7528d056bb.diff
LOG: [TableGen] Make all the fields in PatternToMatch private. NFCI
Add the few missing accessor methods. Use accessor methdods
everywhere.
Added:
Modified:
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/utils/TableGen/CodeGenDAGPatterns.h
llvm/utils/TableGen/DAGISelEmitter.cpp
llvm/utils/TableGen/DAGISelMatcherGen.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
index 669b3d367fde..394a0e1c1727 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -4287,13 +4287,13 @@ void CodeGenDAGPatterns::ExpandHwModeBasedTypes() {
PatternsToMatch.swap(Copy);
auto AppendPattern = [this, &ModeChecks](PatternToMatch &P, unsigned Mode) {
- TreePatternNodePtr NewSrc = P.SrcPattern->clone();
- TreePatternNodePtr NewDst = P.DstPattern->clone();
+ TreePatternNodePtr NewSrc = P.getSrcPattern()->clone();
+ TreePatternNodePtr NewDst = P.getDstPattern()->clone();
if (!NewSrc->setDefaultMode(Mode) || !NewDst->setDefaultMode(Mode)) {
return;
}
- std::vector<Predicate> Preds = P.Predicates;
+ std::vector<Predicate> Preds = P.getPredicates();
const std::vector<Predicate> &MC = ModeChecks[Mode];
llvm::append_range(Preds, MC);
PatternsToMatch.emplace_back(P.getSrcRecord(), std::move(Preds),
@@ -4305,10 +4305,10 @@ void CodeGenDAGPatterns::ExpandHwModeBasedTypes() {
for (PatternToMatch &P : Copy) {
TreePatternNodePtr SrcP = nullptr, DstP = nullptr;
- if (P.SrcPattern->hasProperTypeByHwMode())
- SrcP = P.SrcPattern;
- if (P.DstPattern->hasProperTypeByHwMode())
- DstP = P.DstPattern;
+ if (P.getSrcPattern()->hasProperTypeByHwMode())
+ SrcP = P.getSrcPatternShared();
+ if (P.getDstPattern()->hasProperTypeByHwMode())
+ DstP = P.getDstPatternShared();
if (!SrcP && !DstP) {
PatternsToMatch.push_back(P);
continue;
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.h b/llvm/utils/TableGen/CodeGenDAGPatterns.h
index bc939fe9acc1..2e2a9a2b1efc 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.h
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.h
@@ -1103,15 +1103,6 @@ class Predicate {
/// PatternToMatch - Used by CodeGenDAGPatterns to keep tab of patterns
/// processed to produce isel.
class PatternToMatch {
-public:
- PatternToMatch(Record *srcrecord, std::vector<Predicate> preds,
- TreePatternNodePtr src, TreePatternNodePtr dst,
- std::vector<Record *> dstregs, int complexity,
- unsigned uid, unsigned setmode = 0)
- : SrcRecord(srcrecord), SrcPattern(src), DstPattern(dst),
- Predicates(std::move(preds)), Dstregs(std::move(dstregs)),
- AddedComplexity(complexity), ID(uid), ForceMode(setmode) {}
-
Record *SrcRecord; // Originating Record for the pattern.
TreePatternNodePtr SrcPattern; // Source pattern to match.
TreePatternNodePtr DstPattern; // Resulting pattern.
@@ -1122,6 +1113,15 @@ class PatternToMatch {
unsigned ID; // Unique ID for the record.
unsigned ForceMode; // Force this mode in type inference when set.
+public:
+ PatternToMatch(Record *srcrecord, std::vector<Predicate> preds,
+ TreePatternNodePtr src, TreePatternNodePtr dst,
+ std::vector<Record *> dstregs, int complexity,
+ unsigned uid, unsigned setmode = 0)
+ : SrcRecord(srcrecord), SrcPattern(src), DstPattern(dst),
+ Predicates(std::move(preds)), Dstregs(std::move(dstregs)),
+ AddedComplexity(complexity), ID(uid), ForceMode(setmode) {}
+
Record *getSrcRecord() const { return SrcRecord; }
TreePatternNode *getSrcPattern() const { return SrcPattern.get(); }
TreePatternNodePtr getSrcPatternShared() const { return SrcPattern; }
@@ -1130,6 +1130,8 @@ class PatternToMatch {
const std::vector<Record*> &getDstRegs() const { return Dstregs; }
int getAddedComplexity() const { return AddedComplexity; }
const std::vector<Predicate> &getPredicates() const { return Predicates; }
+ unsigned getID() const { return ID; }
+ unsigned getForceMode() const { return ForceMode; }
std::string getPredicateCheck() const;
diff --git a/llvm/utils/TableGen/DAGISelEmitter.cpp b/llvm/utils/TableGen/DAGISelEmitter.cpp
index b9762f9972af..7b3dc03a67e1 100644
--- a/llvm/utils/TableGen/DAGISelEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelEmitter.cpp
@@ -115,7 +115,7 @@ struct PatternSortingPredicate {
// pattern may have been resolved into multiple match patterns due to
// alternative fragments. To ensure deterministic output, always use
// std::stable_sort with this predicate.
- return LHS->ID < RHS->ID;
+ return LHS->getID() < RHS->getID();
}
};
} // End anonymous namespace
diff --git a/llvm/utils/TableGen/DAGISelMatcherGen.cpp b/llvm/utils/TableGen/DAGISelMatcherGen.cpp
index f7415b87e1c0..2625595cf9d5 100644
--- a/llvm/utils/TableGen/DAGISelMatcherGen.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherGen.cpp
@@ -163,7 +163,7 @@ MatcherGen::MatcherGen(const PatternToMatch &pattern,
PatWithNoTypes->RemoveAllTypes();
// If there are types that are manifestly known, infer them.
- InferPossibleTypes(Pattern.ForceMode);
+ InferPossibleTypes(Pattern.getForceMode());
}
/// InferPossibleTypes - As we emit the pattern, we end up generating type
@@ -576,7 +576,7 @@ bool MatcherGen::EmitMatcherCode(unsigned Variant) {
// Emit the matcher for the pattern structure and types.
EmitMatchCode(Pattern.getSrcPattern(), PatWithNoTypes.get(),
- Pattern.ForceMode);
+ Pattern.getForceMode());
// If the pattern has a predicate on it (e.g. only enabled when a subtarget
// feature is around, do the check).
More information about the llvm-commits
mailing list