These have been removed
[oota-llvm.git] / include / llvm / ModuleProvider.h
1 //===-- llvm/ModuleProvider.h - Interface for module providers --*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file provides an abstract interface for loading a module from some
11 // place.  This interface allows incremental or random access loading of
12 // functions from the file.  This is useful for applications like JIT compilers
13 // or interprocedural optimizers that do not need the entire program in memory
14 // at the same time.
15 //
16 //===----------------------------------------------------------------------===//
17
18 #ifndef MODULEPROVIDER_H
19 #define MODULEPROVIDER_H
20
21 namespace llvm {
22
23 class Function;
24 class Module;
25
26 class ModuleProvider {
27 protected:
28   Module *TheModule;
29   ModuleProvider();
30
31 public:
32   virtual ~ModuleProvider();
33
34   /// getModule - returns the module this provider is encapsulating.
35   ///
36   Module* getModule() { return TheModule; }
37
38   /// materializeFunction - make sure the given function is fully read.  Note
39   /// that this can throw an exception if the module is corrupt!
40   ///
41   virtual void materializeFunction(Function *F) = 0;
42
43   /// materializeModule - make sure the entire Module has been completely read.
44   /// Note that this can throw an exception if the module is corrupt!
45   ///
46   virtual Module* materializeModule() = 0;
47
48   /// releaseModule - no longer delete the Module* when provider is destroyed.
49   /// Note that this can throw an exception if the module is corrupt!
50   ///
51   virtual Module* releaseModule() { 
52     // Since we're losing control of this Module, we must hand it back complete
53     materializeModule();
54     Module *tempM = TheModule; 
55     TheModule = 0; 
56     return tempM; 
57   }
58 };
59
60
61 /// ExistingModuleProvider - Allow conversion from a fully materialized Module
62 /// into a ModuleProvider, allowing code that expects a ModuleProvider to work
63 /// if we just have a Module.  Note that the ModuleProvider takes ownership of
64 /// the Module specified.
65 struct ExistingModuleProvider : public ModuleProvider {
66   ExistingModuleProvider(Module *M) {
67     TheModule = M;
68   }
69   void materializeFunction(Function *F) {}
70   Module* materializeModule() { return TheModule; }
71 };
72
73 } // End llvm namespace
74
75 #endif