Skip to content

Commit 4eebc8d

Browse files
authored
[PatternMatch] Mark various matchers const (NFC) (#138834)
Mark matchers const and remove an extraneous template parameter in SCEVPatternMatch. Since SCEVPatternMatch is intertwined with PatternMatch, also fix constness issues there.
1 parent 358ebdd commit 4eebc8d

File tree

4 files changed

+132
-122
lines changed

4 files changed

+132
-122
lines changed

llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
namespace llvm {
1919
namespace SCEVPatternMatch {
2020

21-
template <typename Val, typename Pattern>
22-
bool match(const SCEV *S, const Pattern &P) {
21+
template <typename Pattern> bool match(const SCEV *S, const Pattern &P) {
2322
return P.match(S);
2423
}
2524

2625
template <typename Predicate> struct cst_pred_ty : public Predicate {
27-
bool match(const SCEV *S) {
26+
bool match(const SCEV *S) const {
2827
assert((isa<SCEVCouldNotCompute>(S) || !S->getType()->isVectorTy()) &&
2928
"no vector types expected from SCEVs");
3029
auto *C = dyn_cast<SCEVConstant>(S);
@@ -33,20 +32,23 @@ template <typename Predicate> struct cst_pred_ty : public Predicate {
3332
};
3433

3534
struct is_zero {
36-
bool isValue(const APInt &C) { return C.isZero(); }
35+
bool isValue(const APInt &C) const { return C.isZero(); }
3736
};
37+
3838
/// Match an integer 0.
3939
inline cst_pred_ty<is_zero> m_scev_Zero() { return cst_pred_ty<is_zero>(); }
4040

4141
struct is_one {
42-
bool isValue(const APInt &C) { return C.isOne(); }
42+
bool isValue(const APInt &C) const { return C.isOne(); }
4343
};
44+
4445
/// Match an integer 1.
4546
inline cst_pred_ty<is_one> m_scev_One() { return cst_pred_ty<is_one>(); }
4647

4748
struct is_all_ones {
48-
bool isValue(const APInt &C) { return C.isAllOnes(); }
49+
bool isValue(const APInt &C) const { return C.isAllOnes(); }
4950
};
51+
5052
/// Match an integer with all bits set.
5153
inline cst_pred_ty<is_all_ones> m_scev_AllOnes() {
5254
return cst_pred_ty<is_all_ones>();
@@ -85,7 +87,7 @@ struct specificscev_ty {
8587

8688
specificscev_ty(const SCEV *Expr) : Expr(Expr) {}
8789

88-
template <typename ITy> bool match(ITy *S) { return S == Expr; }
90+
template <typename ITy> bool match(ITy *S) const { return S == Expr; }
8991
};
9092

9193
/// Match if we have a specific specified SCEV.
@@ -97,7 +99,7 @@ template <typename SCEVTy, typename Op0_t> struct SCEVUnaryExpr_match {
9799

98100
SCEVUnaryExpr_match(Op0_t Op0) : Op0(Op0) {}
99101

100-
bool match(const SCEV *S) {
102+
bool match(const SCEV *S) const {
101103
auto *E = dyn_cast<SCEVTy>(S);
102104
return E && E->getNumOperands() == 1 && Op0.match(E->getOperand(0));
103105
}
@@ -128,7 +130,7 @@ struct SCEVBinaryExpr_match {
128130

129131
SCEVBinaryExpr_match(Op0_t Op0, Op1_t Op1) : Op0(Op0), Op1(Op1) {}
130132

131-
bool match(const SCEV *S) {
133+
bool match(const SCEV *S) const {
132134
auto *E = dyn_cast<SCEVTy>(S);
133135
return E && E->getNumOperands() == 2 && Op0.match(E->getOperand(0)) &&
134136
Op1.match(E->getOperand(1));

0 commit comments

Comments
 (0)