15 #ifndef LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
16 #define LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
40 class ExecutionEngine;
44 class JITEventListener;
45 class MachineCodeInfo;
46 class MCJITMemoryManager;
49 class RTDyldMemoryManager;
74 std::map<uint64_t, std::string> GlobalAddressReverseMap;
79 return GlobalAddressMap;
83 return GlobalAddressReverseMap;
114 bool CompilingLazily;
117 bool GVCompilationDisabled;
121 bool SymbolSearchingDisabled;
137 std::unique_ptr<Module> M,
138 std::string *ErrorStr,
139 std::shared_ptr<MCJITMemoryManager> MM,
140 std::shared_ptr<JITSymbolResolver> SR,
141 std::unique_ptr<TargetMachine>
TM);
144 std::string *ErrorStr,
145 std::shared_ptr<MCJITMemoryManager> MM,
146 std::shared_ptr<JITSymbolResolver> SR,
147 std::unique_ptr<TargetMachine>
TM);
150 std::string *ErrorStr);
173 Modules.push_back(std::move(M));
186 virtual void addObjectFile(std::unique_ptr<object::ObjectFile> O);
241 bool AbortOnFailure =
true) = 0;
248 uint64_t TargetAddress) {
296 const char *
const * envp);
450 CompilingLazily = !Disabled;
453 return CompilingLazily;
460 GVCompilationDisabled = Disabled;
463 return GVCompilationDisabled;
470 SymbolSearchingDisabled = Disabled;
473 return SymbolSearchingDisabled;
484 return VerifyModules;
508 void Init(std::unique_ptr<Module> M);
511 namespace EngineKind {
525 std::unique_ptr<Module> M;
527 std::string *ErrorStr;
529 std::shared_ptr<MCJITMemoryManager> MemMgr;
530 std::shared_ptr<JITSymbolResolver> Resolver;
538 bool UseOrcMCJITReplacement;
609 MArch.assign(march.
begin(), march.
end());
615 MCPU.assign(mcpu.
begin(), mcpu.
end());
627 template<
typename StringSequence>
630 MAttrs.
append(mattrs.begin(), mattrs.end());
636 this->UseOrcMCJITReplacement = UseOrcMCJITReplacement;
A parsed version of the target data layout string in and methods for querying it. ...
virtual void * getOrEmitGlobalVariable(const GlobalVariable *GV)
getOrEmitGlobalVariable - Return the address of the specified global variable, possibly emitting it t...
std::string getMangledName(const GlobalValue *GV)
getMangledName - Get mangled name.
void clearAllGlobalMappings()
clearAllGlobalMappings - Clear all global mappings and start over again, for use in dynamic compilati...
struct LLVMOpaqueExecutionEngine * LLVMExecutionEngineRef
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...
A Module instance is used to store all the information related to an LLVM module. ...
virtual bool removeModule(Module *M)
removeModule - Removes a Module from the list of modules, but does not free the module's memory...
void * getPointerToGlobalIfAvailable(StringRef S)
getPointerToGlobalIfAvailable - This returns the address of the specified global value if it is has a...
sys::Mutex lock
lock - This lock protects the ExecutionEngine and MCJIT classes.
uint64_t updateGlobalMapping(const GlobalValue *GV, void *Addr)
updateGlobalMapping - Replace an existing mapping for GV with a new address.
JITEventListener - Abstract interface for use by the JIT to notify clients about significant events d...
virtual GenericValue runFunction(Function *F, ArrayRef< GenericValue > ArgValues)=0
runFunction - Execute the specified function with the specified arguments, and return the result...
virtual void setObjectCache(ObjectCache *)
Sets the pre-compiled object cache.
void EmitGlobalVariable(const GlobalVariable *GV)
virtual void * getPointerToFunctionOrStub(Function *F)
getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the f...
virtual void RegisterJITEventListener(JITEventListener *)
Registers a listener to be called back on various events within the JIT.
EngineBuilder & setMArch(StringRef march)
setMArch - Override the architecture set by the Module's triple.
EngineBuilder & setSymbolResolver(std::unique_ptr< JITSymbolResolver > SR)
const DataLayout & getDataLayout() const
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
ppc ctr loops PowerPC CTR Loops Verify
virtual void runStaticConstructorsDestructors(bool isDtors)
runStaticConstructorsDestructors - This method is used to execute all of the static constructors or d...
void * getPointerToGlobal(const GlobalValue *GV)
getPointerToGlobal - This returns the address of the specified global value.
void InitializeMemory(const Constant *Init, void *Addr)
EngineBuilder()
Default constructor for EngineBuilder.
EngineBuilder & setVerifyModules(bool Verify)
setVerifyModules - Set whether the JIT implementation should verify IR modules during compilation...
virtual void addModule(std::unique_ptr< Module > M)
Add a Module to the list of modules that we can JIT from.
virtual char * getMemoryForGV(const GlobalVariable *GV)
getMemoryforGV - Allocate memory for a global variable.
void LoadValueFromMemory(GenericValue &Result, GenericValue *Ptr, Type *Ty)
FIXME: document.
std::function< void *(const std::string &)> FunctionCreator
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
virtual void finalizeObject()
finalizeObject - ensure the module is fully processed and is usable.
EngineBuilder & setCodeModel(CodeModel::Model M)
setCodeModel - Set the CodeModel that the ExecutionEngine target data is using.
GenericValue getConstantValue(const Constant *C)
Converts a Constant* into a GenericValue, including handling of ConstantExpr values.
void emitGlobals()
EmitGlobals - Emit all of the global variables to memory, storing their addresses into GlobalAddress...
uint64_t RemoveMapping(StringRef Name)
Erase an entry from the mapping table.
void StoreValueToMemory(const GenericValue &Val, GenericValue *Ptr, Type *Ty)
StoreValueToMemory - Stores the data in Val of type Ty at address Ptr.
StringMap< uint64_t > GlobalAddressMapTy
EngineBuilder & setEngineKind(EngineKind::Kind w)
setEngineKind - Controls whether the user wants the interpreter, the JIT, or whichever engine works...
virtual void generateCodeForModule(Module *M)
generateCodeForModule - Run code generation for the specified module and load it into memory...
bool isGVCompilationDisabled() const
bool isCompilingLazily() const
void setUseOrcMCJITReplacement(bool UseOrcMCJITReplacement)
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important base class in LLVM.
EngineBuilder & setErrorStr(std::string *e)
setErrorStr - Set the error string to write to on error.
bool isSymbolSearchingDisabled() const
EngineBuilder & setMemoryManager(std::unique_ptr< MCJITMemoryManager > MM)
virtual void addObjectFile(std::unique_ptr< object::ObjectFile > O)
addObjectFile - Add an ObjectFile to the execution engine.
EngineBuilder & setMAttrs(const StringSequence &mattrs)
setMAttrs - Set cpu-specific attributes.
GlobalAddressMapTy & getGlobalAddressMap()
void InstallLazyFunctionCreator(FunctionCreator C)
InstallLazyFunctionCreator - If an unknown function is needed, the specified function pointer is invo...
bool getVerifyModules() const
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
void clearGlobalMappingsFromModule(Module *M)
clearGlobalMappingsFromModule - Clear all global mappings that came from a particular module...
virtual Function * FindFunctionNamed(StringRef FnName)
FindFunctionNamed - Search all of the active modules to find the function that defines FnName...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter...
Triple - Helper class for working with autoconf configuration names.
std::map< uint64_t, std::string > & getGlobalAddressReverseMap()
ExecutionEngine(DataLayout DL)
void DisableSymbolSearching(bool Disabled=true)
DisableSymbolSearching - If called, the JIT will not try to lookup unknown symbols with dlsym...
EngineBuilder & setRelocationModel(Reloc::Model RM)
setRelocationModel - Set the relocation model that the ExecutionEngine target is using.
EngineBuilder & setTargetOptions(const TargetOptions &Opts)
setTargetOptions - Set the target options that the ExecutionEngine target is using.
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.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
virtual void setProcessAllSections(bool ProcessAllSections)
setProcessAllSections (MCJIT Only): By default, only sections that are "required for execution" are p...
void setVerifyModules(bool Verify)
Enable/Disable IR module verification.
virtual void addArchive(object::OwningBinary< object::Archive > A)
addArchive - Add an Archive to the execution engine.
virtual void * getPointerToFunction(Function *F)=0
getPointerToFunction - The different EE's represent function bodies in different ways.
void DisableLazyCompilation(bool Disabled=true)
DisableLazyCompilation - When lazy compilation is off (the default), the JIT will eagerly compile eve...
SmallVector< std::unique_ptr< Module >, 1 > Modules
The list of Modules that we are JIT'ing from.
virtual ~ExecutionEngine()
ExecutionEngine * create()
void addGlobalMapping(const GlobalValue *GV, void *Addr)
addGlobalMapping - Tell the execution engine that the specified global is at the specified location...
uint64_t getAddressToGlobalIfAvailable(StringRef S)
getAddressToGlobalIfAvailable - This returns the address of the specified global symbol.
This is the base ObjectCache type which can be provided to an ExecutionEngine for the purpose of avoi...
const GlobalValue * getGlobalValueAtAddress(void *Addr)
getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address...
Helper class for helping synchronize access to the global address map table.
Builder class for ExecutionEngines.
EngineBuilder & setMCJITMemoryManager(std::unique_ptr< RTDyldMemoryManager > mcjmm)
setMCJITMemoryManager - Sets the MCJIT memory manager to use.
virtual void * getPointerToNamedFunction(StringRef Name, bool AbortOnFailure=true)=0
getPointerToNamedFunction - This method returns the address of the specified function by using the dl...
virtual void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress)
mapSectionAddress - map a section to its target address space value.
virtual TargetMachine * getTargetMachine()
Return the target machine (if available).
TargetMachine * selectTarget()
FunctionCreator LazyFunctionCreator
LazyFunctionCreator - If an unknown function is needed, this function pointer is invoked to create it...
Primary interface to the complete machine description for the target machine.
void DisableGVCompilation(bool Disabled=true)
DisableGVCompilation - If called, the JIT will abort if it's asked to allocate space and populate a G...
virtual uint64_t getFunctionAddress(const std::string &Name)
getFunctionAddress - Return the address of the specified function.
StringRef - Represent a constant reference to a string, i.e.
virtual void UnregisterJITEventListener(JITEventListener *)
virtual uint64_t getGlobalValueAddress(const std::string &Name)
getGlobalValueAddress - Return the address of the specified global value.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
EngineBuilder & setOptLevel(CodeGenOpt::Level l)
setOptLevel - Set the optimization level for the JIT.
virtual GlobalVariable * FindGlobalVariableNamed(StringRef Name, bool AllowInternal=false)
FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines N...
EngineBuilder & setMCPU(StringRef mcpu)
setMCPU - Target a specific cpu type.