10 #ifndef LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H 11 #define LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H 32 std::shared_ptr<LegacyJITSymbolResolver>
Resolver)
33 : ParentEngine(Parent), ClientResolver(
std::move(Resolver)) {}
44 std::shared_ptr<LegacyJITSymbolResolver> ClientResolver;
45 void anchor()
override;
69 MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
70 std::shared_ptr<MCJITMemoryManager> MemMgr,
71 std::shared_ptr<LegacyJITSymbolResolver>
Resolver);
75 class OwningModuleContainer {
77 OwningModuleContainer() {
79 ~OwningModuleContainer() {
80 freeModulePtrSet(AddedModules);
81 freeModulePtrSet(LoadedModules);
82 freeModulePtrSet(FinalizedModules);
85 ModulePtrSet::iterator begin_added() {
return AddedModules.begin(); }
86 ModulePtrSet::iterator end_added() {
return AddedModules.end(); }
91 ModulePtrSet::iterator begin_loaded() {
return LoadedModules.begin(); }
92 ModulePtrSet::iterator end_loaded() {
return LoadedModules.end(); }
94 ModulePtrSet::iterator begin_finalized() {
return FinalizedModules.begin(); }
95 ModulePtrSet::iterator end_finalized() {
return FinalizedModules.end(); }
97 void addModule(std::unique_ptr<Module> M) {
98 AddedModules.insert(M.release());
101 bool removeModule(
Module *M) {
102 return AddedModules.erase(M) || LoadedModules.erase(M) ||
103 FinalizedModules.erase(M);
106 bool hasModuleBeenAddedButNotLoaded(
Module *M) {
107 return AddedModules.count(M) != 0;
110 bool hasModuleBeenLoaded(
Module *M) {
113 return (LoadedModules.count(M) != 0 ) || (FinalizedModules.count(M) != 0);
116 bool hasModuleBeenFinalized(
Module *M) {
117 return FinalizedModules.count(M) != 0;
120 bool ownsModule(
Module* M) {
121 return (AddedModules.count(M) != 0) || (LoadedModules.count(M) != 0) ||
122 (FinalizedModules.count(M) != 0);
125 void markModuleAsLoaded(
Module *M) {
129 assert(AddedModules.count(M) &&
130 "markModuleAsLoaded: Module not found in AddedModules");
133 AddedModules.erase(M);
136 LoadedModules.insert(M);
139 void markModuleAsFinalized(
Module *M) {
144 assert(LoadedModules.count(M) &&
145 "markModuleAsFinalized: Module not found in LoadedModules");
148 LoadedModules.erase(M);
152 FinalizedModules.insert(M);
155 void markAllLoadedModulesAsFinalized() {
156 for (ModulePtrSet::iterator
I = LoadedModules.begin(),
157 E = LoadedModules.end();
160 FinalizedModules.insert(M);
162 LoadedModules.clear();
166 ModulePtrSet AddedModules;
167 ModulePtrSet LoadedModules;
168 ModulePtrSet FinalizedModules;
170 void freeModulePtrSet(ModulePtrSet& MPS) {
172 for (ModulePtrSet::iterator
I = MPS.
begin(),
E = MPS.
end();
I !=
E; ++
I) {
180 std::unique_ptr<TargetMachine>
TM;
182 std::shared_ptr<MCJITMemoryManager> MemMgr;
185 std::vector<JITEventListener*> EventListeners;
187 OwningModuleContainer OwnedModules;
199 ModulePtrSet::iterator
I,
200 ModulePtrSet::iterator
E);
204 ModulePtrSet::iterator I,
205 ModulePtrSet::iterator E);
207 void runStaticConstructorsDestructorsInModulePtrSet(
bool isDtors,
208 ModulePtrSet::iterator I,
209 ModulePtrSet::iterator E);
216 void addModule(std::unique_ptr<Module> M)
override;
217 void addObjectFile(std::unique_ptr<object::ObjectFile>
O)
override;
220 bool removeModule(
Module *M)
override;
231 bool AllowInternal =
false)
override;
234 void setObjectCache(
ObjectCache *manager)
override;
240 void generateCodeForModule(
Module *M)
override;
251 void finalizeObject()
override;
252 virtual void finalizeModule(
Module *);
253 void finalizeLoadedModules();
259 void runStaticConstructorsDestructors(
bool isDtors)
override;
261 void *getPointerToFunction(
Function *
F)
override;
274 void *getPointerToNamedFunction(
StringRef Name,
275 bool AbortOnFailure =
true)
override;
282 uint64_t TargetAddress)
override {
291 uint64_t getGlobalValueAddress(
const std::string &Name)
override;
292 uint64_t getFunctionAddress(
const std::string &Name)
override;
301 MCJITCtor = createJIT;
305 createJIT(std::unique_ptr<Module> M, std::string *ErrorStr,
306 std::shared_ptr<MCJITMemoryManager> MemMgr,
307 std::shared_ptr<LegacyJITSymbolResolver> Resolver,
308 std::unique_ptr<TargetMachine> TM);
323 uint64_t getSymbolAddress(
const std::string &Name,
324 bool CheckFunctionsOnly);
332 std::unique_ptr<MemoryBuffer> emitObject(
Module *M);
338 JITSymbol findExistingSymbol(
const std::string &Name);
339 Module *findModuleForSymbol(
const std::string &Name,
bool CheckFunctionsOnly);
344 #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. ...
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.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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.