14 #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONEXPRESSIONS_H
15 #define LLVM_ANALYSIS_SCALAREVOLUTIONEXPRESSIONS_H
207 const SCEV *
const *O,
size_t N)
231 const SCEV *
const *O,
size_t N)
286 const SCEV *
const *O,
size_t N,
const Loop *l)
358 const SCEV *
const *O,
size_t N)
377 const SCEV *
const *O,
size_t N)
397 void deleted()
override;
398 void allUsesReplacedWith(
Value *New)
override;
438 template<
typename SC,
typename RetVal=
void>
483 template<
typename SV>
489 void push(
const SCEV *S) {
490 if (Visited.insert(S).second && Visitor.follow(S))
491 Worklist.push_back(S);
498 while (!Worklist.empty() && !Visitor.isDone()) {
499 const SCEV *S = Worklist.pop_back_val();
508 push(cast<SCEVCastExpr>(S)->getOperand());
515 for (
const auto *
Op : cast<SCEVNAryExpr>(S)->operands())
534 template<
typename SV>
541 template <
typename PredTy>
547 FindClosure(PredTy Pred) : Pred(Pred) {}
549 bool follow(
const SCEV *S) {
557 bool isDone()
const {
return Found; }
560 FindClosure
FC(Pred);
568 template<
typename SC>
588 assert(Result.second &&
"Should insert a new entry");
589 return Result.first->second;
669 bool InterpretConsts =
false) {
671 return Rewriter.
visit(Scev);
681 if (InterpretConsts && isa<ConstantInt>(NV))
690 bool InterpretConsts;
703 return Rewriter.
visit(Scev);
717 if (0 == Map.
count(L))
NoWrapFlags getNoWrapFlags(NoWrapFlags Mask=NoWrapMask) const
const SCEV * evaluateAtIteration(const SCEV *It, ScalarEvolution &SE) const
Return the value of this chain of recurrences at the specified iteration number.
void push_back(const T &Elt)
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
SCEVCastExpr(const FoldingSetNodeIDRef ID, unsigned SCEVTy, const SCEV *op, Type *ty)
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
DiagnosticInfoOptimizationBase::Argument NV
const SCEV * getConstant(ConstantInt *V)
const SCEV * visitSMaxExpr(const SCEVSMaxExpr *Expr)
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
The main scalar evolution driver.
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
static LLVM_NODISCARD SCEV::NoWrapFlags setFlags(SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OnFlags)
The SCEVParameterRewriter takes a scalar evolution expression and updates the SCEVUnknown components ...
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
const SCEV * getStepRecurrence(ScalarEvolution &SE) const
Constructs and returns the recurrence indicating how much this expression steps by.
DenseMap< const Loop *, const SCEV * > LoopToScevMapT
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
This class represents a truncation of an integer value to a smaller integer value.
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
const SCEV *const * Operands
const SCEV * visitCouldNotCompute(const SCEVCouldNotCompute *Expr)
An object of this class is returned by queries that could not be answered.
RetVal visit(const SCEV *S)
bool hasNoSelfWrap() const
const SCEV * visit(const SCEV *S)
This is the base class for unary cast operator classes.
DenseMap< const Value *, Value * > ValueToValueMap
bool isOffsetOf(Type *&STy, Constant *&FieldNo) const
iterator_range< op_iterator > op_range
const SCEV * getStart() const
const SCEV * visitTruncateExpr(const SCEVTruncateExpr *Expr)
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
The SCEVLoopAddRecRewriter takes a scalar evolution expression and applies the Map (Loop -> SCEV) to ...
bool isAlignOf(Type *&AllocTy) const
const SCEV * visitConstant(const SCEVConstant *Constant)
struct fuzzer::@269 Flags
SCEVParameterRewriter(ScalarEvolution &SE, ValueToValueMap &M, bool C)
const APInt & getValue() const
Return the constant as an APInt value reference.
bool hasNoSignedWrap() const
const SCEV *const * op_iterator
unsigned short SubclassData
This field is initialized to zero and may be used in subclasses to store miscellaneous information...
This node is the base class for n'ary commutative operators.
op_iterator op_begin() const
This node represents multiplication of some number of SCEVs.
void setNoWrapFlags(NoWrapFlags Flags)
Set flags for a non-recurrence without clearing previously set flags.
const SCEV * visitUnknown(const SCEVUnknown *Expr)
This node represents a polynomial recurrence on the trip count of the specified loop.
const SCEV * visitAddRecExpr(const SCEVAddRecExpr *Expr)
const SCEV * visitUDivExpr(const SCEVUDivExpr *Expr)
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
const SCEV * getAddRecExpr(const SCEV *Start, const SCEV *Step, const Loop *L, SCEV::NoWrapFlags Flags)
Get an add recurrence expression for the specified loop.
size_t getNumOperands() const
Visit all nodes in the expression tree using worklist traversal.
This means that we are dealing with an entirely unknown SCEV value, and only represent it as its LLVM...
bool isAffine() const
Return true if this represents an expression A + B*x where A and B are loop invariant values...
This class defines a simple visitor class that may be used for various SCEV analysis purposes...
const SCEV * visitUMaxExpr(const SCEVUMaxExpr *Expr)
bool isSizeOf(Type *&AllocTy) const
Value * getValPtr() const
This class represents a binary unsigned division operation.
The instances of the Type class are immutable: once they are created, they are never changed...
Type * getType() const
Return the LLVM type of this SCEV expression.
This is an important base class in LLVM.
const SCEV * getOperand(unsigned i) const
void visitAll(const SCEV *Root)
const SCEV * getSMaxExpr(const SCEV *LHS, const SCEV *RHS)
SCEVRewriteVisitor(ScalarEvolution &SE)
bool SCEVExprContains(const SCEV *Root, PredTy Pred)
Return true if any node in Root satisfies the predicate Pred.
op_range operands() const
const SCEVAddRecExpr * getPostIncExpr(ScalarEvolution &SE) const
Return an expression representing the value of this expression one iteration of the loop ahead...
void setNoWrapFlags(NoWrapFlags Flags)
Set flags for a recurrence without clearing any previously set flags.
const SCEV * getLHS() const
const APInt & getAPInt() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const SCEV * getRHS() const
RetVal visitCouldNotCompute(const SCEVCouldNotCompute *S)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is the shared class of boolean and integer constants.
const SCEV * visitAddExpr(const SCEVAddExpr *Expr)
const SCEV * getTruncateExpr(const SCEV *Op, Type *Ty)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Type * getType() const
All values are typed, get the type of this value.
This class represents a range of values.
CHAIN = SC CHAIN, Imm128 - System call.
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
const SCEV * visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr)
ConstantInt * getValue() const
const SCEV * getUMaxExpr(const SCEV *LHS, const SCEV *RHS)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
size_type count(const KeyT &Val) const
Return 1 if the specified key is in the map, 0 otherwise.
A range adaptor for a pair of iterators.
Class for arbitrary precision integers.
This node represents an addition of some number of SCEVs.
const SCEV * getSignExtendExpr(const SCEV *Op, Type *Ty)
This class represents a signed maximum selection.
const SCEV * getAddExpr(SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
Get a canonical add expression, or something simpler if possible.
void visitAll(const SCEV *Root, SV &Visitor)
Use SCEVTraversal to visit all nodes in the given expression tree.
const SCEV * visitMulExpr(const SCEVMulExpr *Expr)
This class represents a zero extension of a small integer value to a larger integer value...
Virtual Register Rewriter
FoldingSetNodeIDRef - This class describes a reference to an interned FoldingSetNodeID, which can be a useful to store node id data rather than using plain FoldingSetNodeIDs, since the 32-element SmallVector is often much larger than necessary, and the possibility of heap allocation means it requires a non-trivial destructor call.
const SCEV * visitUnknown(const SCEVUnknown *Expr)
This class represents an analyzed expression in the program.
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
const SCEV * visitAddRecExpr(const SCEVAddRecExpr *Expr)
Represents a single loop in the control flow graph.
This class represents a sign extension of a small integer value to a larger integer value...
This class represents an unsigned maximum selection.
const Loop * getLoop() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getSCEVType() const
const SCEV * visitSignExtendExpr(const SCEVSignExtendExpr *Expr)
SCEVNAryExpr(const FoldingSetNodeIDRef ID, enum SCEVTypes T, const SCEV *const *O, size_t N)
const SCEV * getNumIterationsInRange(const ConstantRange &Range, ScalarEvolution &SE) const
Return the number of iterations of this loop that produce values in the specified constant range...
LLVM Value Representation.
SCEVLoopAddRecRewriter(ScalarEvolution &SE, LoopToScevMapT &M)
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
DenseMap< const SCEV *, const SCEV * > RewriteResults
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
const SCEV * getUDivExpr(const SCEV *LHS, const SCEV *RHS)
Get a canonical unsigned division expression, or something simpler if possible.
const SCEV * getUnknown(Value *V)
static const SCEV * rewrite(const SCEV *Scev, ScalarEvolution &SE, ValueToValueMap &Map, bool InterpretConsts=false)
SCEVCommutativeExpr(const FoldingSetNodeIDRef ID, enum SCEVTypes T, const SCEV *const *O, size_t N)
op_iterator op_end() const
Value handle with callbacks on RAUW and destruction.
const SCEV * getZeroExtendExpr(const SCEV *Op, Type *Ty)
This node is a base class providing common functionality for n'ary operators.
NoWrapFlags
NoWrapFlags are bitfield indices into SubclassData.
const SCEV * getOperand() const
const SCEV * getMulExpr(SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
Get a canonical multiply expression, or something simpler if possible.
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
static const SCEV * rewrite(const SCEV *Scev, LoopToScevMapT &Map, ScalarEvolution &SE)
bool hasNoUnsignedWrap() const
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
This visitor recursively visits a SCEV expression and re-writes it.
bool isQuadratic() const
Return true if this represents an expression A + B*x + C*x^2 where A, B and C are loop invariant valu...
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
This class represents a constant integer value.