summaryrefslogtreecommitdiff
path: root/include/llvm/ExecutionEngine
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2010-01-27 20:34:15 +0000
committerJeffrey Yasskin <jyasskin@google.com>2010-01-27 20:34:15 +0000
commitf0356fe140af1a30587b9a86bcfb1b2c51b8ce20 (patch)
treeb93c54de2473a5a87afd13ebccdd234b509b6b72 /include/llvm/ExecutionEngine
parent5deb57c68552a85094b786dfdbd16e3744716733 (diff)
downloadllvm-f0356fe140af1a30587b9a86bcfb1b2c51b8ce20.tar.gz
llvm-f0356fe140af1a30587b9a86bcfb1b2c51b8ce20.tar.bz2
llvm-f0356fe140af1a30587b9a86bcfb1b2c51b8ce20.tar.xz
Kill ModuleProvider and ghost linkage by inverting the relationship between
Modules and ModuleProviders. Because the "ModuleProvider" simply materializes GlobalValues now, and doesn't provide modules, it's renamed to "GVMaterializer". Code that used to need a ModuleProvider to materialize Functions can now materialize the Functions directly. Functions no longer use a magic linkage to record that they're materializable; they simply ask the GVMaterializer. Because the C ABI must never change, we can't remove LLVMModuleProviderRef or the functions that refer to it. Instead, because Module now exposes the same functionality ModuleProvider used to, we store a Module* in any LLVMModuleProviderRef and translate in the wrapper methods. The bindings to other languages still use the ModuleProvider concept. It would probably be worth some time to update them to follow the C++ more closely, but I don't intend to do it. Fixes http://llvm.org/PR5737 and http://llvm.org/PR5735. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94686 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ExecutionEngine')
-rw-r--r--include/llvm/ExecutionEngine/ExecutionEngine.h55
1 files changed, 21 insertions, 34 deletions
diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h
index d2c547dcf1..ce6a2e9af0 100644
--- a/include/llvm/ExecutionEngine/ExecutionEngine.h
+++ b/include/llvm/ExecutionEngine/ExecutionEngine.h
@@ -36,7 +36,6 @@ class JITEventListener;
class JITMemoryManager;
class MachineCodeInfo;
class Module;
-class ModuleProvider;
class MutexGuard;
class TargetData;
class Type;
@@ -95,9 +94,9 @@ class ExecutionEngine {
friend class EngineBuilder; // To allow access to JITCtor and InterpCtor.
protected:
- /// Modules - This is a list of ModuleProvider's that we are JIT'ing from. We
- /// use a smallvector to optimize for the case where there is only one module.
- SmallVector<ModuleProvider*, 1> Modules;
+ /// Modules - This is a list of Modules that we are JIT'ing from. We use a
+ /// smallvector to optimize for the case where there is only one module.
+ SmallVector<Module*, 1> Modules;
void setTargetData(const TargetData *td) {
TD = td;
@@ -109,13 +108,13 @@ protected:
// To avoid having libexecutionengine depend on the JIT and interpreter
// libraries, the JIT and Interpreter set these functions to ctor pointers
// at startup time if they are linked in.
- static ExecutionEngine *(*JITCtor)(ModuleProvider *MP,
+ static ExecutionEngine *(*JITCtor)(Module *M,
std::string *ErrorStr,
JITMemoryManager *JMM,
CodeGenOpt::Level OptLevel,
bool GVsWithCode,
CodeModel::Model CMM);
- static ExecutionEngine *(*InterpCtor)(ModuleProvider *MP,
+ static ExecutionEngine *(*InterpCtor)(Module *M,
std::string *ErrorStr);
/// LazyFunctionCreator - If an unknown function is needed, this function
@@ -141,8 +140,8 @@ public:
/// create - This is the factory method for creating an execution engine which
/// is appropriate for the current machine. This takes ownership of the
- /// module provider.
- static ExecutionEngine *create(ModuleProvider *MP,
+ /// module.
+ static ExecutionEngine *create(Module *M,
bool ForceInterpreter = false,
std::string *ErrorStr = 0,
CodeGenOpt::Level OptLevel =
@@ -165,11 +164,11 @@ public:
/// createJIT - This is the factory method for creating a JIT for the current
/// machine, it does not fall back to the interpreter. This takes ownership
- /// of the ModuleProvider and JITMemoryManager if successful.
+ /// of the Module and JITMemoryManager if successful.
///
/// Clients should make sure to initialize targets prior to calling this
/// function.
- static ExecutionEngine *createJIT(ModuleProvider *MP,
+ static ExecutionEngine *createJIT(Module *M,
std::string *ErrorStr = 0,
JITMemoryManager *JMM = 0,
CodeGenOpt::Level OptLevel =
@@ -178,11 +177,11 @@ public:
CodeModel::Model CMM =
CodeModel::Default);
- /// addModuleProvider - Add a ModuleProvider to the list of modules that we
- /// can JIT from. Note that this takes ownership of the ModuleProvider: when
- /// the ExecutionEngine is destroyed, it destroys the MP as well.
- virtual void addModuleProvider(ModuleProvider *P) {
- Modules.push_back(P);
+ /// addModule - Add a Module to the list of modules that we can JIT from.
+ /// Note that this takes ownership of the Module: when the ExecutionEngine is
+ /// destroyed, it destroys the Module as well.
+ virtual void addModule(Module *M) {
+ Modules.push_back(M);
}
//===----------------------------------------------------------------------===//
@@ -190,16 +189,9 @@ public:
const TargetData *getTargetData() const { return TD; }
- /// removeModuleProvider - Remove a ModuleProvider from the list of modules.
- /// Relases the Module from the ModuleProvider, materializing it in the
- /// process, and returns the materialized Module.
- virtual Module* removeModuleProvider(ModuleProvider *P,
- std::string *ErrInfo = 0);
-
- /// deleteModuleProvider - Remove a ModuleProvider from the list of modules,
- /// and deletes the ModuleProvider and owned Module. Avoids materializing
- /// the underlying module.
- virtual void deleteModuleProvider(ModuleProvider *P,std::string *ErrInfo = 0);
+ /// removeModule - Remove a Module from the list of modules. Returns true if
+ /// M is found.
+ virtual bool removeModule(Module *M);
/// FindFunctionNamed - Search all of the active modules to find the one that
/// defines FnName. This is very slow operation and shouldn't be used for
@@ -393,7 +385,7 @@ public:
}
protected:
- explicit ExecutionEngine(ModuleProvider *P);
+ explicit ExecutionEngine(Module *M);
void emitGlobals();
@@ -422,7 +414,7 @@ namespace EngineKind {
class EngineBuilder {
private:
- ModuleProvider *MP;
+ Module *M;
EngineKind::Kind WhichEngine;
std::string *ErrorStr;
CodeGenOpt::Level OptLevel;
@@ -443,16 +435,11 @@ class EngineBuilder {
public:
/// EngineBuilder - Constructor for EngineBuilder. If create() is called and
- /// is successful, the created engine takes ownership of the module
- /// provider.
- EngineBuilder(ModuleProvider *mp) : MP(mp) {
+ /// is successful, the created engine takes ownership of the module.
+ EngineBuilder(Module *m) : M(m) {
InitEngine();
}
- /// EngineBuilder - Overloaded constructor that automatically creates an
- /// ExistingModuleProvider for an existing module.
- EngineBuilder(Module *m);
-
/// setEngineKind - Controls whether the user wants the interpreter, the JIT,
/// or whichever engine works. This option defaults to EngineKind::Either.
EngineBuilder &setEngineKind(EngineKind::Kind w) {