10 #ifndef LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H
11 #define LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H
32 std::shared_ptr<JITSymbolResolver> Resolver)
33 : ParentEngine(Parent), ClientResolver(std::move(Resolver)) {}
44 std::shared_ptr<JITSymbolResolver> ClientResolver;
68 MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
69 std::shared_ptr<MCJITMemoryManager> MemMgr,
70 std::shared_ptr<JITSymbolResolver> Resolver);
74 class OwningModuleContainer {
76 OwningModuleContainer() {
78 ~OwningModuleContainer() {
79 freeModulePtrSet(AddedModules);
80 freeModulePtrSet(LoadedModules);
81 freeModulePtrSet(FinalizedModules);
96 void addModule(std::unique_ptr<Module> M) {
97 AddedModules.insert(M.release());
101 return AddedModules.erase(M) || LoadedModules.erase(M) ||
102 FinalizedModules.erase(M);
105 bool hasModuleBeenAddedButNotLoaded(
Module *M) {
106 return AddedModules.count(M) != 0;
109 bool hasModuleBeenLoaded(
Module *M) {
112 return (LoadedModules.count(M) != 0 ) || (FinalizedModules.count(M) != 0);
115 bool hasModuleBeenFinalized(
Module *M) {
116 return FinalizedModules.count(M) != 0;
119 bool ownsModule(
Module* M) {
120 return (AddedModules.count(M) != 0) || (LoadedModules.count(M) != 0) ||
121 (FinalizedModules.count(M) != 0);
124 void markModuleAsLoaded(
Module *M) {
128 assert(AddedModules.count(M) &&
129 "markModuleAsLoaded: Module not found in AddedModules");
132 AddedModules.erase(M);
135 LoadedModules.insert(M);
138 void markModuleAsFinalized(
Module *M) {
143 assert(LoadedModules.count(M) &&
144 "markModuleAsFinalized: Module not found in LoadedModules");
147 LoadedModules.erase(M);
151 FinalizedModules.insert(M);
154 void markAllLoadedModulesAsFinalized() {
156 E = LoadedModules.end();
159 FinalizedModules.insert(M);
161 LoadedModules.clear();
179 std::unique_ptr<TargetMachine> TM;
181 std::shared_ptr<MCJITMemoryManager> MemMgr;
184 std::vector<JITEventListener*> EventListeners;
186 OwningModuleContainer OwnedModules;
206 void runStaticConstructorsDestructorsInModulePtrSet(
bool isDtors,
215 void addModule(std::unique_ptr<Module> M)
override;
216 void addObjectFile(std::unique_ptr<object::ObjectFile> O)
override;
230 bool AllowInternal =
false)
override;
274 bool AbortOnFailure =
true)
override;
281 uint64_t TargetAddress)
override {
305 std::string *ErrorStr,
306 std::shared_ptr<MCJITMemoryManager> MemMgr,
307 std::shared_ptr<JITSymbolResolver> Resolver,
308 std::unique_ptr<TargetMachine> TM);
324 bool CheckFunctionsOnly);
344 #endif // LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H
Function * FindFunctionNamed(StringRef FnName) override
FindFunctionNamed - Search all of the active modules to find the function that defines FnName...
Information about the loaded object.
void setObjectCache(ObjectCache *manager) override
Sets the object manager that MCJIT should use to avoid compilation.
LinkingSymbolResolver(MCJIT &Parent, std::shared_ptr< JITSymbolResolver > Resolver)
Represents a symbol in the JIT.
A Module instance is used to store all the information related to an LLVM module. ...
static ExecutionEngine * createJIT(std::unique_ptr< Module > M, std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MemMgr, std::shared_ptr< JITSymbolResolver > Resolver, std::unique_ptr< TargetMachine > TM)
JITEventListener - Abstract interface for use by the JIT to notify clients about significant events d...
This class is the base class for all object file types.
void generateCodeForModule(Module *M) override
generateCodeForModule - Run code generation for the specified module and load it into memory...
void UnregisterJITEventListener(JITEventListener *L) override
void runStaticConstructorsDestructors(bool isDtors) override
runStaticConstructorsDestructors - This method is used to execute all of the static constructors or d...
Context object for machine code objects.
uint64_t getGlobalValueAddress(const std::string &Name) override
getGlobalValueAddress - Return the address of the specified global value.
virtual void finalizeModule(Module *)
GlobalVariable * FindGlobalVariableNamed(StringRef Name, bool AllowInternal=false) override
FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines N...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
void * getPointerToFunction(Function *F) override
getPointerToFunction - The different EE's represent function bodies in different ways.
JITSymbol findSymbol(const std::string &Name) override
This method returns the address of the specified function or variable.
void setProcessAllSections(bool ProcessAllSections)
By default, only sections that are "required for execution" are passed to the RTDyldMemoryManager, and other sections are discarded.
JITSymbol findExistingSymbol(const std::string &Name)
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
void finalizeObject() override
finalizeObject - ensure the module is fully processed and is usable.
void addModule(std::unique_ptr< Module > M) override
Add a Module to the list of modules that we can JIT from.
void setProcessAllSections(bool ProcessAllSections) override
setProcessAllSections (MCJIT Only): By default, only sections that are "required for execution" are p...
bool removeModule(Module *M) override
removeModule - Removes a Module from the list of modules, but does not free the module's memory...
void * getPointerToNamedFunction(StringRef Name, bool AbortOnFailure=true) override
getPointerToNamedFunction - This method returns the address of the specified function by using the dl...
static ExecutionEngine *(* MCJITCtor)(std::unique_ptr< Module > M, std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MM, std::shared_ptr< JITSymbolResolver > SR, std::unique_ptr< TargetMachine > TM)
uint64_t getFunctionAddress(const std::string &Name) override
getFunctionAddress - Return the address of the specified function.
JITSymbol findSymbol(const std::string &Name, bool CheckFunctionsOnly)
JITSymbol findSymbolInLogicalDylib(const std::string &Name) override
This method returns the address of the specified symbol if it exists within the logical dynamic libra...
TargetMachine * getTargetMachine() override
Return the target machine (if available).
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter...
void addArchive(object::OwningBinary< object::Archive > O) override
addArchive - Add an Archive to the execution engine.
void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress) override
mapSectionAddress - map a section to its target address space value.
SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
uint64_t getSymbolAddress(const std::string &Name, bool CheckFunctionsOnly)
void RegisterJITEventListener(JITEventListener *L) override
Registers a listener to be called back on various events within the JIT.
A range adaptor for a pair of iterators.
Module * findModuleForSymbol(const std::string &Name, bool CheckFunctionsOnly)
GenericValue runFunction(Function *F, ArrayRef< GenericValue > ArgValues) override
runFunction - Execute the specified function with the specified arguments, and return the result...
std::unique_ptr< MemoryBuffer > emitObject(Module *M)
emitObject – Generate a JITed object in memory from the specified module Currently, MCJIT only supports a single module and the module passed to this function call is expected to be the contained module.
This is the base ObjectCache type which can be provided to an ExecutionEngine for the purpose of avoi...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void NotifyFreeingObject(const object::ObjectFile &Obj)
Primary interface to the complete machine description for the target machine.
StringRef - Represent a constant reference to a string, i.e.
void NotifyObjectEmitted(const object::ObjectFile &Obj, const RuntimeDyld::LoadedObjectInfo &L)
void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress)
Map a section to its target address space value.
void finalizeLoadedModules()
void addObjectFile(std::unique_ptr< object::ObjectFile > O) override
addObjectFile - Add an ObjectFile to the execution engine.