Skip to content

Commit 87b4a1d

Browse files
committed
VPlan/PatternMatch: mark match functions const (NFC)
1 parent 725fab9 commit 87b4a1d

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace llvm {
2626
namespace VPlanPatternMatch {
2727

2828
template <typename Val, typename Pattern> bool match(Val *V, const Pattern &P) {
29-
return const_cast<Pattern &>(P).match(V);
29+
return P.match(V);
3030
}
3131

3232
template <typename Pattern> bool match(VPUser *U, const Pattern &P) {
@@ -35,7 +35,7 @@ template <typename Pattern> bool match(VPUser *U, const Pattern &P) {
3535
}
3636

3737
template <typename Class> struct class_match {
38-
template <typename ITy> bool match(ITy *V) { return isa<Class>(V); }
38+
template <typename ITy> bool match(ITy *V) const { return isa<Class>(V); }
3939
};
4040

4141
/// Match an arbitrary VPValue and ignore it.
@@ -46,7 +46,7 @@ template <typename Class> struct bind_ty {
4646

4747
bind_ty(Class *&V) : VR(V) {}
4848

49-
template <typename ITy> bool match(ITy *V) {
49+
template <typename ITy> bool match(ITy *V) const {
5050
if (auto *CV = dyn_cast<Class>(V)) {
5151
VR = CV;
5252
return true;
@@ -63,7 +63,7 @@ template <unsigned BitWidth = 0> struct specific_intval {
6363

6464
specific_intval(APInt V) : Val(std::move(V)) {}
6565

66-
bool match(VPValue *VPV) {
66+
bool match(VPValue *VPV) const {
6767
if (!VPV->isLiveIn())
6868
return false;
6969
Value *V = VPV->getLiveInIRValue();
@@ -94,7 +94,7 @@ template <typename LTy, typename RTy> struct match_combine_or {
9494

9595
match_combine_or(const LTy &Left, const RTy &Right) : L(Left), R(Right) {}
9696

97-
template <typename ITy> bool match(ITy *V) {
97+
template <typename ITy> bool match(ITy *V) const {
9898
if (L.match(V))
9999
return true;
100100
if (R.match(V))
@@ -139,12 +139,12 @@ struct UnaryRecipe_match {
139139

140140
UnaryRecipe_match(Op0_t Op0) : Op0(Op0) {}
141141

142-
bool match(const VPValue *V) {
142+
bool match(const VPValue *V) const {
143143
auto *DefR = V->getDefiningRecipe();
144144
return DefR && match(DefR);
145145
}
146146

147-
bool match(const VPRecipeBase *R) {
147+
bool match(const VPRecipeBase *R) const {
148148
if (!detail::MatchRecipeAndOpcode<Opcode, RecipeTys...>::match(R))
149149
return false;
150150
assert(R->getNumOperands() == 1 &&
@@ -170,16 +170,16 @@ struct BinaryRecipe_match {
170170

171171
BinaryRecipe_match(Op0_t Op0, Op1_t Op1) : Op0(Op0), Op1(Op1) {}
172172

173-
bool match(const VPValue *V) {
173+
bool match(const VPValue *V) const {
174174
auto *DefR = V->getDefiningRecipe();
175175
return DefR && match(DefR);
176176
}
177177

178-
bool match(const VPSingleDefRecipe *R) {
178+
bool match(const VPSingleDefRecipe *R) const {
179179
return match(static_cast<const VPRecipeBase *>(R));
180180
}
181181

182-
bool match(const VPRecipeBase *R) {
182+
bool match(const VPRecipeBase *R) const {
183183
if (!detail::MatchRecipeAndOpcode<Opcode, RecipeTys...>::match(R))
184184
return false;
185185
assert(R->getNumOperands() == 2 &&
@@ -310,12 +310,14 @@ m_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
310310
}
311311

312312
struct VPCanonicalIVPHI_match {
313-
bool match(const VPValue *V) {
313+
bool match(const VPValue *V) const {
314314
auto *DefR = V->getDefiningRecipe();
315315
return DefR && match(DefR);
316316
}
317317

318-
bool match(const VPRecipeBase *R) { return isa<VPCanonicalIVPHIRecipe>(R); }
318+
bool match(const VPRecipeBase *R) const {
319+
return isa<VPCanonicalIVPHIRecipe>(R);
320+
}
319321
};
320322

321323
inline VPCanonicalIVPHI_match m_CanonicalIV() {
@@ -328,12 +330,12 @@ template <typename Op0_t, typename Op1_t> struct VPScalarIVSteps_match {
328330

329331
VPScalarIVSteps_match(Op0_t Op0, Op1_t Op1) : Op0(Op0), Op1(Op1) {}
330332

331-
bool match(const VPValue *V) {
333+
bool match(const VPValue *V) const {
332334
auto *DefR = V->getDefiningRecipe();
333335
return DefR && match(DefR);
334336
}
335337

336-
bool match(const VPRecipeBase *R) {
338+
bool match(const VPRecipeBase *R) const {
337339
if (!isa<VPScalarIVStepsRecipe>(R))
338340
return false;
339341
assert(R->getNumOperands() == 2 &&

0 commit comments

Comments
 (0)