Remove the reduceApply functions they are obsolete things from the days before
[oota-llvm.git] / include / llvm / Module.h
1 //===-- llvm/Module.h - C++ class to represent a VM module -------*- C++ -*--=//
2 //
3 // This file contains the declarations for the Module class that is used to 
4 // maintain all the information related to a VM module.
5 //
6 // A module also maintains a GlobalValRefMap object that is used to hold all
7 // constant references to global variables in the module.  When a global
8 // variable is destroyed, it should have no entries in the GlobalValueRefMap.
9 //
10 //===----------------------------------------------------------------------===//
11
12 #ifndef LLVM_MODULE_H
13 #define LLVM_MODULE_H
14
15 #include "llvm/Value.h"
16 #include "llvm/SymTabValue.h"
17 #include "llvm/ValueHolder.h"
18 class GlobalVariable;
19 class GlobalValueRefMap;   // Used by ConstantVals.cpp
20 class ConstantPointerRef;
21
22 class Module : public Value, public SymTabValue {
23 public:
24   typedef ValueHolder<GlobalVariable, Module, Module> GlobalListType;
25   typedef ValueHolder<Function, Module, Module> FunctionListType;
26
27   // Global Variable iterators...
28   typedef GlobalListType::iterator                             giterator;
29   typedef GlobalListType::const_iterator                 const_giterator;
30   typedef std::reverse_iterator<giterator>             reverse_giterator;
31   typedef std::reverse_iterator<const_giterator> const_reverse_giterator;
32
33   // Function iterators...
34   typedef FunctionListType::iterator                            iterator;
35   typedef FunctionListType::const_iterator                const_iterator;
36   typedef std::reverse_iterator<iterator>             reverse_iterator;
37   typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
38
39 private:
40   GlobalListType GlobalList;     // The Global Variables
41   FunctionListType FunctionList;     // The Functions
42
43   GlobalValueRefMap *GVRefMap;
44
45   // Accessor for the underlying GlobalValRefMap... only through the
46   // ConstantPointerRef class...
47   friend class ConstantPointerRef;
48   void mutateConstantPointerRef(GlobalValue *OldGV, GlobalValue *NewGV);
49   ConstantPointerRef *getConstantPointerRef(GlobalValue *GV);
50
51 public:
52   Module();
53   ~Module();
54
55   // Get the underlying elements of the Module...
56   inline const GlobalListType &getGlobalList() const  { return GlobalList; }
57   inline       GlobalListType &getGlobalList()        { return GlobalList; }
58   inline const FunctionListType &getFunctionList() const { return FunctionList;}
59   inline       FunctionListType &getFunctionList()       { return FunctionList;}
60
61   //===--------------------------------------------------------------------===//
62   // Module iterator forwarding functions
63   //
64   inline giterator                gbegin()       { return GlobalList.begin(); }
65   inline const_giterator          gbegin() const { return GlobalList.begin(); }
66   inline giterator                gend  ()       { return GlobalList.end();   }
67   inline const_giterator          gend  () const { return GlobalList.end();   }
68
69   inline reverse_giterator       grbegin()       { return GlobalList.rbegin(); }
70   inline const_reverse_giterator grbegin() const { return GlobalList.rbegin(); }
71   inline reverse_giterator       grend  ()       { return GlobalList.rend();   }
72   inline const_reverse_giterator grend  () const { return GlobalList.rend();   }
73
74   inline unsigned                  gsize() const { return GlobalList.size(); }
75   inline bool                     gempty() const { return GlobalList.empty(); }
76   inline const GlobalVariable    *gfront() const { return GlobalList.front(); }
77   inline       GlobalVariable    *gfront()       { return GlobalList.front(); }
78   inline const GlobalVariable     *gback() const { return GlobalList.back(); }
79   inline       GlobalVariable     *gback()       { return GlobalList.back(); }
80
81
82
83   inline iterator                begin()       { return FunctionList.begin(); }
84   inline const_iterator          begin() const { return FunctionList.begin(); }
85   inline iterator                end  ()       { return FunctionList.end();   }
86   inline const_iterator          end  () const { return FunctionList.end();   }
87
88   inline reverse_iterator       rbegin()       { return FunctionList.rbegin(); }
89   inline const_reverse_iterator rbegin() const { return FunctionList.rbegin(); }
90   inline reverse_iterator       rend  ()       { return FunctionList.rend();   }
91   inline const_reverse_iterator rend  () const { return FunctionList.rend();   }
92
93   inline unsigned                 size() const { return FunctionList.size(); }
94   inline bool                    empty() const { return FunctionList.empty(); }
95   inline const Function         *front() const { return FunctionList.front(); }
96   inline       Function         *front()       { return FunctionList.front(); }
97   inline const Function          *back() const { return FunctionList.back(); }
98   inline       Function          *back()       { return FunctionList.back(); }
99
100   // Methods for support type inquiry through isa, cast, and dyn_cast:
101   static inline bool classof(const Module *T) { return true; }
102   static inline bool classof(const Value *V) {
103     return V->getValueType() == Value::ModuleVal;
104   }
105
106   // dropAllReferences() - This function causes all the subinstructions to "let
107   // go" of all references that they are maintaining.  This allows one to
108   // 'delete' a whole class at a time, even though there may be circular
109   // references... first all references are dropped, and all use counts go to
110   // zero.  Then everything is delete'd for real.  Note that no operations are
111   // valid on an object that has "dropped all references", except operator 
112   // delete.
113   //
114   void dropAllReferences();
115 };
116
117 #endif