@@ -26,7 +26,7 @@ namespace llvm {
26
26
namespace VPlanPatternMatch {
27
27
28
28
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);
30
30
}
31
31
32
32
template <typename Pattern> bool match (VPUser *U, const Pattern &P) {
@@ -35,7 +35,7 @@ template <typename Pattern> bool match(VPUser *U, const Pattern &P) {
35
35
}
36
36
37
37
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); }
39
39
};
40
40
41
41
// / Match an arbitrary VPValue and ignore it.
@@ -46,7 +46,7 @@ template <typename Class> struct bind_ty {
46
46
47
47
bind_ty (Class *&V) : VR(V) {}
48
48
49
- template <typename ITy> bool match (ITy *V) {
49
+ template <typename ITy> bool match (ITy *V) const {
50
50
if (auto *CV = dyn_cast<Class>(V)) {
51
51
VR = CV;
52
52
return true ;
@@ -63,7 +63,7 @@ template <unsigned BitWidth = 0> struct specific_intval {
63
63
64
64
specific_intval (APInt V) : Val(std::move(V)) {}
65
65
66
- bool match (VPValue *VPV) {
66
+ bool match (VPValue *VPV) const {
67
67
if (!VPV->isLiveIn ())
68
68
return false ;
69
69
Value *V = VPV->getLiveInIRValue ();
@@ -94,7 +94,7 @@ template <typename LTy, typename RTy> struct match_combine_or {
94
94
95
95
match_combine_or (const LTy &Left, const RTy &Right) : L(Left), R(Right) {}
96
96
97
- template <typename ITy> bool match (ITy *V) {
97
+ template <typename ITy> bool match (ITy *V) const {
98
98
if (L.match (V))
99
99
return true ;
100
100
if (R.match (V))
@@ -139,12 +139,12 @@ struct UnaryRecipe_match {
139
139
140
140
UnaryRecipe_match (Op0_t Op0) : Op0(Op0) {}
141
141
142
- bool match (const VPValue *V) {
142
+ bool match (const VPValue *V) const {
143
143
auto *DefR = V->getDefiningRecipe ();
144
144
return DefR && match (DefR);
145
145
}
146
146
147
- bool match (const VPRecipeBase *R) {
147
+ bool match (const VPRecipeBase *R) const {
148
148
if (!detail::MatchRecipeAndOpcode<Opcode, RecipeTys...>::match (R))
149
149
return false ;
150
150
assert (R->getNumOperands () == 1 &&
@@ -170,16 +170,16 @@ struct BinaryRecipe_match {
170
170
171
171
BinaryRecipe_match (Op0_t Op0, Op1_t Op1) : Op0(Op0), Op1(Op1) {}
172
172
173
- bool match (const VPValue *V) {
173
+ bool match (const VPValue *V) const {
174
174
auto *DefR = V->getDefiningRecipe ();
175
175
return DefR && match (DefR);
176
176
}
177
177
178
- bool match (const VPSingleDefRecipe *R) {
178
+ bool match (const VPSingleDefRecipe *R) const {
179
179
return match (static_cast <const VPRecipeBase *>(R));
180
180
}
181
181
182
- bool match (const VPRecipeBase *R) {
182
+ bool match (const VPRecipeBase *R) const {
183
183
if (!detail::MatchRecipeAndOpcode<Opcode, RecipeTys...>::match (R))
184
184
return false ;
185
185
assert (R->getNumOperands () == 2 &&
@@ -310,12 +310,14 @@ m_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
310
310
}
311
311
312
312
struct VPCanonicalIVPHI_match {
313
- bool match (const VPValue *V) {
313
+ bool match (const VPValue *V) const {
314
314
auto *DefR = V->getDefiningRecipe ();
315
315
return DefR && match (DefR);
316
316
}
317
317
318
- bool match (const VPRecipeBase *R) { return isa<VPCanonicalIVPHIRecipe>(R); }
318
+ bool match (const VPRecipeBase *R) const {
319
+ return isa<VPCanonicalIVPHIRecipe>(R);
320
+ }
319
321
};
320
322
321
323
inline VPCanonicalIVPHI_match m_CanonicalIV () {
@@ -328,12 +330,12 @@ template <typename Op0_t, typename Op1_t> struct VPScalarIVSteps_match {
328
330
329
331
VPScalarIVSteps_match (Op0_t Op0, Op1_t Op1) : Op0(Op0), Op1(Op1) {}
330
332
331
- bool match (const VPValue *V) {
333
+ bool match (const VPValue *V) const {
332
334
auto *DefR = V->getDefiningRecipe ();
333
335
return DefR && match (DefR);
334
336
}
335
337
336
- bool match (const VPRecipeBase *R) {
338
+ bool match (const VPRecipeBase *R) const {
337
339
if (!isa<VPScalarIVStepsRecipe>(R))
338
340
return false ;
339
341
assert (R->getNumOperands () == 2 &&
0 commit comments