Go to the documentation of this file.
14 #ifndef LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
15 #define LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
48 class JITEventListener;
49 class MCJITMemoryManager;
51 class 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);
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);
520 namespace 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;
669 #endif // LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
std::string getMangledName(const GlobalValue *GV)
getMangledName - Get mangled name.
This is an optimization pass for GlobalISel generic memory operations.
void setVerifyModules(bool Verify)
Enable/Disable IR module verification.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
virtual void * getPointerToFunctionOrStub(Function *F)
getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the f...
virtual ~ExecutionEngine()
A parsed version of the target data layout string in and methods for querying it.
ExecutionEngine * create()
uint64_t updateGlobalMapping(const GlobalValue *GV, void *Addr)
updateGlobalMapping - Replace an existing mapping for GV with a new address.
EngineBuilder & setCodeModel(CodeModel::Model M)
setCodeModel - Set the CodeModel that the ExecutionEngine target data is using.
EngineBuilder & setMCJITMemoryManager(std::unique_ptr< RTDyldMemoryManager > mcjmm)
setMCJITMemoryManager - Sets the MCJIT memory manager to use.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
struct LLVMOpaqueExecutionEngine * LLVMExecutionEngineRef
virtual void * getPointerToNamedFunction(StringRef Name, bool AbortOnFailure=true)=0
getPointerToNamedFunction - This method returns the address of the specified function by using the dl...
void clearGlobalMappingsFromModule(Module *M)
clearGlobalMappingsFromModule - Clear all global mappings that came from a particular module,...
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...
Triple - Helper class for working with autoconf configuration names.
void clearAllGlobalMappings()
clearAllGlobalMappings - Clear all global mappings and start over again, for use in dynamic compilati...
void emitGlobalVariable(const GlobalVariable *GV)
virtual TargetMachine * getTargetMachine()
Return the target machine (if available).
The instances of the Type class are immutable: once they are created, they are never changed.
bool isSymbolSearchingDisabled() const
Builder class for ExecutionEngines.
EngineBuilder & setTargetOptions(const TargetOptions &Opts)
setTargetOptions - Set the target options that the ExecutionEngine target is using.
This is the base ObjectCache type which can be provided to an ExecutionEngine for the purpose of avoi...
virtual void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress)
mapSectionAddress - map a section to its target address space value.
SmallVector< std::unique_ptr< Module >, 1 > Modules
The list of Modules that we are JIT'ing from.
void DisableSymbolSearching(bool Disabled=true)
DisableSymbolSearching - If called, the JIT will not try to lookup unknown symbols with dlsym.
void DisableGVCompilation(bool Disabled=true)
DisableGVCompilation - If called, the JIT will abort if it's asked to allocate space and populate a G...
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
ppc ctr loops PowerPC CTR Loops Verify
void StoreValueToMemory(const GenericValue &Val, GenericValue *Ptr, Type *Ty)
StoreValueToMemory - Stores the data in Val of type Ty at address Ptr.
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
sys::Mutex lock
lock - This lock protects the ExecutionEngine and MCJIT classes.
void LoadValueFromMemory(GenericValue &Result, GenericValue *Ptr, Type *Ty)
FIXME: document.
virtual void addObjectFile(std::unique_ptr< object::ObjectFile > O)
addObjectFile - Add an ObjectFile to the execution engine.
uint64_t getAddressToGlobalIfAvailable(StringRef S)
getAddressToGlobalIfAvailable - This returns the address of the specified global symbol.
bool isGVCompilationDisabled() const
bool getVerifyModules() const
virtual void generateCodeForModule(Module *M)
generateCodeForModule - Run code generation for the specified module and load it into memory.
virtual void addModule(std::unique_ptr< Module > M)
Add a Module to the list of modules that we can JIT from.
virtual void * getOrEmitGlobalVariable(const GlobalVariable *GV)
getOrEmitGlobalVariable - Return the address of the specified global variable, possibly emitting it t...
(vector float) vec_cmpeq(*A, *B) C
FunctionCreator LazyFunctionCreator
LazyFunctionCreator - If an unknown function is needed, this function pointer is invoked to create it...
virtual uint64_t getFunctionAddress(const std::string &Name)
getFunctionAddress - Return the address of the specified function.
virtual GlobalVariable * FindGlobalVariableNamed(StringRef Name, bool AllowInternal=false)
FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines N...
This requires reassociating to forms of expressions that are already something that reassoc doesn t think about yet These two functions should generate the same code on big endian int * l
EngineBuilder & setErrorStr(std::string *e)
setErrorStr - Set the error string to write to on error.
virtual Function * FindFunctionNamed(StringRef FnName)
FindFunctionNamed - Search all of the active modules to find the function that defines FnName.
void DisableLazyCompilation(bool Disabled=true)
DisableLazyCompilation - When lazy compilation is off (the default), the JIT will eagerly compile eve...
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
uint64_t RemoveMapping(StringRef Name)
Erase an entry from the mapping table.
GenericValue getConstantValue(const Constant *C)
Converts a Constant* into a GenericValue, including handling of ConstantExpr values.
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
EngineBuilder & setVerifyModules(bool Verify)
setVerifyModules - Set whether the JIT implementation should verify IR modules during compilation.
virtual void setObjectCache(ObjectCache *)
Sets the pre-compiled object cache.
EngineBuilder & setMemoryManager(std::unique_ptr< MCJITMemoryManager > MM)
virtual void UnregisterJITEventListener(JITEventListener *)
void clearErrorMessage()
Clear the error message.
virtual bool removeModule(Module *M)
removeModule - Removes a Module from the list of modules, but does not free the module's memory.
virtual void runStaticConstructorsDestructors(bool isDtors)
runStaticConstructorsDestructors - This method is used to execute all of the static constructors or d...
const DataLayout & getDataLayout() const
virtual void finalizeObject()
finalizeObject - ensure the module is fully processed and is usable.
bar al al movzbl eax ret Missed when stored in a memory object
This is an important base class in LLVM.
EngineBuilder & setRelocationModel(Reloc::Model RM)
setRelocationModel - Set the relocation model that the ExecutionEngine target is using.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
void InstallLazyFunctionCreator(FunctionCreator C)
InstallLazyFunctionCreator - If an unknown function is needed, the specified function pointer is invo...
GlobalAddressMapTy & getGlobalAddressMap()
Primary interface to the complete machine description for the target machine.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
EngineBuilder()
Default constructor for EngineBuilder.
virtual void * getPointerToFunction(Function *F)=0
getPointerToFunction - The different EE's represent function bodies in different ways.
print Print MemDeps of function
A Module instance is used to store all the information related to an LLVM module.
const GlobalValue * getGlobalValueAtAddress(void *Addr)
getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address.
bool hasError() const
Returns true if an error has been recorded.
JITEventListener - Abstract interface for use by the JIT to notify clients about significant events d...
std::map< uint64_t, std::string > & getGlobalAddressReverseMap()
ExecutionEngine(DataLayout DL)
void * getPointerToGlobal(const GlobalValue *GV)
getPointerToGlobal - This returns the address of the specified global value.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
void addGlobalMapping(const GlobalValue *GV, void *Addr)
addGlobalMapping - Tell the execution engine that the specified global is at the specified location.
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
std::function< void *(const std::string &)> FunctionCreator
void setEmulatedTLS(bool EmulatedTLS)
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter...
void InitializeMemory(const Constant *Init, void *Addr)
void emitGlobals()
EmitGlobals - Emit all of the global variables to memory, storing their addresses into GlobalAddress.
virtual GenericValue runFunction(Function *F, ArrayRef< GenericValue > ArgValues)=0
runFunction - Execute the specified function with the specified arguments, and return the result.
void * getPointerToGlobalIfAvailable(StringRef S)
getPointerToGlobalIfAvailable - This returns the address of the specified global value if it is has a...
virtual void RegisterJITEventListener(JITEventListener *)
Registers a listener to be called back on various events within the JIT.
bool isCompilingLazily() const
EngineBuilder & setMAttrs(const StringSequence &mattrs)
setMAttrs - Set cpu-specific attributes.
EngineBuilder & setSymbolResolver(std::unique_ptr< LegacyJITSymbolResolver > SR)
virtual char * getMemoryForGV(const GlobalVariable *GV)
getMemoryforGV - Allocate memory for a global variable.
virtual uint64_t getGlobalValueAddress(const std::string &Name)
getGlobalValueAddress - Return the address of the specified global value.
Helper class for helping synchronize access to the global address map table.
EngineBuilder & setMCPU(StringRef mcpu)
setMCPU - Target a specific cpu type.
EngineBuilder & setOptLevel(CodeGenOpt::Level l)
setOptLevel - Set the optimization level for the JIT.
EngineBuilder & setEngineKind(EngineKind::Kind w)
setEngineKind - Controls whether the user wants the interpreter, the JIT, or whichever engine works.
const char LLVMTargetMachineRef TM
const std::string & getErrorMessage() const
Returns the most recent error message.
Level
Code generation optimization level.
EngineBuilder & setMArch(StringRef march)
setMArch - Override the architecture set by the Module's triple.
TargetMachine * selectTarget()
virtual void setProcessAllSections(bool ProcessAllSections)
setProcessAllSections (MCJIT Only): By default, only sections that are "required for execution" are p...
virtual void addArchive(object::OwningBinary< object::Archive > A)
addArchive - Add an Archive to the execution engine.