Rip JIT specific stuff out of TargetMachine, as per PR176
[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.
39   ///
40   virtual void materializeFunction(Function *F) = 0;
41
42   /// materializeModule - make sure the entire Module has been completely read.
43   ///
44   Module* materializeModule();
45
46   /// releaseModule - no longer delete the Module* when provider is destroyed.
47   ///
48   virtual Module* releaseModule() { 
49     // Since we're losing control of this Module, we must hand it back complete
50     materializeModule();
51     Module *tempM = TheModule; 
52     TheModule = 0; 
53     return tempM; 
54   }
55 };
56
57 } // End llvm namespace
58
59 #endif