Added LLVM copyright header (for lack of a better term).
[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 class Function;
22 class Module;
23
24 class ModuleProvider {
25 protected:
26   Module *TheModule;
27   ModuleProvider();
28
29 public:
30   virtual ~ModuleProvider();
31
32   /// getModule - returns the module this provider is encapsulating.
33   ///
34   Module* getModule() { return TheModule; }
35
36   /// materializeFunction - make sure the given function is fully read.
37   ///
38   virtual void materializeFunction(Function *F) = 0;
39
40   /// materializeModule - make sure the entire Module has been completely read.
41   ///
42   Module* materializeModule();
43
44   /// releaseModule - no longer delete the Module* when provider is destroyed.
45   ///
46   virtual Module* releaseModule() { 
47     // Since we're losing control of this Module, we must hand it back complete
48     materializeModule();
49     Module *tempM = TheModule; 
50     TheModule = 0; 
51     return tempM; 
52   }
53 };
54
55 #endif