Add a flag to mark a dirty cache entry. This is not yet used, but will eventually
[oota-llvm.git] / include / llvm / Analysis / ScalarEvolutionExpressions.h
index af795377c2b95e39d1557042d829d36ae8b53817..af1656ee8ea3f8cdd78fd2a333525aa45e155f68 100644 (file)
@@ -24,8 +24,8 @@ namespace llvm {
   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
   };
 
   //===--------------------------------------------------------------------===//
@@ -33,13 +33,14 @@ namespace llvm {
   ///
   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; }
 
@@ -166,6 +167,53 @@ namespace llvm {
     }
   };
 
+  //===--------------------------------------------------------------------===//
+  /// 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
@@ -427,10 +475,8 @@ namespace llvm {
     /// 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;
@@ -464,7 +510,6 @@ namespace llvm {
     /// getIntegerSCEV - Given an integer or FP type, create a constant for the
     /// specified signed integer value and return a SCEV for the constant.
     static SCEVHandle getIntegerSCEV(int Val, const Type *Ty);
-    static SCEVHandle getIntegerSCEV(const APInt& Val);
 
     Value *getValue() const { return V; }
 
@@ -503,6 +548,8 @@ namespace llvm {
         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: