13#ifndef LLVM_ANALYSIS_SCALAREVOLUTIONPATTERNMATCH_H
14#define LLVM_ANALYSIS_SCALAREVOLUTIONPATTERNMATCH_H
25template <
typename Predicate>
struct cst_pred_ty :
public Predicate {
30 "no vector types expected from SCEVs");
32 return C && this->isValue(
C->getAPInt());
76 template <
typename ITy>
bool match(ITy *V)
const {
108 template <
typename ITy>
bool match(ITy *S)
const {
return S ==
Expr; }
142 "no vector types expected from SCEVs");
162 return E &&
E->getNumOperands() == 1 &&
Op0.match(
E->getOperand(0));
166template <
typename SCEVTy,
typename Op0_t>
171template <
typename Op0_t>
172inline SCEVUnaryExpr_match<SCEVSignExtendExpr, Op0_t>
177template <
typename Op0_t>
178inline SCEVUnaryExpr_match<SCEVZeroExtendExpr, Op0_t>
183template <
typename Op0_t>
184inline SCEVUnaryExpr_match<SCEVPtrToIntExpr, Op0_t>
189template <
typename Op0_t>
190inline SCEVUnaryExpr_match<SCEVTruncateExpr, Op0_t>
196template <
typename SCEVTy,
typename Op0_t,
typename Op1_t,
198 bool Commutable =
false>
207 if (WrappingS->getNoWrapFlags(WrapFlags) != WrapFlags)
211 return E &&
E->getNumOperands() == 2 &&
212 ((
Op0.match(
E->getOperand(0)) &&
Op1.match(
E->getOperand(1))) ||
213 (Commutable &&
Op0.match(
E->getOperand(1)) &&
214 Op1.match(
E->getOperand(0))));
218template <
typename SCEVTy,
typename Op0_t,
typename Op1_t,
220 bool Commutable =
false>
221inline SCEVBinaryExpr_match<SCEVTy, Op0_t, Op1_t, WrapFlags, Commutable>
227template <
typename Op0_t,
typename Op1_t>
228inline SCEVBinaryExpr_match<SCEVAddExpr, Op0_t, Op1_t>
233template <
typename Op0_t,
typename Op1_t>
234inline SCEVBinaryExpr_match<SCEVMulExpr, Op0_t, Op1_t>
239template <
typename Op0_t,
typename Op1_t>
240inline SCEVBinaryExpr_match<SCEVMulExpr, Op0_t, Op1_t, SCEV::FlagAnyWrap, true>
246template <
typename Op0_t,
typename Op1_t>
247inline SCEVBinaryExpr_match<SCEVMulExpr, Op0_t, Op1_t, SCEV::FlagNUW, true>
253template <
typename Op0_t,
typename Op1_t>
254inline SCEVBinaryExpr_match<SCEVUDivExpr, Op0_t, Op1_t>
281 if (
SE.getTypeSizeInBits(
LHS->getType()) >
288 <<
SE.getTypeSizeInBits(TruncTy));
297 const auto MatchURemWithDivisor = [&](
const SCEV *
B) {
299 if (Expr ==
SE.getURemExpr(
A,
B))
300 return Op0.match(
A) &&
Op1.match(
B);
306 return MatchURemWithDivisor(
Mul->getOperand(1)) ||
307 MatchURemWithDivisor(
Mul->getOperand(2));
310 if (
Mul->getNumOperands() == 2)
311 return MatchURemWithDivisor(
Mul->getOperand(1)) ||
312 MatchURemWithDivisor(
Mul->getOperand(0)) ||
313 MatchURemWithDivisor(
SE.getNegativeSCEV(
Mul->getOperand(1))) ||
314 MatchURemWithDivisor(
SE.getNegativeSCEV(
Mul->getOperand(0)));
323template <
typename Op0_t,
typename Op1_t>
332template <
typename Op0_t,
typename Op1_t,
typename Loop_t>
358template <
typename Op0_t,
typename Op1_t>
359inline SCEVAffineAddRec_match<Op0_t, Op1_t, class_match<const Loop>>
365template <
typename Op0_t,
typename Op1_t,
typename Loop_t>
366inline SCEVAffineAddRec_match<Op0_t, Op1_t, Loop_t>
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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.
LLVM_ABI Type * getType() const
Return the LLVM type of this SCEV expression.
NoWrapFlags
NoWrapFlags are bitfield indices into SubclassData.
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.
@ C
The default llvm calling convention, compatible with C.
cstval_pred_ty< Predicate, ConstantInt, AllowPoison > cst_pred_ty
specialization of cstval_pred_ty for ConstantInt
class_match< const SCEVVScale > m_SCEVVScale()
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)
class_match< const SCEVConstant > m_SCEVConstant()
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)
SCEVAffineAddRec_match< Op0_t, Op1_t, class_match< const Loop > > m_scev_AffineAddRec(const Op0_t &Op0, const Op1_t &Op1)
bind_ty< const SCEVMulExpr > m_scev_Mul(const SCEVMulExpr *&V)
SCEVUnaryExpr_match< SCEVTy, Op0_t > m_scev_Unary(const Op0_t &Op0)
SCEVUnaryExpr_match< SCEVSignExtendExpr, Op0_t > m_scev_SExt(const Op0_t &Op0)
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.
SCEVBinaryExpr_match< SCEVMulExpr, Op0_t, Op1_t, SCEV::FlagNUW, true > m_scev_c_NUWMul(const Op0_t &Op0, const Op1_t &Op1)
class_match< const Loop > m_Loop()
bind_ty< const SCEVAddExpr > m_scev_Add(const SCEVAddExpr *&V)
SCEVUnaryExpr_match< SCEVPtrToIntExpr, Op0_t > m_scev_PtrToInt(const Op0_t &Op0)
bind_ty< const SCEVUnknown > m_SCEVUnknown(const SCEVUnknown *&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)
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.
class_match< const SCEV > m_SCEV()
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
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.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
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 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)