From 0d9ccf3b16ca74a60d9f3991c2859fa386c1f742 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sat, 6 Feb 2021 22:31:38 -0800 Subject: [PATCH] [TableGen] Make all the fields in PatternToMatch private. NFCI Add the few missing accessor methods. Use accessor methdods everywhere. --- utils/TableGen/CodeGenDAGPatterns.cpp | 14 +++++++------- utils/TableGen/CodeGenDAGPatterns.h | 20 +++++++++++--------- utils/TableGen/DAGISelEmitter.cpp | 2 +- utils/TableGen/DAGISelMatcherGen.cpp | 4 ++-- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/utils/TableGen/CodeGenDAGPatterns.cpp b/utils/TableGen/CodeGenDAGPatterns.cpp index 669b3d367fd..394a0e1c172 100644 --- a/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/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 Preds = P.Predicates; + std::vector Preds = P.getPredicates(); const std::vector &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/utils/TableGen/CodeGenDAGPatterns.h b/utils/TableGen/CodeGenDAGPatterns.h index bc939fe9acc..2e2a9a2b1ef 100644 --- a/utils/TableGen/CodeGenDAGPatterns.h +++ b/utils/TableGen/CodeGenDAGPatterns.h @@ -1103,15 +1103,6 @@ public: /// PatternToMatch - Used by CodeGenDAGPatterns to keep tab of patterns /// processed to produce isel. class PatternToMatch { -public: - PatternToMatch(Record *srcrecord, std::vector preds, - TreePatternNodePtr src, TreePatternNodePtr dst, - std::vector 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 @@ public: unsigned ID; // Unique ID for the record. unsigned ForceMode; // Force this mode in type inference when set. +public: + PatternToMatch(Record *srcrecord, std::vector preds, + TreePatternNodePtr src, TreePatternNodePtr dst, + std::vector 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 @@ public: const std::vector &getDstRegs() const { return Dstregs; } int getAddedComplexity() const { return AddedComplexity; } const std::vector &getPredicates() const { return Predicates; } + unsigned getID() const { return ID; } + unsigned getForceMode() const { return ForceMode; } std::string getPredicateCheck() const; diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index b9762f9972a..7b3dc03a67e 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/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/utils/TableGen/DAGISelMatcherGen.cpp b/utils/TableGen/DAGISelMatcherGen.cpp index f7415b87e1c..2625595cf9d 100644 --- a/utils/TableGen/DAGISelMatcherGen.cpp +++ b/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).