namespace llvm {
class ConstantInt;
class ConstantRange;
+ class APInt;
enum SCEVTypes {
// These should be ordered in terms of increasing complexity to make the
// folders simpler.
- scConstant, scTruncate, scZeroExtend, scAddExpr, scMulExpr, scSDivExpr,
- scAddRecExpr, scUnknown, scCouldNotCompute
+ scConstant, scTruncate, scZeroExtend, scSignExtend, scAddExpr, scMulExpr,
+ scSDivExpr, scAddRecExpr, scUnknown, scCouldNotCompute
};
//===--------------------------------------------------------------------===//
///
class SCEVConstant : public SCEV {
ConstantInt *V;
- SCEVConstant(ConstantInt *v) : SCEV(scConstant), V(v) {}
+ explicit SCEVConstant(ConstantInt *v) : SCEV(scConstant), V(v) {}
virtual ~SCEVConstant();
public:
/// get method - This just gets and returns a new SCEVConstant object.
///
static SCEVHandle get(ConstantInt *V);
+ static SCEVHandle get(const APInt& Val);
ConstantInt *getValue() const { return V; }
}
};
+ //===--------------------------------------------------------------------===//
+ /// SCEVSignExtendExpr - This class represents a sign extension of a small
+ /// integer value to a larger integer value.
+ ///
+ class SCEVSignExtendExpr : public SCEV {
+ SCEVHandle Op;
+ const Type *Ty;
+ SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty);
+ virtual ~SCEVSignExtendExpr();
+ public:
+ /// get method - This just gets and returns a new SCEVSignExtend object
+ ///
+ static SCEVHandle get(const SCEVHandle &Op, const Type *Ty);
+
+ const SCEVHandle &getOperand() const { return Op; }
+ virtual const Type *getType() const { return Ty; }
+
+ virtual bool isLoopInvariant(const Loop *L) const {
+ return Op->isLoopInvariant(L);
+ }
+
+ virtual bool hasComputableLoopEvolution(const Loop *L) const {
+ return Op->hasComputableLoopEvolution(L);
+ }
+
+ /// getValueRange - Return the tightest constant bounds that this value is
+ /// known to have. This method is only valid on integer SCEV objects.
+ virtual ConstantRange getValueRange() const;
+
+ SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
+ const SCEVHandle &Conc) const {
+ SCEVHandle H = Op->replaceSymbolicValuesWithConcrete(Sym, Conc);
+ if (H == Op)
+ return this;
+ return get(H, Ty);
+ }
+
+ virtual void print(std::ostream &OS) const;
+ void print(std::ostream *OS) const { if (OS) print(*OS); }
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const SCEVSignExtendExpr *S) { return true; }
+ static inline bool classof(const SCEV *S) {
+ return S->getSCEVType() == scSignExtend;
+ }
+ };
+
//===--------------------------------------------------------------------===//
/// SCEVCommutativeExpr - This node is the base class for n'ary commutative
/// looking at this is that it returns the first iteration number where the
/// value is not in the condition, thus computing the exit count. If the
/// iteration count can't be computed, an instance of SCEVCouldNotCompute is
- /// returned. The isSigned parameter indicates whether the ConstantRange
- /// should be treated as signed or unsigned.
- SCEVHandle getNumIterationsInRange(ConstantRange Range,
- bool isSigned) const;
+ /// returned.
+ SCEVHandle getNumIterationsInRange(ConstantRange Range) const;
SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
const SCEVHandle &Conc) const;
return ((SC*)this)->visitTruncateExpr((SCEVTruncateExpr*)S);
case scZeroExtend:
return ((SC*)this)->visitZeroExtendExpr((SCEVZeroExtendExpr*)S);
+ case scSignExtend:
+ return ((SC*)this)->visitSignExtendExpr((SCEVSignExtendExpr*)S);
case scAddExpr:
return ((SC*)this)->visitAddExpr((SCEVAddExpr*)S);
case scMulExpr: