14 #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONEXPRESSIONS_H
15 #define LLVM_ANALYSIS_SCALAREVOLUTIONEXPRESSIONS_H
150 assert(i <
NumOperands &&
"Operand index out of range!");
211 const SCEV *
const *O,
size_t N)
236 const SCEV *
const *O,
size_t N)
294 const SCEV *
const *O,
size_t N,
const Loop *l)
368 const SCEV *
const *O,
size_t N)
389 const SCEV *
const *O,
size_t N)
411 void deleted()
override;
412 void allUsesReplacedWith(
Value *New)
override;
450 template<
typename SC,
typename RetVal=
void>
495 template<
typename SV>
501 void push(
const SCEV *S) {
502 if (Visited.insert(S).second && Visitor.follow(S))
503 Worklist.push_back(S);
510 while (!Worklist.empty() && !Visitor.isDone()) {
511 const SCEV *S = Worklist.pop_back_val();
520 push(cast<SCEVCastExpr>(S)->getOperand());
550 template<
typename SV>
561 :
public SCEVVisitor<SCEVParameterRewriter, const SCEV*> {
565 bool InterpretConsts =
false) {
567 return Rewriter.
visit(Scev);
571 : SE(S), Map(M), InterpretConsts(C) {}
636 if (InterpretConsts && isa<ConstantInt>(NV))
650 bool InterpretConsts;
658 :
public SCEVVisitor<SCEVApplyRewriter, const SCEV*> {
663 return Rewriter.
visit(Scev);
714 if (0 == Map.
count(L))
NoWrapFlags getNoWrapFlags(NoWrapFlags Mask=NoWrapMask) const
SCEVParameterRewriter(ScalarEvolution &S, ValueToValueMap &M, bool C)
const SCEV * visitMulExpr(const SCEVMulExpr *Expr)
const SCEV * evaluateAtIteration(const SCEV *It, ScalarEvolution &SE) const
evaluateAtIteration - 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...
const SCEV * visitAddRecExpr(const SCEVAddRecExpr *Expr)
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:
const SCEV * getConstant(ConstantInt *V)
const SCEV * visitSignExtendExpr(const SCEVSignExtendExpr *Expr)
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
ScalarEvolution - This class is the main scalar evolution driver.
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 * getStepRecurrence(ScalarEvolution &SE) const
getStepRecurrence - This method constructs and returns the recurrence indicating how much this expres...
DenseMap< const Loop *, const SCEV * > LoopToScevMapT
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
SCEVTruncateExpr - This class represents a truncation of an integer value to a smaller integer value...
const SCEV * visitUDivExpr(const SCEVUDivExpr *Expr)
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
const SCEV *const * Operands
const SCEV * visitUnknown(const SCEVUnknown *Expr)
SCEVCouldNotCompute - An object of this class is returned by queries that could not be answered...
RetVal visit(const SCEV *S)
const SCEV * visitConstant(const SCEVConstant *Constant)
SCEVCastExpr - 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
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:
static const SCEV * apply(const SCEV *Scev, LoopToScevMapT &Map, ScalarEvolution &SE)
Applies the Map (Loop -> SCEV) to the given Scev.
const SCEV * visitSMaxExpr(const SCEVSMaxExpr *Expr)
static const SCEV * rewrite(const SCEV *Scev, LoopToScevMapT &Map, ScalarEvolution &SE)
bool isAlignOf(Type *&AllocTy) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const SCEV *const * op_iterator
unsigned short SubclassData
SubclassData - This field is initialized to zero and may be used in subclasses to store miscellaneous...
SCEVCommutativeExpr - This node is the base class for n'ary commutative operators.
op_iterator op_begin() const
SCEVMulExpr - 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 * visitCouldNotCompute(const SCEVCouldNotCompute *Expr)
SCEVAddRecExpr - This node represents a polynomial recurrence on the trip count of the specified loop...
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)
getAddRecExpr - Get an add recurrence expression for the specified loop.
size_t getNumOperands() const
const SCEV * visitUDivExpr(const SCEVUDivExpr *Expr)
const SCEV * getNumIterationsInRange(ConstantRange Range, ScalarEvolution &SE) const
getNumIterationsInRange - Return the number of iterations of this loop that produce values in the spe...
Visit all nodes in the expression tree using worklist traversal.
SCEVUnknown - This means that we are dealing with an entirely unknown SCEV value, and only represent ...
bool isAffine() const
isAffine - Return true if this represents an expression A + B*x where A and B are loop invariant valu...
SCEVVisitor - This class defines a simple visitor class that may be used for various SCEV analysis pu...
bool isSizeOf(Type *&AllocTy) const
isSizeOf, isAlignOf, isOffsetOf - Test whether this is a special constant representing a type size...
Value * getValPtr() const
static const SCEV * rewrite(const SCEV *Scev, ScalarEvolution &SE, ValueToValueMap &Map, bool InterpretConsts=false)
SCEVUDivExpr - 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
getType - 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)
op_range operands() const
const SCEVAddRecExpr * getPostIncExpr(ScalarEvolution &SE) const
getPostIncExpr - Return an expression representing the value of this expression one iteration of the ...
void setNoWrapFlags(NoWrapFlags Flags)
Set flags for a recurrence without clearing any previously set flags.
const SCEV * visitAddExpr(const SCEVAddExpr *Expr)
static SCEV::NoWrapFlags LLVM_ATTRIBUTE_UNUSED_RESULT setFlags(SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OnFlags)
const SCEV * getLHS() const
const SCEV * visitMulExpr(const SCEVMulExpr *Expr)
const SCEV * getRHS() const
SCEVApplyRewriter(ScalarEvolution &S, LoopToScevMapT &M)
RetVal visitCouldNotCompute(const SCEVCouldNotCompute *S)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
const SCEV * visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr)
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 * getTruncateExpr(const SCEV *Op, Type *Ty)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
const SCEV * visitUMaxExpr(const SCEVUMaxExpr *Expr)
Type * getType() const
All values are typed, get the type of this value.
This class represents a range of values.
const SCEV * visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr)
CHAIN = SC CHAIN, Imm128 - System call.
const SCEV * visitSMaxExpr(const SCEVSMaxExpr *Expr)
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
ConstantInt * getValue() const
const SCEV * getUMaxExpr(const SCEV *LHS, const SCEV *RHS)
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.
SCEVAddExpr - This node represents an addition of some number of SCEVs.
const SCEV * getSignExtendExpr(const SCEV *Op, Type *Ty)
const SCEV * visitTruncateExpr(const SCEVTruncateExpr *Expr)
SCEVSMaxExpr - This class represents a signed maximum selection.
const SCEV * getAddExpr(SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
getAddExpr - 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 * visitAddExpr(const SCEVAddExpr *Expr)
SCEVZeroExtendExpr - This class represents a zero extension of a small integer value to a larger inte...
Virtual Register Rewriter
const SCEV * visitUnknown(const SCEVUnknown *Expr)
const SCEV * visitAddRecExpr(const SCEVAddRecExpr *Expr)
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.
SCEV - 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 * visitSignExtendExpr(const SCEVSignExtendExpr *Expr)
SCEVSignExtendExpr - This class represents a sign extension of a small integer value to a larger inte...
SCEVUMaxExpr - This class represents an unsigned maximum selection.
const Loop * getLoop() const
The SCEVApplyRewriter takes a scalar evolution expression and applies the Map (Loop -> SCEV) to all A...
const SCEV * visitConstant(const SCEVConstant *Constant)
unsigned getSCEVType() const
SCEVNAryExpr(const FoldingSetNodeIDRef ID, enum SCEVTypes T, const SCEV *const *O, size_t N)
LLVM Value Representation.
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
const SCEV * getUDivExpr(const SCEV *LHS, const SCEV *RHS)
getUDivExpr - Get a canonical unsigned division expression, or something simpler if possible...
const SCEV * getUnknown(Value *V)
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 * visitTruncateExpr(const SCEVTruncateExpr *Expr)
const SCEV * getZeroExtendExpr(const SCEV *Op, Type *Ty)
SCEVNAryExpr - 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)
getMulExpr - 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:
const SCEV * visitUMaxExpr(const SCEVUMaxExpr *Expr)
const SCEV * visitCouldNotCompute(const SCEVCouldNotCompute *Expr)
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
bool isQuadratic() const
isQuadratic - Return true if this represents an expression A + B*x + C*x^2 where A, B and C are loop invariant values.
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
SCEVConstant - This class represents a constant integer value.