@@ -26,7 +26,7 @@ namespace llvm {
2626namespace VPlanPatternMatch {
2727
2828template <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
3232template <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
3737template <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,16 +139,16 @@ 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 VPSingleDefRecipe *R) {
147+ bool match (const VPSingleDefRecipe *R) const {
148148 return match (static_cast <const VPRecipeBase *>(R));
149149 }
150150
151- bool match (const VPRecipeBase *R) {
151+ bool match (const VPRecipeBase *R) const {
152152 if (!detail::MatchRecipeAndOpcode<Opcode, RecipeTys...>::match (R))
153153 return false ;
154154 assert (R->getNumOperands () == 1 &&
@@ -174,16 +174,16 @@ struct BinaryRecipe_match {
174174
175175 BinaryRecipe_match (Op0_t Op0, Op1_t Op1) : Op0(Op0), Op1(Op1) {}
176176
177- bool match (const VPValue *V) {
177+ bool match (const VPValue *V) const {
178178 auto *DefR = V->getDefiningRecipe ();
179179 return DefR && match (DefR);
180180 }
181181
182- bool match (const VPSingleDefRecipe *R) {
182+ bool match (const VPSingleDefRecipe *R) const {
183183 return match (static_cast <const VPRecipeBase *>(R));
184184 }
185185
186- bool match (const VPRecipeBase *R) {
186+ bool match (const VPRecipeBase *R) const {
187187 if (!detail::MatchRecipeAndOpcode<Opcode, RecipeTys...>::match (R))
188188 return false ;
189189 assert (R->getNumOperands () == 2 &&
@@ -314,12 +314,14 @@ m_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
314314}
315315
316316struct VPCanonicalIVPHI_match {
317- bool match (const VPValue *V) {
317+ bool match (const VPValue *V) const {
318318 auto *DefR = V->getDefiningRecipe ();
319319 return DefR && match (DefR);
320320 }
321321
322- bool match (const VPRecipeBase *R) { return isa<VPCanonicalIVPHIRecipe>(R); }
322+ bool match (const VPRecipeBase *R) const {
323+ return isa<VPCanonicalIVPHIRecipe>(R);
324+ }
323325};
324326
325327inline VPCanonicalIVPHI_match m_CanonicalIV () {
@@ -332,12 +334,12 @@ template <typename Op0_t, typename Op1_t> struct VPScalarIVSteps_match {
332334
333335 VPScalarIVSteps_match (Op0_t Op0, Op1_t Op1) : Op0(Op0), Op1(Op1) {}
334336
335- bool match (const VPValue *V) {
337+ bool match (const VPValue *V) const {
336338 auto *DefR = V->getDefiningRecipe ();
337339 return DefR && match (DefR);
338340 }
339341
340- bool match (const VPRecipeBase *R) {
342+ bool match (const VPRecipeBase *R) const {
341343 if (!isa<VPScalarIVStepsRecipe>(R))
342344 return false ;
343345 assert (R->getNumOperands () == 2 &&
0 commit comments