14#ifndef LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
15#define LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
48class JITEventListener;
49class MCJITMemoryManager;
51class RTDyldMemoryManager;
77 std::map<uint64_t, std::string> GlobalAddressReverseMap;
81 return GlobalAddressMap;
85 return GlobalAddressReverseMap;
116 bool CompilingLazily;
119 bool GVCompilationDisabled;
123 bool SymbolSearchingDisabled;
139 std::unique_ptr<Module> M, std::string *ErrorStr,
140 std::shared_ptr<MCJITMemoryManager> MM,
141 std::shared_ptr<LegacyJITSymbolResolver> SR,
142 std::unique_ptr<TargetMachine> TM);
145 std::string *ErrorStr);
170 Modules.push_back(std::move(M));
183 virtual void addObjectFile(std::unique_ptr<object::ObjectFile> O);
238 bool AbortOnFailure =
true) = 0;
305 const char *
const * envp);
462 return CompilingLazily;
472 return GVCompilationDisabled;
482 return SymbolSearchingDisabled;
493 return VerifyModules;
517 void Init(std::unique_ptr<Module> M);
520namespace EngineKind {
536 std::unique_ptr<Module> M;
538 std::string *ErrorStr;
540 std::shared_ptr<MCJITMemoryManager> MemMgr;
541 std::shared_ptr<LegacyJITSymbolResolver>
Resolver;
543 std::optional<Reloc::Model> RelocModel;
544 std::optional<CodeModel::Model> CMModel;
549 bool EmulatedTLS =
true;
619 MArch.assign(march.
begin(), march.
end());
625 MCPU.assign(mcpu.
begin(), mcpu.
end());
637 template<
typename StringSequence>
640 MAttrs.
append(mattrs.begin(), mattrs.end());
645 this->EmulatedTLS = EmulatedTLS;
This file defines the StringMap class.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#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.
EngineBuilder & setMCJITMemoryManager(std::unique_ptr< RTDyldMemoryManager > mcjmm)
setMCJITMemoryManager - Sets the MCJIT memory manager to use.
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.
EngineBuilder & setSymbolResolver(std::unique_ptr< LegacyJITSymbolResolver > SR)
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.
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()
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.
void StoreValueToMemory(const GenericValue &Val, GenericValue *Ptr, Type *Ty)
StoreValueToMemory - Stores the data in Val of type Ty at address Ptr.
GenericValue getConstantValue(const Constant *C)
Converts a Constant* into a GenericValue, including handling of ConstantExpr values.
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 * getPointerToGlobalIfAvailable(StringRef S)
getPointerToGlobalIfAvailable - This returns the address of the specified global value if it is has a...
void clearAllGlobalMappings()
clearAllGlobalMappings - Clear all global mappings and start over again, for use in dynamic compilati...
virtual void addArchive(object::OwningBinary< object::Archive > A)
addArchive - Add an Archive to the execution engine.
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.
void InitializeMemory(const Constant *Init, void *Addr)
virtual void * getPointerToFunctionOrStub(Function *F)
getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the f...
std::string getMangledName(const GlobalValue *GV)
getMangledName - Get mangled name.
virtual bool removeModule(Module *M)
removeModule - Removes a Module from the list of modules, but does not free the module's memory.
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.
virtual void runStaticConstructorsDestructors(bool isDtors)
runStaticConstructorsDestructors - This method is used to execute all of the static constructors or d...
FunctionCreator LazyFunctionCreator
LazyFunctionCreator - If an unknown function is needed, this function pointer is invoked to create it...
void addGlobalMapping(const GlobalValue *GV, void *Addr)
addGlobalMapping - Tell the execution engine that the specified global is at the specified location.
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.
const GlobalValue * getGlobalValueAtAddress(void *Addr)
getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address.
ExecutionEngine(DataLayout DL)
void clearGlobalMappingsFromModule(Module *M)
clearGlobalMappingsFromModule - Clear all global mappings that came from a particular module,...
void InstallLazyFunctionCreator(FunctionCreator C)
InstallLazyFunctionCreator - If an unknown function is needed, the specified function pointer is invo...
void * getPointerToGlobal(const GlobalValue *GV)
getPointerToGlobal - This returns the address of the specified global value.
virtual uint64_t getGlobalValueAddress(const std::string &Name)
getGlobalValueAddress - Return the address of the specified global value.
int runFunctionAsMain(Function *Fn, const std::vector< std::string > &argv, const char *const *envp)
runFunctionAsMain - This is a helper function which wraps runFunction to handle the common task of st...
virtual void addObjectFile(std::unique_ptr< object::ObjectFile > O)
addObjectFile - Add an ObjectFile to the execution engine.
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.
uint64_t getAddressToGlobalIfAvailable(StringRef S)
getAddressToGlobalIfAvailable - This returns the address of the specified global symbol.
void emitGlobalVariable(const GlobalVariable *GV)
virtual void UnregisterJITEventListener(JITEventListener *)
virtual void setObjectCache(ObjectCache *)
Sets the pre-compiled object cache.
virtual GlobalVariable * FindGlobalVariableNamed(StringRef Name, bool AllowInternal=false)
FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines N...
virtual GenericValue runFunction(Function *F, ArrayRef< GenericValue > ArgValues)=0
runFunction - Execute the specified function with the specified arguments, and return the result.
void emitGlobals()
EmitGlobals - Emit all of the global variables to memory, storing their addresses into GlobalAddress.
void LoadValueFromMemory(GenericValue &Result, GenericValue *Ptr, Type *Ty)
FIXME: document.
bool isGVCompilationDisabled() const
uint64_t updateGlobalMapping(const GlobalValue *GV, void *Addr)
updateGlobalMapping - Replace an existing mapping for GV with a new address.
virtual char * getMemoryForGV(const GlobalVariable *GV)
getMemoryforGV - Allocate memory for a global variable.
virtual ~ExecutionEngine()
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 Function * FindFunctionNamed(StringRef FnName)
FindFunctionNamed - Search all of the active modules to find the function that defines FnName.
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.
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.
@ C
The default llvm calling convention, compatible with C.
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.