@@ -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,16 +139,16 @@ 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 VPSingleDefRecipe *R) {
147
+ bool match (const VPSingleDefRecipe *R) const {
148
148
return match (static_cast <const VPRecipeBase *>(R));
149
149
}
150
150
151
- bool match (const VPRecipeBase *R) {
151
+ bool match (const VPRecipeBase *R) const {
152
152
if (!detail::MatchRecipeAndOpcode<Opcode, RecipeTys...>::match (R))
153
153
return false ;
154
154
assert (R->getNumOperands () == 1 &&
@@ -174,16 +174,16 @@ struct BinaryRecipe_match {
174
174
175
175
BinaryRecipe_match (Op0_t Op0, Op1_t Op1) : Op0(Op0), Op1(Op1) {}
176
176
177
- bool match (const VPValue *V) {
177
+ bool match (const VPValue *V) const {
178
178
auto *DefR = V->getDefiningRecipe ();
179
179
return DefR && match (DefR);
180
180
}
181
181
182
- bool match (const VPSingleDefRecipe *R) {
182
+ bool match (const VPSingleDefRecipe *R) const {
183
183
return match (static_cast <const VPRecipeBase *>(R));
184
184
}
185
185
186
- bool match (const VPRecipeBase *R) {
186
+ bool match (const VPRecipeBase *R) const {
187
187
if (!detail::MatchRecipeAndOpcode<Opcode, RecipeTys...>::match (R))
188
188
return false ;
189
189
assert (R->getNumOperands () == 2 &&
@@ -314,12 +314,14 @@ m_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
314
314
}
315
315
316
316
struct VPCanonicalIVPHI_match {
317
- bool match (const VPValue *V) {
317
+ bool match (const VPValue *V) const {
318
318
auto *DefR = V->getDefiningRecipe ();
319
319
return DefR && match (DefR);
320
320
}
321
321
322
- bool match (const VPRecipeBase *R) { return isa<VPCanonicalIVPHIRecipe>(R); }
322
+ bool match (const VPRecipeBase *R) const {
323
+ return isa<VPCanonicalIVPHIRecipe>(R);
324
+ }
323
325
};
324
326
325
327
inline VPCanonicalIVPHI_match m_CanonicalIV () {
@@ -332,12 +334,12 @@ template <typename Op0_t, typename Op1_t> struct VPScalarIVSteps_match {
332
334
333
335
VPScalarIVSteps_match (Op0_t Op0, Op1_t Op1) : Op0(Op0), Op1(Op1) {}
334
336
335
- bool match (const VPValue *V) {
337
+ bool match (const VPValue *V) const {
336
338
auto *DefR = V->getDefiningRecipe ();
337
339
return DefR && match (DefR);
338
340
}
339
341
340
- bool match (const VPRecipeBase *R) {
342
+ bool match (const VPRecipeBase *R) const {
341
343
if (!isa<VPScalarIVStepsRecipe>(R))
342
344
return false ;
343
345
assert (R->getNumOperands () == 2 &&
0 commit comments