9#ifndef LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H
10#define LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H
30 std::shared_ptr<LegacyJITSymbolResolver>
Resolver)
42 std::shared_ptr<LegacyJITSymbolResolver> ClientResolver;
43 void anchor()
override;
67 MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
68 std::shared_ptr<MCJITMemoryManager> MemMgr,
69 std::shared_ptr<LegacyJITSymbolResolver>
Resolver);
73 class OwningModuleContainer {
75 OwningModuleContainer() =
default;
76 ~OwningModuleContainer() {
77 freeModulePtrSet(AddedModules);
78 freeModulePtrSet(LoadedModules);
79 freeModulePtrSet(FinalizedModules);
94 void addModule(std::unique_ptr<Module> M) {
95 AddedModules.insert(M.release());
98 bool removeModule(
Module *M) {
99 return AddedModules.erase(M) || LoadedModules.erase(M) ||
100 FinalizedModules.erase(M);
103 bool hasModuleBeenAddedButNotLoaded(
Module *M) {
104 return AddedModules.contains(M);
107 bool hasModuleBeenLoaded(
Module *M) {
110 return LoadedModules.contains(M) || FinalizedModules.contains(M);
113 bool hasModuleBeenFinalized(
Module *M) {
114 return FinalizedModules.contains(M);
117 bool ownsModule(
Module* M) {
118 return AddedModules.contains(M) || LoadedModules.contains(M) ||
119 FinalizedModules.contains(M);
122 void markModuleAsLoaded(
Module *M) {
126 assert(AddedModules.count(M) &&
127 "markModuleAsLoaded: Module not found in AddedModules");
130 AddedModules.erase(M);
133 LoadedModules.insert(M);
136 void markModuleAsFinalized(
Module *M) {
141 assert(LoadedModules.count(M) &&
142 "markModuleAsFinalized: Module not found in LoadedModules");
145 LoadedModules.erase(M);
149 FinalizedModules.insert(M);
152 void markAllLoadedModulesAsFinalized() {
153 for (
Module *M : LoadedModules)
154 FinalizedModules.insert(M);
155 LoadedModules.clear();
171 std::unique_ptr<TargetMachine> TM;
173 std::shared_ptr<MCJITMemoryManager> MemMgr;
176 std::vector<JITEventListener*> EventListeners;
178 OwningModuleContainer OwnedModules;
198 void runStaticConstructorsDestructorsInModulePtrSet(
bool isDtors,
207 void addModule(std::unique_ptr<Module> M)
override;
208 void addObjectFile(std::unique_ptr<object::ObjectFile> O)
override;
222 bool AllowInternal =
false)
override;
266 bool AbortOnFailure =
true)
override;
296 createJIT(std::unique_ptr<Module> M, std::string *ErrorStr,
297 std::shared_ptr<MCJITMemoryManager> MemMgr,
298 std::shared_ptr<LegacyJITSymbolResolver>
Resolver,
299 std::unique_ptr<TargetMachine> TM);
315 bool CheckFunctionsOnly);
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Machine Check Debug Module
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter...
static ExecutionEngine *(* MCJITCtor)(std::unique_ptr< Module > M, std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MM, std::shared_ptr< LegacyJITSymbolResolver > SR, std::unique_ptr< TargetMachine > TM)
JITEventListener - Abstract interface for use by the JIT to notify clients about significant events d...
Represents a symbol in the JIT.
Legacy symbol resolution interface.
LinkingSymbolResolver(MCJIT &Parent, std::shared_ptr< LegacyJITSymbolResolver > Resolver)
JITSymbol findSymbol(const std::string &Name) override
This method returns the address of the specified function or variable.
JITSymbol findSymbolInLogicalDylib(const std::string &Name) override
This method returns the address of the specified symbol if it exists within the logical dynamic libra...
Context object for machine code objects.
GenericValue runFunction(Function *F, ArrayRef< GenericValue > ArgValues) override
runFunction - Execute the specified function with the specified arguments, and return the result.
void setProcessAllSections(bool ProcessAllSections) override
setProcessAllSections (MCJIT Only): By default, only sections that are "required for execution" are p...
void * getPointerToNamedFunction(StringRef Name, bool AbortOnFailure=true) override
getPointerToNamedFunction - This method returns the address of the specified function by using the dl...
void RegisterJITEventListener(JITEventListener *L) override
Registers a listener to be called back on various events within the JIT.
static ExecutionEngine * createJIT(std::unique_ptr< Module > M, std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MemMgr, std::shared_ptr< LegacyJITSymbolResolver > Resolver, std::unique_ptr< TargetMachine > TM)
void runStaticConstructorsDestructors(bool isDtors) override
runStaticConstructorsDestructors - This method is used to execute all of the static constructors or d...
Module * findModuleForSymbol(const std::string &Name, bool CheckFunctionsOnly)
void addArchive(object::OwningBinary< object::Archive > O) override
addArchive - Add an Archive to the execution engine.
Function * FindFunctionNamed(StringRef FnName) override
FindFunctionNamed - Search all of the active modules to find the function that defines FnName.
void finalizeObject() override
finalizeObject - ensure the module is fully processed and is usable.
void finalizeLoadedModules()
void notifyObjectLoaded(const object::ObjectFile &Obj, const RuntimeDyld::LoadedObjectInfo &L)
void generateCodeForModule(Module *M) override
generateCodeForModule - Run code generation for the specified module and load it into memory.
uint64_t getFunctionAddress(const std::string &Name) override
getFunctionAddress - Return the address of the specified function.
void addObjectFile(std::unique_ptr< object::ObjectFile > O) override
addObjectFile - Add an ObjectFile to the execution engine.
std::unique_ptr< MemoryBuffer > emitObject(Module *M)
emitObject – Generate a JITed object in memory from the specified module Currently,...
TargetMachine * getTargetMachine() override
Return the target machine (if available).
void UnregisterJITEventListener(JITEventListener *L) override
bool removeModule(Module *M) override
removeModule - Removes a Module from the list of modules, but does not free the module's memory.
void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress) override
mapSectionAddress - map a section to its target address space value.
JITSymbol findExistingSymbol(const std::string &Name)
GlobalVariable * FindGlobalVariableNamed(StringRef Name, bool AllowInternal=false) override
FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines N...
uint64_t getGlobalValueAddress(const std::string &Name) override
getGlobalValueAddress - Return the address of the specified global value.
uint64_t getSymbolAddress(const std::string &Name, bool CheckFunctionsOnly)
void notifyFreeingObject(const object::ObjectFile &Obj)
virtual void finalizeModule(Module *)
JITSymbol findSymbol(const std::string &Name, bool CheckFunctionsOnly)
void * getPointerToFunction(Function *F) override
getPointerToFunction - The different EE's represent function bodies in different ways.
void setObjectCache(ObjectCache *manager) override
Sets the object manager that MCJIT should use to avoid compilation.
void addModule(std::unique_ptr< Module > M) override
Add a Module to the list of modules that we can JIT from.
A Module instance is used to store all the information related to an LLVM module.
This is the base ObjectCache type which can be provided to an ExecutionEngine for the purpose of avoi...
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Information about the loaded object.
void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress)
Map a section to its target address space value.
void setProcessAllSections(bool ProcessAllSections)
By default, only sections that are "required for execution" are passed to the RTDyldMemoryManager,...
SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
A range adaptor for a pair of iterators.
This class is the base class for all object file types.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.