For PR950:
[oota-llvm.git] / include / llvm / Analysis / ScalarEvolutionExpressions.h
index b632bc58eea5ed94684487daf40418e3a5f1c575..b9bf93b8c79aea3069269ef23a831881aac12412 100644 (file)
@@ -1,14 +1,14 @@
 //===- llvm/Analysis/ScalarEvolutionExpressions.h - SCEV Exprs --*- C++ -*-===//
-// 
+//
 //                     The LLVM Compiler Infrastructure
 //
 // This file was developed by the LLVM research group and is distributed under
 // the University of Illinois Open Source License. See LICENSE.TXT for details.
-// 
+//
 //===----------------------------------------------------------------------===//
 //
 // This file defines the classes used to represent and build scalar expressions.
-// 
+//
 //===----------------------------------------------------------------------===//
 
 #ifndef LLVM_ANALYSIS_SCALAREVOLUTION_EXPRESSIONS_H
@@ -23,7 +23,7 @@ namespace llvm {
   enum SCEVTypes {
     // These should be ordered in terms of increasing complexity to make the
     // folders simpler.
-    scConstant, scTruncate, scZeroExtend, scAddExpr, scMulExpr, scUDivExpr,
+    scConstant, scTruncate, scZeroExtend, scAddExpr, scMulExpr, scSDivExpr,
     scAddRecExpr, scUnknown, scCouldNotCompute
   };
 
@@ -33,7 +33,7 @@ namespace llvm {
   class SCEVConstant : public SCEV {
     ConstantInt *V;
     SCEVConstant(ConstantInt *v) : SCEV(scConstant), V(v) {}
-    
+
     virtual ~SCEVConstant();
   public:
     /// get method - This just gets and returns a new SCEVConstant object.
@@ -62,6 +62,7 @@ namespace llvm {
     }
 
     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 SCEVConstant *S) { return true; }
@@ -86,7 +87,7 @@ namespace llvm {
 
     const SCEVHandle &getOperand() const { return Op; }
     virtual const Type *getType() const { return Ty; }
-    
+
     virtual bool isLoopInvariant(const Loop *L) const {
       return Op->isLoopInvariant(L);
     }
@@ -108,6 +109,7 @@ namespace llvm {
     virtual ConstantRange getValueRange() const;
 
     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 SCEVTruncateExpr *S) { return true; }
@@ -132,7 +134,7 @@ namespace llvm {
 
     const SCEVHandle &getOperand() const { return Op; }
     virtual const Type *getType() const { return Ty; }
-    
+
     virtual bool isLoopInvariant(const Loop *L) const {
       return Op->isLoopInvariant(L);
     }
@@ -154,6 +156,7 @@ namespace llvm {
     }
 
     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 SCEVZeroExtendExpr *S) { return true; }
@@ -218,6 +221,7 @@ namespace llvm {
 
     virtual const Type *getType() const { return getOperand(0)->getType(); }
     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 SCEVCommutativeExpr *S) { return true; }
@@ -293,16 +297,16 @@ namespace llvm {
 
 
   //===--------------------------------------------------------------------===//
-  /// SCEVUDivExpr - This class represents a binary unsigned division operation.
+  /// SCEVSDivExpr - This class represents a binary signed division operation.
   ///
-  class SCEVUDivExpr : public SCEV {
+  class SCEVSDivExpr : public SCEV {
     SCEVHandle LHS, RHS;
-    SCEVUDivExpr(const SCEVHandle &lhs, const SCEVHandle &rhs)
-      : SCEV(scUDivExpr), LHS(lhs), RHS(rhs) {}
+    SCEVSDivExpr(const SCEVHandle &lhs, const SCEVHandle &rhs)
+      : SCEV(scSDivExpr), LHS(lhs), RHS(rhs) {}
 
-    virtual ~SCEVUDivExpr();
+    virtual ~SCEVSDivExpr();
   public:
-    /// get method - This just gets and returns a new SCEVUDiv object.
+    /// get method - This just gets and returns a new SCEVSDiv object.
     ///
     static SCEVHandle get(const SCEVHandle &LHS, const SCEVHandle &RHS);
 
@@ -332,11 +336,12 @@ namespace llvm {
     virtual const Type *getType() const;
 
     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 SCEVUDivExpr *S) { return true; }
+    static inline bool classof(const SCEVSDivExpr *S) { return true; }
     static inline bool classof(const SCEV *S) {
-      return S->getSCEVType() == scUDivExpr;
+      return S->getSCEVType() == scSDivExpr;
     }
   };
 
@@ -421,13 +426,16 @@ 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.
-    SCEVHandle getNumIterationsInRange(ConstantRange Range) const;
+    /// returned. The isSigned parameter indicates whether the ConstantRange
+    /// should be treated as signed or unsigned.
+    SCEVHandle getNumIterationsInRange(ConstantRange Range, 
+                                       bool isSigned) const;
 
     SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
                                                  const SCEVHandle &Conc) const;
 
     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 SCEVAddRecExpr *S) { return true; }
@@ -472,6 +480,7 @@ namespace llvm {
     virtual const Type *getType() const;
 
     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 SCEVUnknown *S) { return true; }
@@ -496,8 +505,8 @@ namespace llvm {
         return ((SC*)this)->visitAddExpr((SCEVAddExpr*)S);
       case scMulExpr:
         return ((SC*)this)->visitMulExpr((SCEVMulExpr*)S);
-      case scUDivExpr:
-        return ((SC*)this)->visitUDivExpr((SCEVUDivExpr*)S);
+      case scSDivExpr:
+        return ((SC*)this)->visitSDivExpr((SCEVSDivExpr*)S);
       case scAddRecExpr:
         return ((SC*)this)->visitAddRecExpr((SCEVAddRecExpr*)S);
       case scUnknown: