Rename loop preheaders pass to loop simplify
[oota-llvm.git] / include / llvm / ModuleProvider.h
1 //===-- llvm/ModuleProvider.h - Interface for module providers --*- C++ -*-===//
2 //
3 // This file provides an abstract interface for loading a module from some
4 // place.  This interface allows incremental or random access loading of
5 // functions from the file.  This is useful for applications like JIT compilers
6 // or interprocedural optimizers that do not need the entire program in memory
7 // at the same time.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef MODULEPROVIDER_H
12 #define MODULEPROVIDER_H
13
14 class Function;
15 class Module;
16
17 class ModuleProvider {
18 protected:
19   Module *TheModule;
20   ModuleProvider();
21
22 public:
23   virtual ~ModuleProvider();
24
25   /// getModule - returns the module this provider is encapsulating.
26   ///
27   Module* getModule() { return TheModule; }
28
29   /// materializeFunction - make sure the given function is fully read.
30   ///
31   virtual void materializeFunction(Function *F) = 0;
32
33   /// materializeModule - make sure the entire Module has been completely read.
34   ///
35   void materializeModule();
36
37   /// releaseModule - no longer delete the Module* when provider is destroyed.
38   ///
39   virtual Module* releaseModule() { 
40     // Since we're losing control of this Module, we must hand it back complete
41     materializeModule();
42     Module *tempM = TheModule; 
43     TheModule = 0; 
44     return tempM; 
45   }
46 };
47
48 #endif