9 #ifndef LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H 10 #define LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H 31 std::shared_ptr<LegacyJITSymbolResolver>
Resolver)
32 : ParentEngine(Parent), ClientResolver(
std::move(Resolver)) {}
43 std::shared_ptr<LegacyJITSymbolResolver> ClientResolver;
44 void anchor()
override;
68 MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
69 std::shared_ptr<MCJITMemoryManager> MemMgr,
70 std::shared_ptr<LegacyJITSymbolResolver>
Resolver);
74 class OwningModuleContainer {
76 OwningModuleContainer() {
78 ~OwningModuleContainer() {
79 freeModulePtrSet(AddedModules);
80 freeModulePtrSet(LoadedModules);
81 freeModulePtrSet(FinalizedModules);
84 ModulePtrSet::iterator begin_added() {
return AddedModules.begin(); }
85 ModulePtrSet::iterator end_added() {
return AddedModules.end(); }
90 ModulePtrSet::iterator begin_loaded() {
return LoadedModules.begin(); }
91 ModulePtrSet::iterator end_loaded() {
return LoadedModules.end(); }
93 ModulePtrSet::iterator begin_finalized() {
return FinalizedModules.begin(); }
94 ModulePtrSet::iterator end_finalized() {
return FinalizedModules.end(); }
96 void addModule(std::unique_ptr<Module> M) {
97 AddedModules.insert(M.release());
100 bool removeModule(
Module *M) {
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() {
155 for (ModulePtrSet::iterator
I = LoadedModules.begin(),
156 E = LoadedModules.end();
159 FinalizedModules.insert(M);
161 LoadedModules.clear();
165 ModulePtrSet AddedModules;
166 ModulePtrSet LoadedModules;
167 ModulePtrSet FinalizedModules;
169 void freeModulePtrSet(ModulePtrSet& MPS) {
171 for (ModulePtrSet::iterator
I = MPS.
begin(),
E = MPS.
end();
I !=
E; ++
I) {
179 std::unique_ptr<TargetMachine>
TM;
181 std::shared_ptr<MCJITMemoryManager> MemMgr;
184 std::vector<JITEventListener*> EventListeners;
186 OwningModuleContainer OwnedModules;
198 ModulePtrSet::iterator
I,
199 ModulePtrSet::iterator
E);
203 ModulePtrSet::iterator I,
204 ModulePtrSet::iterator E);
206 void runStaticConstructorsDestructorsInModulePtrSet(
bool isDtors,
207 ModulePtrSet::iterator I,
208 ModulePtrSet::iterator E);
215 void addModule(std::unique_ptr<Module> M)
override;
216 void addObjectFile(std::unique_ptr<object::ObjectFile>
O)
override;
219 bool removeModule(
Module *M)
override;
230 bool AllowInternal =
false)
override;
233 void setObjectCache(
ObjectCache *manager)
override;
239 void generateCodeForModule(
Module *M)
override;
250 void finalizeObject()
override;
251 virtual void finalizeModule(
Module *);
252 void finalizeLoadedModules();
258 void runStaticConstructorsDestructors(
bool isDtors)
override;
260 void *getPointerToFunction(
Function *
F)
override;
273 void *getPointerToNamedFunction(
StringRef Name,
274 bool AbortOnFailure =
true)
override;
281 uint64_t TargetAddress)
override {
290 uint64_t getGlobalValueAddress(
const std::string &Name)
override;
291 uint64_t getFunctionAddress(
const std::string &Name)
override;
300 MCJITCtor = createJIT;
304 createJIT(std::unique_ptr<Module> M, std::string *ErrorStr,
305 std::shared_ptr<MCJITMemoryManager> MemMgr,
306 std::shared_ptr<LegacyJITSymbolResolver> Resolver,
307 std::unique_ptr<TargetMachine> TM);
322 uint64_t getSymbolAddress(
const std::string &Name,
323 bool CheckFunctionsOnly);
331 std::unique_ptr<MemoryBuffer> emitObject(
Module *M);
337 JITSymbol findExistingSymbol(
const std::string &Name);
338 Module *findModuleForSymbol(
const std::string &Name,
bool CheckFunctionsOnly);
343 #endif // LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H Information about the loaded object.
Represents a symbol in the JIT.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
JITEventListener - Abstract interface for use by the JIT to notify clients about significant events d...
Legacy symbol resolution interface.
This class is the base class for all object file types.
Context object for machine code objects.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
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.
void setProcessAllSections(bool ProcessAllSections) override
setProcessAllSections (MCJIT Only): By default, only sections that are "required for execution" are p...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
LinkingSymbolResolver(MCJIT &Parent, std::shared_ptr< LegacyJITSymbolResolver > Resolver)
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 mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress) override
mapSectionAddress - map a section to its target address space value.
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.
A range adaptor for a pair of iterators.
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())
Primary interface to the complete machine description for the target machine.
StringRef - Represent a constant reference to a string, i.e.
void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress)
Map a section to its target address space value.