14#ifndef LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
15#define LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
49class JITEventListener;
50class MCJITMemoryManager;
52class RTDyldMemoryManager;
78 std::map<uint64_t, std::string> GlobalAddressReverseMap;
82 return GlobalAddressMap;
86 return GlobalAddressReverseMap;
117 bool CompilingLazily;
120 bool GVCompilationDisabled;
124 bool SymbolSearchingDisabled;
140 std::unique_ptr<Module> M, std::string *ErrorStr,
141 std::shared_ptr<MCJITMemoryManager> MM,
142 std::shared_ptr<LegacyJITSymbolResolver> SR,
143 std::unique_ptr<TargetMachine> TM);
146 std::string *ErrorStr);
184 virtual void addObjectFile(std::unique_ptr<object::ObjectFile> O);
205 virtual bool removeModule(
Module *M);
239 bool AbortOnFailure =
true) = 0;
293 virtual void runStaticConstructorsDestructors(
bool isDtors);
299 void runStaticConstructorsDestructors(
Module &module,
bool isDtors);
305 int runFunctionAsMain(
Function *Fn,
const std::vector<std::string> &argv,
306 const char *
const * envp);
321 void clearAllGlobalMappings();
325 void clearGlobalMappingsFromModule(
Module *M);
341 void *getPointerToGlobalIfAvailable(
StringRef S);
342 void *getPointerToGlobalIfAvailable(
const GlobalValue *GV);
370 return getPointerToFunction(
F);
412 return getPointerToGlobal((
const GlobalValue *)GV);
460 CompilingLazily = !Disabled;
463 return CompilingLazily;
470 GVCompilationDisabled = Disabled;
473 return GVCompilationDisabled;
480 SymbolSearchingDisabled = Disabled;
483 return SymbolSearchingDisabled;
494 return VerifyModules;
501 LazyFunctionCreator = std::move(
C);
518 void Init(std::unique_ptr<Module> M);
521namespace EngineKind {
537 std::unique_ptr<Module> M;
539 std::string *ErrorStr;
541 std::shared_ptr<MCJITMemoryManager> MemMgr;
542 std::shared_ptr<LegacyJITSymbolResolver>
Resolver;
544 std::optional<Reloc::Model> RelocModel;
545 std::optional<CodeModel::Model> CMModel;
550 bool EmulatedTLS =
true;
622 MArch.assign(march.
begin(), march.
end());
628 MCPU.assign(mcpu.
begin(), mcpu.
end());
640 template<
typename StringSequence>
643 MAttrs.
append(mattrs.begin(), mattrs.end());
648 this->EmulatedTLS = EmulatedTLS;
This file defines the StringMap class.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
Module.h This file contains the declarations for the Module class.
ppc ctr loops PowerPC CTR Loops Verify
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
Builder class for ExecutionEngines.
EngineBuilder & setTargetOptions(const TargetOptions &Opts)
setTargetOptions - Set the target options that the ExecutionEngine target is using.
LLVM_ABI EngineBuilder & setMCJITMemoryManager(std::unique_ptr< RTDyldMemoryManager > mcjmm)
setMCJITMemoryManager - Sets the MCJIT memory manager to use.
LLVM_ABI EngineBuilder()
Default constructor for EngineBuilder.
EngineBuilder & setMArch(StringRef march)
setMArch - Override the architecture set by the Module's triple.
EngineBuilder & setCodeModel(CodeModel::Model M)
setCodeModel - Set the CodeModel that the ExecutionEngine target data is using.
EngineBuilder & setOptLevel(CodeGenOptLevel l)
setOptLevel - Set the optimization level for the JIT.
LLVM_ABI EngineBuilder & setSymbolResolver(std::unique_ptr< LegacyJITSymbolResolver > SR)
LLVM_ABI ~EngineBuilder()
LLVM_ABI TargetMachine * selectTarget()
EngineBuilder & setErrorStr(std::string *e)
setErrorStr - Set the error string to write to on error.
EngineBuilder & setVerifyModules(bool Verify)
setVerifyModules - Set whether the JIT implementation should verify IR modules during compilation.
EngineBuilder & setEngineKind(EngineKind::Kind w)
setEngineKind - Controls whether the user wants the interpreter, the JIT, or whichever engine works.
LLVM_ABI EngineBuilder & setMemoryManager(std::unique_ptr< MCJITMemoryManager > MM)
ExecutionEngine * create()
EngineBuilder & setRelocationModel(Reloc::Model RM)
setRelocationModel - Set the relocation model that the ExecutionEngine target is using.
void setEmulatedTLS(bool EmulatedTLS)
EngineBuilder & setMAttrs(const StringSequence &mattrs)
setMAttrs - Set cpu-specific attributes.
EngineBuilder & setMCPU(StringRef mcpu)
setMCPU - Target a specific cpu type.
Helper class for helping synchronize access to the global address map table.
std::map< uint64_t, std::string > & getGlobalAddressReverseMap()
LLVM_ABI uint64_t RemoveMapping(StringRef Name)
Erase an entry from the mapping table.
GlobalAddressMapTy & getGlobalAddressMap()
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter...
void setVerifyModules(bool Verify)
Enable/Disable IR module verification.
bool isCompilingLazily() const
virtual void setProcessAllSections(bool ProcessAllSections)
setProcessAllSections (MCJIT Only): By default, only sections that are "required for execution" are p...
const DataLayout & getDataLayout() const
bool getVerifyModules() const
void DisableGVCompilation(bool Disabled=true)
DisableGVCompilation - If called, the JIT will abort if it's asked to allocate space and populate a G...
const std::string & getErrorMessage() const
Returns the most recent error message.
void clearErrorMessage()
Clear the error message.
virtual void * getPointerToFunctionOrStub(Function *F)
getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the f...
void DisableLazyCompilation(bool Disabled=true)
DisableLazyCompilation - When lazy compilation is off (the default), the JIT will eagerly compile eve...
virtual void * getPointerToFunction(Function *F)=0
getPointerToFunction - The different EE's represent function bodies in different ways.
virtual uint64_t getFunctionAddress(const std::string &Name)
getFunctionAddress - Return the address of the specified function.
sys::Mutex lock
lock - This lock protects the ExecutionEngine and MCJIT classes.
virtual void addModule(std::unique_ptr< Module > M)
Add a Module to the list of modules that we can JIT from.
virtual void generateCodeForModule(Module *M)
generateCodeForModule - Run code generation for the specified module and load it into memory.
FunctionCreator LazyFunctionCreator
LazyFunctionCreator - If an unknown function is needed, this function pointer is invoked to create it...
bool hasError() const
Returns true if an error has been recorded.
SmallVector< std::unique_ptr< Module >, 1 > Modules
The list of Modules that we are JIT'ing from.
virtual void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress)
mapSectionAddress - map a section to its target address space value.
ExecutionEngine(DataLayout DL)
void InstallLazyFunctionCreator(FunctionCreator C)
InstallLazyFunctionCreator - If an unknown function is needed, the specified function pointer is invo...
virtual uint64_t getGlobalValueAddress(const std::string &Name)
getGlobalValueAddress - Return the address of the specified global value.
virtual void * getOrEmitGlobalVariable(const GlobalVariable *GV)
getOrEmitGlobalVariable - Return the address of the specified global variable, possibly emitting it t...
virtual TargetMachine * getTargetMachine()
Return the target machine (if available).
virtual void finalizeObject()
finalizeObject - ensure the module is fully processed and is usable.
virtual void UnregisterJITEventListener(JITEventListener *)
virtual void setObjectCache(ObjectCache *)
Sets the pre-compiled object cache.
virtual GenericValue runFunction(Function *F, ArrayRef< GenericValue > ArgValues)=0
runFunction - Execute the specified function with the specified arguments, and return the result.
bool isGVCompilationDisabled() const
virtual void * getPointerToNamedFunction(StringRef Name, bool AbortOnFailure=true)=0
getPointerToNamedFunction - This method returns the address of the specified function by using the dl...
void DisableSymbolSearching(bool Disabled=true)
DisableSymbolSearching - If called, the JIT will not try to lookup unknown symbols with dlsym.
bool isSymbolSearchingDisabled() const
virtual void RegisterJITEventListener(JITEventListener *)
Registers a listener to be called back on various events within the JIT.
JITEventListener - Abstract interface for use by the JIT to notify clients about significant events d...
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.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
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.
Triple - Helper class for working with autoconf configuration names.
The instances of the Type class are immutable: once they are created, they are never changed.
struct LLVMOpaqueExecutionEngine * LLVMExecutionEngineRef
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
CodeGenOptLevel
Code generation optimization level.
std::function< void *(const std::string &)> FunctionCreator
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.