13#ifndef LLVM_ANALYSIS_SCALAREVOLUTIONPATTERNMATCH_H
14#define LLVM_ANALYSIS_SCALAREVOLUTIONPATTERNMATCH_H
27 template <
typename ITy>
bool match(ITy *V)
const {
42template <
typename SCEVPtrT,
typename Pattern>
44 return P.match(U.getPointer());
47template <
typename Predicate>
struct cst_pred_ty :
public Predicate {
52 "no vector types expected from SCEVs");
54 return C && this->isValue(
C->getAPInt());
88template <
typename SCEVPtrT>
113 template <
typename ITy>
bool match(ITy *S)
const {
return S ==
Expr; }
147 "no vector types expected from SCEVs");
167 return E &&
E->getNumOperands() == 1 &&
168 Op0.match(
E->getOperand(0).getPointer());
172template <
typename SCEVTy,
typename Op0_t>
177template <
typename Op0_t>
178inline SCEVUnaryExpr_match<SCEVSignExtendExpr, Op0_t>
183template <
typename Op0_t>
184inline SCEVUnaryExpr_match<SCEVZeroExtendExpr, Op0_t>
189template <
typename Op0_t>
190inline SCEVUnaryExpr_match<SCEVPtrToAddrExpr, Op0_t>
195template <
typename Op0_t>
196inline SCEVUnaryExpr_match<SCEVTruncateExpr, Op0_t>
202template <
typename SCEVTy,
typename Op0_t,
typename Op1_t,
204 bool Commutable =
false>
213 if (WrappingS->getNoWrapFlags(WrapFlags) != WrapFlags)
217 return E &&
E->getNumOperands() == 2 &&
218 ((
Op0.match(
E->getOperand(0).getPointer()) &&
219 Op1.match(
E->getOperand(1).getPointer())) ||
220 (Commutable &&
Op0.match(
E->getOperand(1).getPointer()) &&
221 Op1.match(
E->getOperand(0).getPointer())));
225template <
typename SCEVTy,
typename Op0_t,
typename Op1_t,
227 bool Commutable =
false>
228inline SCEVBinaryExpr_match<SCEVTy, Op0_t, Op1_t, WrapFlags, Commutable>
234template <
typename Op0_t,
typename Op1_t>
235inline SCEVBinaryExpr_match<SCEVAddExpr, Op0_t, Op1_t>
240template <
typename Op0_t,
typename Op1_t>
241inline SCEVBinaryExpr_match<SCEVMulExpr, Op0_t, Op1_t>
246template <
typename Op0_t,
typename Op1_t>
247inline SCEVBinaryExpr_match<SCEVMulExpr, Op0_t, Op1_t, SCEV::FlagAnyWrap, true>
253template <
typename Op0_t,
typename Op1_t>
254inline SCEVBinaryExpr_match<SCEVMulExpr, Op0_t, Op1_t, SCEV::FlagNUW, true>
260template <
typename Op0_t,
typename Op1_t>
261inline SCEVBinaryExpr_match<SCEVUDivExpr, Op0_t, Op1_t>
266template <
typename Op0_t,
typename Op1_t>
267inline SCEVBinaryExpr_match<SCEVSMaxExpr, Op0_t, Op1_t>
272template <
typename Op0_t,
typename Op1_t>
273inline SCEVBinaryExpr_match<SCEVMinMaxExpr, Op0_t, Op1_t>
300 if (
SE.getTypeSizeInBits(
LHS->getType()) >
307 <<
SE.getTypeSizeInBits(TruncTy));
320 [](
const SCEV *
Op) { return isa<SCEVUDivExpr>(Op); }))
323 const auto MatchURemWithDivisor = [&](
const SCEV *
B) {
325 if (Expr ==
SE.getURemExpr(
A,
B))
326 return Op0.match(
A) &&
Op1.match(
B);
332 return MatchURemWithDivisor(
Mul->getOperand(1)) ||
333 MatchURemWithDivisor(
Mul->getOperand(2));
336 if (
Mul->getNumOperands() == 2)
337 return MatchURemWithDivisor(
Mul->getOperand(1)) ||
338 MatchURemWithDivisor(
Mul->getOperand(0)) ||
339 MatchURemWithDivisor(
SE.getNegativeSCEV(
Mul->getOperand(1))) ||
340 MatchURemWithDivisor(
SE.getNegativeSCEV(
Mul->getOperand(0)));
349template <
typename Op0_t,
typename Op1_t>
358template <
typename Op0_t,
typename Op1_t,
typename Loop_t>
384template <
typename Op0_t,
typename Op1_t>
385inline SCEVAffineAddRec_match<Op0_t, Op1_t, match_isa<const Loop>>
391template <
typename Op0_t,
typename Op1_t,
typename Loop_t>
392inline SCEVAffineAddRec_match<Op0_t, Op1_t, Loop_t>
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Class for arbitrary precision integers.
Represents a single loop in the control flow graph.
This node represents an addition of some number of SCEVs.
This class represents a constant integer value.
This node represents multiplication of some number of SCEVs.
This means that we are dealing with an entirely unknown SCEV value, and only represent it as its LLVM...
This class represents an analyzed expression in the program.
SCEVNoWrapFlags NoWrapFlags
static constexpr auto FlagAnyWrap
Type * getType() const
Return the LLVM type of this SCEV expression.
The main scalar evolution driver.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isVectorTy() const
True if this is an instance of VectorType.
bool isPointerTy() const
True if this is an instance of PointerType.
match_isa< To... > m_Isa()
cstval_pred_ty< Predicate, ConstantInt, AllowPoison > cst_pred_ty
specialization of cstval_pred_ty for ConstantInt
bind_cst_ty m_scev_APInt(const APInt *&C)
Match an SCEV constant and bind it to an APInt.
cst_pred_ty< is_all_ones > m_scev_AllOnes()
Match an integer with all bits set.
SCEVUnaryExpr_match< SCEVZeroExtendExpr, Op0_t > m_scev_ZExt(const Op0_t &Op0)
is_undef_or_poison m_scev_UndefOrPoison()
Match an SCEVUnknown wrapping undef or poison.
SCEVBinaryExpr_match< SCEVMinMaxExpr, Op0_t, Op1_t > m_scev_MinMax(const Op0_t &Op0, const Op1_t &Op1)
cst_pred_ty< is_one > m_scev_One()
Match an integer 1.
specificloop_ty m_SpecificLoop(const Loop *L)
cst_pred_ty< is_specific_signed_cst > m_scev_SpecificSInt(int64_t V)
Match an SCEV constant with a plain signed integer (sign-extended value will be matched)
SCEVBinaryExpr_match< SCEVTy, Op0_t, Op1_t, WrapFlags, Commutable > m_scev_Binary(const Op0_t &Op0, const Op1_t &Op1)
SCEVUnaryExpr_match< SCEVTy, Op0_t > m_scev_Unary(const Op0_t &Op0)
SCEVUnaryExpr_match< SCEVSignExtendExpr, Op0_t > m_scev_SExt(const Op0_t &Op0)
SCEVUnaryExpr_match< SCEVPtrToAddrExpr, Op0_t > m_scev_PtrToAddr(const Op0_t &Op0)
match_bind< const SCEVMulExpr > m_scev_Mul(const SCEVMulExpr *&V)
cst_pred_ty< is_zero > m_scev_Zero()
Match an integer 0.
SCEVUnaryExpr_match< SCEVTruncateExpr, Op0_t > m_scev_Trunc(const Op0_t &Op0)
bool match(const SCEV *S, const Pattern &P)
SCEVBinaryExpr_match< SCEVUDivExpr, Op0_t, Op1_t > m_scev_UDiv(const Op0_t &Op0, const Op1_t &Op1)
specificscev_ty m_scev_Specific(const SCEV *S)
Match if we have a specific specified SCEV.
SCEVAffineAddRec_match< Op0_t, Op1_t, match_isa< const Loop > > m_scev_AffineAddRec(const Op0_t &Op0, const Op1_t &Op1)
match_bind< const SCEVUnknown > m_SCEVUnknown(const SCEVUnknown *&V)
SCEVBinaryExpr_match< SCEVMulExpr, Op0_t, Op1_t, SCEV::FlagNUW, true > m_scev_c_NUWMul(const Op0_t &Op0, const Op1_t &Op1)
match_bind< const SCEVAddExpr > m_scev_Add(const SCEVAddExpr *&V)
cst_pred_ty< is_specific_cst > m_scev_SpecificInt(uint64_t V)
Match an SCEV constant with a plain unsigned integer.
SCEVBinaryExpr_match< SCEVMulExpr, Op0_t, Op1_t, SCEV::FlagAnyWrap, true > m_scev_c_Mul(const Op0_t &Op0, const Op1_t &Op1)
SCEVBinaryExpr_match< SCEVSMaxExpr, Op0_t, Op1_t > m_scev_SMax(const Op0_t &Op0, const Op1_t &Op1)
SCEVURem_match< Op0_t, Op1_t > m_scev_URem(Op0_t LHS, Op1_t RHS, ScalarEvolution &SE)
Match the mathematical pattern A - (A / B) * B, where A and B can be arbitrary expressions.
This is an optimization pass for GlobalISel generic memory operations.
@ Unknown
Not known to have no common set bits.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Mul
Product of integers.
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
match_bind(SCEVUseT< SCEVPtrT > &V)
SCEVUseT< SCEVPtrT > & VR
Matcher to bind the captured value.
Match an affine SCEVAddRecExpr.
SCEVBinaryExpr_match< SCEVAddRecExpr, Op0_t, Op1_t > Ops
bool match(const SCEV *S) const
SCEVAffineAddRec_match(Op0_t Op0, Op1_t Op1, Loop_t Loop)
SCEVBinaryExpr_match(Op0_t Op0, Op1_t Op1)
bool match(const SCEV *S) const
Match unsigned remainder pattern.
SCEVURem_match(Op0_t Op0, Op1_t Op1, ScalarEvolution &SE)
bool match(const SCEV *Expr) const
bool match(const SCEV *S) const
SCEVUnaryExpr_match(Op0_t Op0)
bind_cst_ty(const APInt *&Op0)
bool match(const SCEV *S) const
bool match(const SCEV *S) const
bool isValue(const APInt &C) const
bool isValue(const APInt &C) const
is_specific_cst(uint64_t C)
bool isValue(const APInt &C) const
bool isValue(const APInt &C) const
is_specific_signed_cst(int64_t C)
bool match(const SCEV *S) const
bool isValue(const APInt &C) const
Match a specified const Loop*.
bool match(const Loop *L) const
specificloop_ty(const Loop *L)
Match a specified const SCEV *.
specificscev_ty(const SCEV *Expr)