diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-06-21 13:59:01 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-06-21 13:59:01 +0000 |
commit | 3a0822f094b578157263e04114075ad7df81db41 (patch) | |
tree | bc48361fe2cd1ca5f93ac01b38b183774468fc79 /lib/ExecutionEngine/MCJIT | |
parent | 85d8b2bbe386bcfe669575d05b61482d7be07e5d (diff) |
Diffstat (limited to 'lib/ExecutionEngine/MCJIT')
-rw-r--r-- | lib/ExecutionEngine/MCJIT/CMakeLists.txt | 3 | ||||
-rw-r--r-- | lib/ExecutionEngine/MCJIT/MCJIT.cpp | 28 | ||||
-rw-r--r-- | lib/ExecutionEngine/MCJIT/MCJIT.h | 18 |
3 files changed, 43 insertions, 6 deletions
diff --git a/lib/ExecutionEngine/MCJIT/CMakeLists.txt b/lib/ExecutionEngine/MCJIT/CMakeLists.txt index 2911a5077220..b1e2bc3d635c 100644 --- a/lib/ExecutionEngine/MCJIT/CMakeLists.txt +++ b/lib/ExecutionEngine/MCJIT/CMakeLists.txt @@ -1,3 +1,6 @@ add_llvm_library(LLVMMCJIT MCJIT.cpp + + DEPENDS + intrinsics_gen ) diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/lib/ExecutionEngine/MCJIT/MCJIT.cpp index 7e37afe2056e..87243e4221f4 100644 --- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -429,6 +429,19 @@ Function *MCJIT::FindFunctionNamedInModulePtrSet(const char *FnName, return nullptr; } +GlobalVariable *MCJIT::FindGlobalVariableNamedInModulePtrSet(const char *Name, + bool AllowInternal, + ModulePtrSet::iterator I, + ModulePtrSet::iterator E) { + for (; I != E; ++I) { + GlobalVariable *GV = (*I)->getGlobalVariable(Name, AllowInternal); + if (GV && !GV->isDeclaration()) + return GV; + } + return nullptr; +} + + Function *MCJIT::FindFunctionNamed(const char *FnName) { Function *F = FindFunctionNamedInModulePtrSet( FnName, OwnedModules.begin_added(), OwnedModules.end_added()); @@ -441,8 +454,19 @@ Function *MCJIT::FindFunctionNamed(const char *FnName) { return F; } -GenericValue MCJIT::runFunction(Function *F, - const std::vector<GenericValue> &ArgValues) { +GlobalVariable *MCJIT::FindGlobalVariableNamed(const char *Name, bool AllowInternal) { + GlobalVariable *GV = FindGlobalVariableNamedInModulePtrSet( + Name, AllowInternal, OwnedModules.begin_added(), OwnedModules.end_added()); + if (!GV) + GV = FindGlobalVariableNamedInModulePtrSet(Name, AllowInternal, OwnedModules.begin_loaded(), + OwnedModules.end_loaded()); + if (!GV) + GV = FindGlobalVariableNamedInModulePtrSet(Name, AllowInternal, OwnedModules.begin_finalized(), + OwnedModules.end_finalized()); + return GV; +} + +GenericValue MCJIT::runFunction(Function *F, ArrayRef<GenericValue> ArgValues) { assert(F && "Function *F was null at entry to run()"); void *FPtr = getPointerToFunction(F); diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.h b/lib/ExecutionEngine/MCJIT/MCJIT.h index 59e99498f9a4..7fda1e0fed6e 100644 --- a/lib/ExecutionEngine/MCJIT/MCJIT.h +++ b/lib/ExecutionEngine/MCJIT/MCJIT.h @@ -200,6 +200,11 @@ class MCJIT : public ExecutionEngine { ModulePtrSet::iterator I, ModulePtrSet::iterator E); + GlobalVariable *FindGlobalVariableNamedInModulePtrSet(const char *Name, + bool AllowInternal, + ModulePtrSet::iterator I, + ModulePtrSet::iterator E); + void runStaticConstructorsDestructorsInModulePtrSet(bool isDtors, ModulePtrSet::iterator I, ModulePtrSet::iterator E); @@ -215,10 +220,15 @@ public: void addArchive(object::OwningBinary<object::Archive> O) override; bool removeModule(Module *M) override; - /// FindFunctionNamed - Search all of the active modules to find the one that + /// FindFunctionNamed - Search all of the active modules to find the function that /// defines FnName. This is very slow operation and shouldn't be used for /// general code. - Function *FindFunctionNamed(const char *FnName) override; + virtual Function *FindFunctionNamed(const char *FnName) override; + + /// FindGlobalVariableNamed - Search all of the active modules to find the global variable + /// that defines Name. This is very slow operation and shouldn't be used for + /// general code. + virtual GlobalVariable *FindGlobalVariableNamed(const char *Name, bool AllowInternal = false) override; /// Sets the object manager that MCJIT should use to avoid compilation. void setObjectCache(ObjectCache *manager) override; @@ -251,7 +261,7 @@ public: void *getPointerToFunction(Function *F) override; GenericValue runFunction(Function *F, - const std::vector<GenericValue> &ArgValues) override; + ArrayRef<GenericValue> ArgValues) override; /// getPointerToNamedFunction - This method returns the address of the /// specified function by using the dlsym function call. As such it is only @@ -325,6 +335,6 @@ protected: bool CheckFunctionsOnly); }; -} // End llvm namespace +} // namespace llvm #endif |