Make SCEVExpanders private methods private, instead of protected.
[oota-llvm.git] / include / llvm / Analysis / LoopVR.h
1 //===- LoopVR.cpp - Value Range analysis driven by loop information -------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the interface for the loop-driven value range pass.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_ANALYSIS_LOOPVR_H
15 #define LLVM_ANALYSIS_LOOPVR_H
16
17 #include "llvm/Pass.h"
18 #include "llvm/Analysis/ScalarEvolution.h"
19 #include "llvm/Support/ConstantRange.h"
20 #include <iosfwd>
21 #include <map>
22
23 namespace llvm {
24
25 /// LoopVR - This class maintains a mapping of Values to ConstantRanges.
26 /// There are interfaces to look up and update ranges by value, and for
27 /// accessing all values with range information.
28 ///
29 class LoopVR : public FunctionPass {
30 public:
31   static char ID; // Class identification, replacement for typeinfo
32
33   LoopVR() : FunctionPass(&ID) {}
34
35   bool runOnFunction(Function &F);
36   virtual void print(std::ostream &os, const Module *) const;
37   void releaseMemory();
38
39   void getAnalysisUsage(AnalysisUsage &AU) const {
40     AU.addRequiredTransitive<LoopInfo>();
41     AU.addRequiredTransitive<ScalarEvolution>();
42     AU.setPreservesAll();
43   }
44
45   //===---------------------------------------------------------------------
46   // Methods that are used to look up and update particular values.
47
48   /// get - return the ConstantRange for a given Value of IntegerType.
49   ConstantRange get(Value *V);
50
51   /// remove - remove a value from this analysis.
52   void remove(Value *V);
53
54   /// narrow - improve our unterstanding of a Value by pointing out that it
55   /// must fall within ConstantRange. To replace a range, remove it first.
56   void narrow(Value *V, const ConstantRange &CR);
57
58   //===---------------------------------------------------------------------
59   // Methods that are used to iterate across all values with information.
60
61   /// size - returns the number of Values with information
62   unsigned size() const { return Map.size(); }
63
64   typedef std::map<Value *, ConstantRange *>::iterator iterator;
65
66   /// begin - return an iterator to the first Value, ConstantRange pair
67   iterator begin() { return Map.begin(); }
68
69   /// end - return an iterator one past the last Value, ConstantRange pair
70   iterator end() { return Map.end(); }
71
72   /// getValue - return the Value referenced by an iterator
73   Value *getValue(iterator I) { return I->first; }
74
75   /// getConstantRange - return the ConstantRange referenced by an iterator
76   ConstantRange getConstantRange(iterator I) { return *I->second; }
77
78 private:
79   ConstantRange compute(Value *V);
80
81   ConstantRange getRange(SCEVHandle S, Loop *L, ScalarEvolution &SE);
82
83   ConstantRange getRange(SCEVHandle S, SCEVHandle T, ScalarEvolution &SE);
84
85   std::map<Value *, ConstantRange *> Map;
86 };
87
88 } // end llvm namespace
89
90 #endif