Skip to content

VPlan/PatternMatch: mark match functions const (NFC) #108191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace llvm {
namespace VPlanPatternMatch {

template <typename Val, typename Pattern> bool match(Val *V, const Pattern &P) {
return const_cast<Pattern &>(P).match(V);
return P.match(V);
}

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

template <typename Class> struct class_match {
template <typename ITy> bool match(ITy *V) { return isa<Class>(V); }
template <typename ITy> bool match(ITy *V) const { return isa<Class>(V); }
};

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

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

template <typename ITy> bool match(ITy *V) {
template <typename ITy> bool match(ITy *V) const {
if (auto *CV = dyn_cast<Class>(V)) {
VR = CV;
return true;
Expand All @@ -63,7 +63,7 @@ template <unsigned BitWidth = 0> 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();
Expand Down Expand Up @@ -94,7 +94,7 @@ template <typename LTy, typename RTy> struct match_combine_or {

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

template <typename ITy> bool match(ITy *V) {
template <typename ITy> bool match(ITy *V) const {
if (L.match(V))
return true;
if (R.match(V))
Expand Down Expand Up @@ -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<const VPRecipeBase *>(R));
}

bool match(const VPRecipeBase *R) {
bool match(const VPRecipeBase *R) const {
if (!detail::MatchRecipeAndOpcode<Opcode, RecipeTys...>::match(R))
return false;
assert(R->getNumOperands() == 1 &&
Expand All @@ -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<const VPRecipeBase *>(R));
}

bool match(const VPRecipeBase *R) {
bool match(const VPRecipeBase *R) const {
if (!detail::MatchRecipeAndOpcode<Opcode, RecipeTys...>::match(R))
return false;
assert(R->getNumOperands() == 2 &&
Expand Down Expand Up @@ -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<VPCanonicalIVPHIRecipe>(R); }
bool match(const VPRecipeBase *R) const {
return isa<VPCanonicalIVPHIRecipe>(R);
}
};

inline VPCanonicalIVPHI_match m_CanonicalIV() {
Expand All @@ -332,12 +334,12 @@ template <typename Op0_t, typename Op1_t> 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<VPScalarIVStepsRecipe>(R))
return false;
assert(R->getNumOperands() == 2 &&
Expand Down
Loading