From e8b16185c3566b8387edd5766d12796bb84d83c6 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Wed, 11 Sep 2024 12:18:59 +0100 Subject: [PATCH] VPlan/PatternMatch: mark match functions const (NFC) --- .../Transforms/Vectorize/VPlanPatternMatch.h | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h b/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h index 4ddbd0d5fafb8..ed0bb13d9425f 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h +++ b/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h @@ -26,7 +26,7 @@ namespace llvm { namespace VPlanPatternMatch { template bool match(Val *V, const Pattern &P) { - return const_cast(P).match(V); + return P.match(V); } template bool match(VPUser *U, const Pattern &P) { @@ -35,7 +35,7 @@ template bool match(VPUser *U, const Pattern &P) { } template struct class_match { - template bool match(ITy *V) { return isa(V); } + template bool match(ITy *V) const { return isa(V); } }; /// Match an arbitrary VPValue and ignore it. @@ -46,7 +46,7 @@ template struct bind_ty { bind_ty(Class *&V) : VR(V) {} - template bool match(ITy *V) { + template bool match(ITy *V) const { if (auto *CV = dyn_cast(V)) { VR = CV; return true; @@ -63,7 +63,7 @@ template struct specific_intval { specific_intval(APInt V) : Val(std::move(V)) {} - bool match(VPValue *VPV) { + bool match(VPValue *VPV) const { if (!VPV->isLiveIn()) return false; Value *V = VPV->getLiveInIRValue(); @@ -94,7 +94,7 @@ template struct match_combine_or { match_combine_or(const LTy &Left, const RTy &Right) : L(Left), R(Right) {} - template bool match(ITy *V) { + template bool match(ITy *V) const { if (L.match(V)) return true; if (R.match(V)) @@ -139,16 +139,16 @@ struct UnaryRecipe_match { UnaryRecipe_match(Op0_t Op0) : Op0(Op0) {} - bool match(const VPValue *V) { + bool match(const VPValue *V) const { auto *DefR = V->getDefiningRecipe(); return DefR && match(DefR); } - bool match(const VPSingleDefRecipe *R) { + bool match(const VPSingleDefRecipe *R) const { return match(static_cast(R)); } - bool match(const VPRecipeBase *R) { + bool match(const VPRecipeBase *R) const { if (!detail::MatchRecipeAndOpcode::match(R)) return false; assert(R->getNumOperands() == 1 && @@ -174,16 +174,16 @@ struct BinaryRecipe_match { BinaryRecipe_match(Op0_t Op0, Op1_t Op1) : Op0(Op0), Op1(Op1) {} - bool match(const VPValue *V) { + bool match(const VPValue *V) const { auto *DefR = V->getDefiningRecipe(); return DefR && match(DefR); } - bool match(const VPSingleDefRecipe *R) { + bool match(const VPSingleDefRecipe *R) const { return match(static_cast(R)); } - bool match(const VPRecipeBase *R) { + bool match(const VPRecipeBase *R) const { if (!detail::MatchRecipeAndOpcode::match(R)) return false; assert(R->getNumOperands() == 2 && @@ -314,12 +314,14 @@ m_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) { } struct VPCanonicalIVPHI_match { - bool match(const VPValue *V) { + bool match(const VPValue *V) const { auto *DefR = V->getDefiningRecipe(); return DefR && match(DefR); } - bool match(const VPRecipeBase *R) { return isa(R); } + bool match(const VPRecipeBase *R) const { + return isa(R); + } }; inline VPCanonicalIVPHI_match m_CanonicalIV() { @@ -332,12 +334,12 @@ template struct VPScalarIVSteps_match { VPScalarIVSteps_match(Op0_t Op0, Op1_t Op1) : Op0(Op0), Op1(Op1) {} - bool match(const VPValue *V) { + bool match(const VPValue *V) const { auto *DefR = V->getDefiningRecipe(); return DefR && match(DefR); } - bool match(const VPRecipeBase *R) { + bool match(const VPRecipeBase *R) const { if (!isa(R)) return false; assert(R->getNumOperands() == 2 &&