Add a flag to mark a dirty cache entry. This is not yet used, but will eventually
[oota-llvm.git] / include / llvm / Analysis / ScalarEvolution.h
index 4eb0bb33b255d48fcfbe393ea7bc92117707f971..b6a58fe0053f9570aef826d84adbcbc3c9b30323 100644 (file)
@@ -22,6 +22,7 @@
 #define LLVM_ANALYSIS_SCALAREVOLUTION_H
 
 #include "llvm/Pass.h"
+#include "llvm/Support/DataTypes.h"
 #include "llvm/Support/Streams.h"
 #include <set>
 
@@ -53,7 +54,7 @@ namespace llvm {
   protected:
     virtual ~SCEV();
   public:
-    SCEV(unsigned SCEVTy) : SCEVType(SCEVTy), RefCount(0) {}
+    explicit SCEV(unsigned SCEVTy) : SCEVType(SCEVTy), RefCount(0) {}
 
     /// getNegativeSCEV - Return the SCEV object corresponding to -V.
     ///
@@ -85,6 +86,10 @@ namespace llvm {
     ///
     virtual const Type *getType() const = 0;
 
+    /// getBitWidth - Get the bit width of the type, if it has one, 0 otherwise.
+    /// 
+    uint32_t getBitWidth() const;
+
     /// replaceSymbolicValuesWithConcrete - If this SCEV internally references
     /// the symbolic value "Sym", construct and return a new SCEV that produces
     /// the same value, but which uses the concrete value Conc instead of the
@@ -97,20 +102,14 @@ namespace llvm {
     /// print - Print out the internal representation of this scalar to the
     /// specified stream.  This should really only be used for debugging
     /// purposes.
-    void print(OStream &OS) const {
-      if (OS.stream()) print(*OS.stream());
-    }
     virtual void print(std::ostream &OS) const = 0;
+    void print(std::ostream *OS) const { if (OS) print(*OS); }
 
     /// dump - This method is used for debugging.
     ///
     void dump() const;
   };
 
-  inline OStream &operator<<(OStream &OS, const SCEV &S) {
-    S.print(OS);
-    return OS;
-  }
   inline std::ostream &operator<<(std::ostream &OS, const SCEV &S) {
     S.print(OS);
     return OS;
@@ -128,10 +127,8 @@ namespace llvm {
     virtual bool isLoopInvariant(const Loop *L) const;
     virtual const Type *getType() const;
     virtual bool hasComputableLoopEvolution(const Loop *L) const;
-    void print(OStream &OS) const {
-      if (OS.stream()) print(*OS.stream());
-    }
     virtual void print(std::ostream &OS) const;
+    void print(std::ostream *OS) const { if (OS) print(*OS); }
     virtual SCEVHandle
     replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
                                       const SCEVHandle &Conc) const;
@@ -200,7 +197,8 @@ namespace llvm {
   class ScalarEvolution : public FunctionPass {
     void *Impl;    // ScalarEvolution uses the pimpl pattern
   public:
-    ScalarEvolution() : Impl(0) {}
+    static char ID; // Pass identification, replacement for typeid
+    ScalarEvolution() : FunctionPass((intptr_t)&ID), Impl(0) {}
 
     /// getSCEV - Return a SCEV expression handle for the full generality of the
     /// specified expression.
@@ -234,18 +232,18 @@ namespace llvm {
     /// an analyzable loop-invariant iteration count.
     bool hasLoopInvariantIterationCount(const Loop *L) const;
 
-    /// deleteInstructionFromRecords - This method should be called by the
-    /// client before it removes an instruction from the program, to make sure
+    /// deleteValueFromRecords - This method should be called by the
+    /// client before it removes a Value from the program, to make sure
     /// that no dangling references are left around.
-    void deleteInstructionFromRecords(Instruction *I) const;
+    void deleteValueFromRecords(Value *V) const;
 
     virtual bool runOnFunction(Function &F);
     virtual void releaseMemory();
     virtual void getAnalysisUsage(AnalysisUsage &AU) const;
-    void print(OStream &OS, const Module* = 0) const {
-      if (OS.stream()) print(*OS.stream());
-    }
     virtual void print(std::ostream &OS, const Module* = 0) const;
+    void print(std::ostream *OS, const Module* M = 0) const {
+      if (OS) print(*OS, M);
+    }
   };
 }