LLVM API Documentation
#include <MCJIT.h>
Public Member Functions | |
~MCJIT () | |
uint64_t | getSymbolAddress (const std::string &Name, bool CheckFunctionsOnly) |
ExecutionEngine interface implementation | |
virtual void | addModule (Module *M) |
virtual bool | removeModule (Module *M) |
virtual Function * | FindFunctionNamed (const char *FnName) |
virtual void | setObjectCache (ObjectCache *manager) |
Sets the object manager that MCJIT should use to avoid compilation. More... | |
virtual void | generateCodeForModule (Module *M) |
virtual void | finalizeObject () |
virtual void | finalizeModule (Module *) |
void | finalizeLoadedModules () |
void | runStaticConstructorsDestructors (bool isDtors) |
virtual void * | getPointerToBasicBlock (BasicBlock *BB) |
virtual void * | getPointerToFunction (Function *F) |
virtual void * | recompileAndRelinkFunction (Function *F) |
virtual void | freeMachineCodeForFunction (Function *F) |
virtual GenericValue | runFunction (Function *F, const std::vector< GenericValue > &ArgValues) |
virtual void * | getPointerToNamedFunction (const std::string &Name, bool AbortOnFailure=true) |
virtual void | mapSectionAddress (const void *LocalAddress, uint64_t TargetAddress) |
virtual void | RegisterJITEventListener (JITEventListener *L) |
virtual void | UnregisterJITEventListener (JITEventListener *L) |
virtual uint64_t | getGlobalValueAddress (const std::string &Name) |
virtual uint64_t | getFunctionAddress (const std::string &Name) |
![]() | |
virtual | ~ExecutionEngine () |
const DataLayout * | getDataLayout () const |
void | runStaticConstructorsDestructors (Module *module, bool isDtors) |
int | runFunctionAsMain (Function *Fn, const std::vector< std::string > &argv, const char *const *envp) |
void | addGlobalMapping (const GlobalValue *GV, void *Addr) |
void | clearAllGlobalMappings () |
void | clearGlobalMappingsFromModule (Module *M) |
void * | updateGlobalMapping (const GlobalValue *GV, void *Addr) |
void * | getPointerToGlobalIfAvailable (const GlobalValue *GV) |
void * | getPointerToGlobal (const GlobalValue *GV) |
virtual void * | getPointerToFunctionOrStub (Function *F) |
virtual void | runJITOnFunction (Function *, MachineCodeInfo *=0) |
const GlobalValue * | getGlobalValueAtAddress (void *Addr) |
void | StoreValueToMemory (const GenericValue &Val, GenericValue *Ptr, Type *Ty) |
void | InitializeMemory (const Constant *Init, void *Addr) |
virtual void * | getOrEmitGlobalVariable (const GlobalVariable *GV) |
void | DisableLazyCompilation (bool Disabled=true) |
bool | isCompilingLazily () const |
bool | isLazyCompilationDisabled () const |
void | DisableGVCompilation (bool Disabled=true) |
bool | isGVCompilationDisabled () const |
void | DisableSymbolSearching (bool Disabled=true) |
bool | isSymbolSearchingDisabled () const |
void | InstallLazyFunctionCreator (void *(*P)(const std::string &)) |
Static Public Member Functions | |
(Private) Registration Interfaces | |
static void | Register () |
static ExecutionEngine * | createJIT (Module *M, std::string *ErrorStr, RTDyldMemoryManager *MemMgr, bool GVsWithCode, TargetMachine *TM) |
![]() | |
static ExecutionEngine * | create (Module *M, bool ForceInterpreter=false, std::string *ErrorStr=0, CodeGenOpt::Level OptLevel=CodeGenOpt::Default, bool GVsWithCode=true) |
static ExecutionEngine * | createJIT (Module *M, std::string *ErrorStr=0, JITMemoryManager *JMM=0, CodeGenOpt::Level OptLevel=CodeGenOpt::Default, bool GVsWithCode=true, Reloc::Model RM=Reloc::Default, CodeModel::Model CMM=CodeModel::JITDefault) |
Protected Member Functions | |
ObjectBufferStream * | emitObject (Module *M) |
void | NotifyObjectEmitted (const ObjectImage &Obj) |
void | NotifyFreeingObject (const ObjectImage &Obj) |
uint64_t | getExistingSymbolAddress (const std::string &Name) |
Module * | findModuleForSymbol (const std::string &Name, bool CheckFunctionsOnly) |
![]() | |
void | setDataLayout (const DataLayout *td) |
virtual char * | getMemoryForGV (const GlobalVariable *GV) |
getMemoryforGV - Allocate memory for a global variable. More... | |
ExecutionEngine (Module *M) | |
void | emitGlobals () |
void | EmitGlobalVariable (const GlobalVariable *GV) |
GenericValue | getConstantValue (const Constant *C) |
Converts a Constant* into a GenericValue, including handling of ConstantExpr values. More... | |
void | LoadValueFromMemory (GenericValue &Result, GenericValue *Ptr, Type *Ty) |
Additional Inherited Members | |
![]() | |
sys::Mutex | lock |
![]() | |
SmallVector< Module *, 1 > | Modules |
void *(* | LazyFunctionCreator )(const std::string &) |
![]() | |
static ExecutionEngine *(* | JITCtor )(Module *M, std::string *ErrorStr, JITMemoryManager *JMM, bool GVsWithCode, TargetMachine *TM) |
static ExecutionEngine *(* | MCJITCtor )(Module *M, std::string *ErrorStr, RTDyldMemoryManager *MCJMM, bool GVsWithCode, TargetMachine *TM) |
static ExecutionEngine *(* | InterpCtor )(Module *M, std::string *ErrorStr) |
Definition at line 93 of file lib/ExecutionEngine/MCJIT/MCJIT.h.
MCJIT::~MCJIT | ( | ) |
Definition at line 65 of file MCJIT.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::begin(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::clear(), llvm::RuntimeDyld::deregisterEHFrames(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::end(), llvm::sys::path::end(), llvm::ExecutionEngine::lock, llvm::ExecutionEngine::Modules, and NotifyFreeingObject().
|
virtual |
addModule - Add a Module to the list of modules that we can JIT from. Note that this takes ownership of the Module: when the ExecutionEngine is destroyed, it destroys the Module as well.
Reimplemented from llvm::ExecutionEngine.
Definition at line 92 of file MCJIT.cpp.
References llvm::ExecutionEngine::lock.
|
static |
Definition at line 42 of file MCJIT.cpp.
References llvm::sys::DynamicLibrary::LoadLibraryPermanently().
Referenced by Register().
|
protected |
emitObject – Generate a JITed object in memory from the specified module Currently, MCJIT only supports a single module and the module passed to this function call is expected to be the contained module. The module is passed as a parameter here to prepare for multiple module support in the future.
Definition at line 109 of file MCJIT.cpp.
References llvm::TargetMachine::addPassesToEmitMC(), llvm::ObjectBufferStream::flush(), llvm::TargetMachine::getDataLayout(), llvm::ObjectBuffer::getMemBuffer(), llvm::ObjectBufferStream::getOStream(), llvm::ExecutionEngine::lock, llvm::ObjectCache::notifyObjectCompiled(), llvm::report_fatal_error(), and llvm::OwningPtr< T >::take().
Referenced by generateCodeForModule().
void MCJIT::finalizeLoadedModules | ( | ) |
Definition at line 187 of file MCJIT.cpp.
References llvm::LinkingMemoryManager::finalizeMemory(), llvm::ExecutionEngine::lock, llvm::RuntimeDyld::registerEHFrames(), and llvm::RuntimeDyld::resolveRelocations().
Referenced by finalizeModule(), finalizeObject(), getFunctionAddress(), and getGlobalValueAddress().
|
virtual |
Definition at line 216 of file MCJIT.cpp.
References finalizeLoadedModules(), generateCodeForModule(), and llvm::ExecutionEngine::lock.
|
virtual |
finalizeObject - ensure the module is fully processed and is usable.
It is the user-level function for completing the process of making the object usable for execution. It should be called after sections within an object have been relocated using mapSectionAddress. When this method is called the MCJIT execution engine will reapply relocations for a loaded object. Is it OK to finalize a set of modules, add modules and finalize again.
Reimplemented from llvm::ExecutionEngine.
Definition at line 203 of file MCJIT.cpp.
References finalizeLoadedModules(), generateCodeForModule(), I, and llvm::ExecutionEngine::lock.
|
virtual |
FindFunctionNamed - Search all of the active modules to find the one that defines FnName. This is very slow operation and shouldn't be used for general code.
Reimplemented from llvm::ExecutionEngine.
Definition at line 369 of file MCJIT.cpp.
References F().
Definition at line 241 of file MCJIT.cpp.
References F(), G, llvm::Module::getFunction(), llvm::Module::getGlobalVariable(), I, llvm::GlobalValue::isDeclaration(), and llvm::ExecutionEngine::lock.
Referenced by getSymbolAddress().
|
virtual |
freeMachineCodeForFunction - Release memory in the ExecutionEngine corresponding to the machine code emitted to execute this function, useful for garbage-collecting generated code.
Implements llvm::ExecutionEngine.
Definition at line 338 of file MCJIT.cpp.
References llvm::report_fatal_error().
|
virtual |
generateCodeForModule - Run code generationen for the specified module and load it into memory.
When this function has completed, all code and data for the specified module, and any module on which this module depends, will be generated and loaded into memory, but relocations will not yet have been applied and all memory will be readable and writable but not executable.
This function is primarily useful when generating code for an external target, allowing the client an opportunity to remap section addresses before relocations are applied. Clients that intend to execute code locally can use the getFunctionAddress call, which will generate code and apply final preparations all in one step.
This method has no effect for the legacy JIT engine or the interpeter.
Reimplemented from llvm::ExecutionEngine.
Definition at line 146 of file MCJIT.cpp.
References emitObject(), llvm::OwningPtr< T >::get(), llvm::RuntimeDyld::getErrorString(), llvm::ObjectCache::getObject(), llvm::RuntimeDyld::loadObject(), llvm::ExecutionEngine::lock, NotifyObjectEmitted(), llvm::ObjectImage::registerWithDebugger(), llvm::report_fatal_error(), llvm::OwningPtr< T >::reset(), and llvm::OwningPtr< T >::take().
Referenced by finalizeModule(), finalizeObject(), getPointerToFunction(), and getSymbolAddress().
|
protected |
Definition at line 233 of file MCJIT.cpp.
References llvm::MCAsmInfo::getGlobalPrefix(), llvm::TargetMachine::getMCAsmInfo(), and llvm::RuntimeDyld::getSymbolLoadAddress().
Referenced by getSymbolAddress().
|
virtual |
getFunctionAddress - Return the address of the specified function. This may involve code generation.
Reimplemented from llvm::ExecutionEngine.
Definition at line 293 of file MCJIT.cpp.
References finalizeLoadedModules(), getSymbolAddress(), and llvm::ExecutionEngine::lock.
|
virtual |
getGlobalValueAddress - Return the address of the specified global value. This may involve code generation.
This function should not be called with the JIT or interpreter engines.
Reimplemented from llvm::ExecutionEngine.
Definition at line 285 of file MCJIT.cpp.
References finalizeLoadedModules(), getSymbolAddress(), and llvm::ExecutionEngine::lock.
|
virtual |
getPointerToBasicBlock - The different EE's represent basic blocks in different ways. Return the representation for a blockaddress of the specified block.
This function will not be implemented for the MCJIT execution engine.
Implements llvm::ExecutionEngine.
Definition at line 229 of file MCJIT.cpp.
References llvm::report_fatal_error().
|
virtual |
getPointerToFunction - The different EE's represent function bodies in different ways. They should each implement this to say what a function pointer should look like. When F is destroyed, the ExecutionEngine will remove its global mapping and free any machine code. Be sure no threads are running inside F when that happens.
This function is deprecated for the MCJIT execution engine. Use getFunctionAddress instead.
Implements llvm::ExecutionEngine.
Definition at line 302 of file MCJIT.cpp.
References llvm::ExecutionEngine::addGlobalMapping(), generateCodeForModule(), llvm::MCAsmInfo::getGlobalPrefix(), llvm::TargetMachine::getMCAsmInfo(), llvm::Value::getName(), llvm::GlobalValue::getParent(), getPointerToNamedFunction(), llvm::RuntimeDyld::getSymbolLoadAddress(), llvm::GlobalValue::hasAvailableExternallyLinkage(), llvm::GlobalValue::hasExternalWeakLinkage(), llvm::GlobalValue::isDeclaration(), llvm::ExecutionEngine::lock, and llvm::StringRef::substr().
Referenced by runFunction().
|
virtual |
getPointerToNamedFunction - This method returns the address of the specified function by using the dlsym function call. As such it is only useful for resolving library symbols, not code generated symbols.
If AbortOnFailure is false and no function with the given name is found, this function silently returns a null pointer. Otherwise, it prints a message to stderr and aborts.
If a LazyFunctionCreator is installed, use it to get/create the function.
Implements llvm::ExecutionEngine.
Definition at line 481 of file MCJIT.cpp.
References llvm::RTDyldMemoryManager::getPointerToNamedFunction(), llvm::ExecutionEngine::isSymbolSearchingDisabled(), llvm::ExecutionEngine::LazyFunctionCreator, llvm::report_fatal_error(), and llvm::NVPTX::PTXCvtMode::RP.
Referenced by getPointerToFunction().
uint64_t MCJIT::getSymbolAddress | ( | const std::string & | Name, |
bool | CheckFunctionsOnly | ||
) |
Definition at line 264 of file MCJIT.cpp.
References findModuleForSymbol(), generateCodeForModule(), getExistingSymbolAddress(), and llvm::ExecutionEngine::lock.
Referenced by getFunctionAddress(), getGlobalValueAddress(), and llvm::LinkingMemoryManager::getSymbolAddress().
|
inlinevirtual |
mapSectionAddress - map a section to its target address space value. Map the address of a JIT section as returned from the memory manager to the address in the target process as the running code will see it. This is the address which will be used for relocation resolution.
Reimplemented from llvm::ExecutionEngine.
Definition at line 287 of file lib/ExecutionEngine/MCJIT/MCJIT.h.
References llvm::RuntimeDyld::mapSectionAddress().
|
protected |
Definition at line 525 of file MCJIT.cpp.
References I, and llvm::ExecutionEngine::lock.
Referenced by ~MCJIT().
|
protected |
Definition at line 518 of file MCJIT.cpp.
References I, llvm::ExecutionEngine::lock, and llvm::LinkingMemoryManager::notifyObjectLoaded().
Referenced by generateCodeForModule().
|
virtual |
recompileAndRelinkFunction - This method is used to force a function which has already been compiled to be compiled again, possibly after it has been modified. Then the entry to the old copy is overwritten with a branch to the new copy. If there was no old copy, this acts just like VM::getPointerToFunction().
Implements llvm::ExecutionEngine.
Definition at line 334 of file MCJIT.cpp.
References llvm::report_fatal_error().
|
inlinestatic |
Definition at line 304 of file lib/ExecutionEngine/MCJIT/MCJIT.h.
References createJIT(), and llvm::ExecutionEngine::MCJITCtor.
|
virtual |
Registers a listener to be called back on various events within the JIT. See JITEventListener.h for more details. Does not take ownership of the argument. The argument may be NULL, in which case these functions do nothing.
Reimplemented from llvm::ExecutionEngine.
Definition at line 501 of file MCJIT.cpp.
References llvm::ExecutionEngine::lock.
removeModule - Remove a Module from the list of modules. Returns true if M is found.
Reimplemented from llvm::ExecutionEngine.
Definition at line 97 of file MCJIT.cpp.
References llvm::ExecutionEngine::lock.
|
virtual |
runFunction - Execute the specified function with the specified arguments, and return the result.
Implements llvm::ExecutionEngine.
Definition at line 381 of file MCJIT.cpp.
References llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, llvm::Type::FP128TyID, getBitWidth(), llvm::Function::getFunctionType(), llvm::FunctionType::getNumParams(), llvm::FunctionType::getParamType(), getPointerToFunction(), llvm::FunctionType::getReturnType(), llvm::Type::getTypeID(), llvm::GVTOP(), llvm::Type::IntegerTyID, llvm::GenericValue::IntVal, llvm::tgtok::IntVal, llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::FunctionType::isVarArg(), llvm::Type::isVoidTy(), llvm_unreachable, llvm::Type::PointerTyID, llvm::Type::PPC_FP128TyID, llvm::PTOGV(), llvm::Type::VoidTyID, and llvm::Type::X86_FP80TyID.
|
virtual |
runStaticConstructorsDestructors - This method is used to execute all of the static constructors or destructors for a program.
isDtors | - Run the destructors instead of constructors. |
Reimplemented from llvm::ExecutionEngine.
|
virtual |
Sets the object manager that MCJIT should use to avoid compilation.
Reimplemented from llvm::ExecutionEngine.
Definition at line 104 of file MCJIT.cpp.
References llvm::ExecutionEngine::lock.
|
virtual |
Reimplemented from llvm::ExecutionEngine.
Definition at line 507 of file MCJIT.cpp.
References llvm::ExecutionEngine::lock, and std::swap().