LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
llvm::ExecutionEngine Class Referenceabstract

Abstract interface for implementation execution of LLVM modules, designed to support both interpreter and just-in-time (JIT) compiler implementations. More...

#include <ExecutionEngine.h>

Inheritance diagram for llvm::ExecutionEngine:
Inheritance graph
[legend]
Collaboration diagram for llvm::ExecutionEngine:
Collaboration graph
[legend]

Public Member Functions

virtual ~ExecutionEngine ()
 
virtual void addModule (Module *M)
 
const DataLayoutgetDataLayout () const
 
virtual bool removeModule (Module *M)
 
virtual FunctionFindFunctionNamed (const char *FnName)
 
virtual GenericValue runFunction (Function *F, const std::vector< GenericValue > &ArgValues)=0
 
virtual void * getPointerToNamedFunction (const std::string &Name, bool AbortOnFailure=true)=0
 
virtual void mapSectionAddress (const void *LocalAddress, uint64_t TargetAddress)
 
virtual void generateCodeForModule (Module *M)
 
virtual void finalizeObject ()
 
virtual void runStaticConstructorsDestructors (bool isDtors)
 
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 * getPointerToFunction (Function *F)=0
 
virtual void * getPointerToBasicBlock (BasicBlock *BB)=0
 
virtual void * getPointerToFunctionOrStub (Function *F)
 
virtual uint64_t getGlobalValueAddress (const std::string &Name)
 
virtual uint64_t getFunctionAddress (const std::string &Name)
 
virtual void runJITOnFunction (Function *, MachineCodeInfo *=0)
 
const GlobalValuegetGlobalValueAtAddress (void *Addr)
 
void StoreValueToMemory (const GenericValue &Val, GenericValue *Ptr, Type *Ty)
 
void InitializeMemory (const Constant *Init, void *Addr)
 
virtual void * recompileAndRelinkFunction (Function *F)=0
 
virtual void freeMachineCodeForFunction (Function *F)=0
 
virtual void * getOrEmitGlobalVariable (const GlobalVariable *GV)
 
virtual void RegisterJITEventListener (JITEventListener *)
 
virtual void UnregisterJITEventListener (JITEventListener *)
 
virtual void setObjectCache (ObjectCache *)
 
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

static ExecutionEnginecreate (Module *M, bool ForceInterpreter=false, std::string *ErrorStr=0, CodeGenOpt::Level OptLevel=CodeGenOpt::Default, bool GVsWithCode=true)
 
static ExecutionEnginecreateJIT (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)
 

Public Attributes

sys::Mutex lock
 

Protected Member Functions

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)
 

Protected Attributes

SmallVector< Module *, 1 > Modules
 
void *(* LazyFunctionCreator )(const std::string &)
 

Static Protected Attributes

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)
 

Friends

class EngineBuilder
 

Detailed Description

Abstract interface for implementation execution of LLVM modules, designed to support both interpreter and just-in-time (JIT) compiler implementations.

Definition at line 100 of file ExecutionEngine/ExecutionEngine.h.

Constructor & Destructor Documentation

ExecutionEngine::~ExecutionEngine ( )
virtual

Definition at line 73 of file ExecutionEngine.cpp.

References clearAllGlobalMappings(), and Modules.

ExecutionEngine::ExecutionEngine ( Module M)
explicitprotected

Definition at line 63 of file ExecutionEngine.cpp.

References Modules.

Member Function Documentation

void ExecutionEngine::addGlobalMapping ( const GlobalValue GV,
void *  Addr 
)

addGlobalMapping - Tell the execution engine that the specified global is at the specified location. This is used internally as functions are JIT'd and as global variables are laid out in memory. It can and should also be used by clients of the EE that want to have an LLVM global overlay existing data in memory. Mappings are automatically removed when their GlobalValue is destroyed.

Definition at line 154 of file ExecutionEngine.cpp.

References llvm::dbgs(), DEBUG, llvm::ExecutionEngineState::getGlobalAddressMap(), llvm::ExecutionEngineState::getGlobalAddressReverseMap(), llvm::Value::getName(), and lock.

Referenced by emitGlobals(), EmitGlobalVariable(), llvm::JIT::getOrEmitGlobalVariable(), llvm::JIT::getPointerToFunction(), llvm::MCJIT::getPointerToFunction(), and llvm::JIT::recompileAndRelinkFunction().

virtual void llvm::ExecutionEngine::addModule ( Module M)
inlinevirtual

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 in llvm::MCJIT, and llvm::JIT.

Definition at line 203 of file ExecutionEngine/ExecutionEngine.h.

References Modules.

Referenced by llvm::JIT::addModule().

void ExecutionEngine::clearAllGlobalMappings ( )

clearAllGlobalMappings - Clear all global mappings and start over again, for use in dynamic compilation scenarios to move globals.

Definition at line 172 of file ExecutionEngine.cpp.

References llvm::ValueMap< KeyT, ValueT, Config >::clear(), llvm::ExecutionEngineState::getGlobalAddressMap(), llvm::ExecutionEngineState::getGlobalAddressReverseMap(), and lock.

Referenced by ~ExecutionEngine().

void ExecutionEngine::clearGlobalMappingsFromModule ( Module M)

clearGlobalMappingsFromModule - Clear all global mappings that came from a particular module, because it has been removed from the JIT.

Definition at line 179 of file ExecutionEngine.cpp.

References llvm::Module::begin(), llvm::Module::end(), llvm::A64CC::GE, llvm::Module::global_begin(), llvm::Module::global_end(), lock, and llvm::ExecutionEngineState::RemoveMapping().

Referenced by removeModule().

ExecutionEngine * ExecutionEngine::create ( Module M,
bool  ForceInterpreter = false,
std::string *  ErrorStr = 0,
CodeGenOpt::Level  OptLevel = CodeGenOpt::Default,
bool  GVsWithCode = true 
)
static

create - This is the factory method for creating an execution engine which is appropriate for the current machine. This takes ownership of the module.

Parameters
GVsWithCode- Allocating globals with code breaks freeMachineCodeForFunction and is probably unsafe and bad for performance. However, we have clients who depend on this behavior, so we must support it. Eventually, when we're willing to break some backwards compatibility, this flag should be flipped to false, so that by default freeMachineCodeForFunction works.

Definition at line 395 of file ExecutionEngine.cpp.

References llvm::EngineBuilder::create(), EngineBuilder, llvm::EngineKind::Interpreter, and llvm::EngineKind::JIT.

ExecutionEngine * ExecutionEngine::createJIT ( Module M,
std::string *  ErrorStr = 0,
JITMemoryManager JMM = 0,
CodeGenOpt::Level  OL = CodeGenOpt::Default,
bool  GVsWithCode = true,
Reloc::Model  RM = Reloc::Default,
CodeModel::Model  CMM = CodeModel::JITDefault 
)
static

createJIT - This is the factory method for creating a JIT for the current machine, it does not fall back to the interpreter. This takes ownership of the Module and JITMemoryManager if successful.

Clients should make sure to initialize targets prior to calling this function.

createJIT - This is the factory method for creating a JIT for the current machine, it does not fall back to the interpreter. This takes ownership of the module.

Definition at line 414 of file ExecutionEngine.cpp.

References llvm::EngineKind::JIT, JITCtor, llvm::EngineBuilder::selectTarget(), llvm::EngineBuilder::setAllocateGVsWithCode(), llvm::EngineBuilder::setCodeModel(), llvm::EngineBuilder::setEngineKind(), llvm::EngineBuilder::setErrorStr(), llvm::EngineBuilder::setJITMemoryManager(), llvm::EngineBuilder::setOptLevel(), llvm::EngineBuilder::setRelocationModel(), and llvm::SystemZISD::TM.

Referenced by llvm::JIT::create().

void llvm::ExecutionEngine::DisableGVCompilation ( bool  Disabled = true)
inline

DisableGVCompilation - If called, the JIT will abort if it's asked to allocate space and populate a GlobalVariable that is not internal to the module.

Definition at line 461 of file ExecutionEngine/ExecutionEngine.h.

void llvm::ExecutionEngine::DisableLazyCompilation ( bool  Disabled = true)
inline

DisableLazyCompilation - When lazy compilation is off (the default), the JIT will eagerly compile every function reachable from the argument to getPointerToFunction. If lazy compilation is turned on, the JIT will only compile the one function and emit stubs to compile the rest when they're first called. If lazy compilation is turned off again while some lazy stubs are still around, and one of those stubs is called, the program will abort.

In order to safely compile lazily in a threaded program, the user must ensure that 1) only one thread at a time can call any particular lazy stub, and 2) any thread modifying LLVM IR must hold the JIT's lock (ExecutionEngine::lock) or otherwise ensure that no other thread calls a lazy stub. See http://llvm.org/PR5184 for details.

Definition at line 446 of file ExecutionEngine/ExecutionEngine.h.

void llvm::ExecutionEngine::DisableSymbolSearching ( bool  Disabled = true)
inline

DisableSymbolSearching - If called, the JIT will not try to lookup unknown symbols with dlsym. A client can still use InstallLazyFunctionCreator to resolve symbols in a custom way.

Definition at line 471 of file ExecutionEngine/ExecutionEngine.h.

void ExecutionEngine::emitGlobals ( )
protected
void ExecutionEngine::EmitGlobalVariable ( const GlobalVariable GV)
protected
virtual void llvm::ExecutionEngine::finalizeObject ( )
inlinevirtual

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. This method has no effect for the legacy JIT engine or the interpeter.

Reimplemented in llvm::MCJIT.

Definition at line 275 of file ExecutionEngine/ExecutionEngine.h.

Function * ExecutionEngine::FindFunctionNamed ( const char *  FnName)
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 in llvm::MCJIT.

Definition at line 127 of file ExecutionEngine.cpp.

References F(), and Modules.

virtual void llvm::ExecutionEngine::freeMachineCodeForFunction ( Function F)
pure virtual

freeMachineCodeForFunction - Release memory in the ExecutionEngine corresponding to the machine code emitted to execute this function, useful for garbage-collecting generated code.

Implemented in llvm::MCJIT, llvm::JIT, and llvm::Interpreter.

virtual void llvm::ExecutionEngine::generateCodeForModule ( Module M)
inlinevirtual

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 in llvm::MCJIT.

Definition at line 265 of file ExecutionEngine/ExecutionEngine.h.

GenericValue ExecutionEngine::getConstantValue ( const Constant C)
protected

Converts a Constant* into a GenericValue, including handling of ConstantExpr values.

Definition at line 538 of file ExecutionEngine.cpp.

References llvm::APFloat::add(), llvm::GenericValue::AggregateVal, llvm::APIntOps::And(), llvm::lltok::APFloat, llvm::APFloat::bitcastToAPInt(), llvm::APInt::bitsToDouble(), llvm::APInt::bitsToFloat(), llvm::CallingConv::C, llvm::APFloat::convertFromAPInt(), llvm::APFloat::convertToInteger(), llvm::APFloat::divide(), llvm::APInt::doubleToBits(), llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::dyn_cast(), F(), llvm::APInt::floatToBits(), llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, llvm::LibFunc::fmod, llvm::Type::FP128TyID, llvm::UndefValue::get(), getBitWidth(), llvm::APInt::getBitWidth(), llvm::ConstantDataSequential::getElementAsDouble(), llvm::ConstantDataSequential::getElementAsFloat(), llvm::ConstantDataSequential::getElementAsInteger(), llvm::SequentialType::getElementType(), llvm::ConstantDataSequential::getElementType(), llvm::VectorType::getNumElements(), llvm::ConstantDataSequential::getNumElements(), llvm::User::getOperand(), getOrEmitGlobalVariable(), llvm::DataLayout::getPointerSizeInBits(), getPointerToBasicBlock(), getPointerToFunctionOrStub(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::Type::getTypeID(), llvm::DataLayout::getTypeSizeInBits(), llvm::APFloat::getZero(), llvm::APInt::getZExtValue(), llvm::Type::IntegerTyID, llvm::GenericValue::IntVal, llvm::Type::isAggregateType(), llvm::Type::isDoubleTy(), llvm::Type::isFloatingPointTy(), llvm::Type::isFloatTy(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::Type::isX86_FP80Ty(), llvm_unreachable, llvm::APFloat::mod(), llvm::APFloat::multiply(), llvm::APIntOps::Or(), llvm::Type::PointerTyID, llvm::GenericValue::PointerVal, llvm::Type::PPC_FP128TyID, llvm::PTOGV(), llvm::report_fatal_error(), llvm::APFloat::rmNearestTiesToEven, llvm::APFloat::rmTowardZero, llvm::APIntOps::RoundDoubleToAPInt(), llvm::APIntOps::RoundFloatToAPInt(), llvm::APInt::roundToDouble(), llvm::APInt::sdiv(), llvm::APInt::sext(), llvm::APInt::signedRoundToDouble(), llvm::APInt::srem(), llvm::raw_svector_ostream::str(), llvm::Type::StructTyID, llvm::APFloat::subtract(), llvm::APInt::trunc(), llvm::APInt::udiv(), llvm::APInt::urem(), llvm::Type::VectorTyID, llvm::Type::X86_FP80TyID, llvm::APFloat::x87DoubleExtended, llvm::APIntOps::Xor(), llvm::APInt::zext(), and llvm::APInt::zextOrTrunc().

Referenced by InitializeMemory().

const DataLayout* llvm::ExecutionEngine::getDataLayout ( ) const
inline
virtual uint64_t llvm::ExecutionEngine::getFunctionAddress ( const std::string &  Name)
inlinevirtual

getFunctionAddress - Return the address of the specified function. This may involve code generation.

Reimplemented in llvm::MCJIT.

Definition at line 375 of file ExecutionEngine/ExecutionEngine.h.

virtual uint64_t llvm::ExecutionEngine::getGlobalValueAddress ( const std::string &  Name)
inlinevirtual

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 in llvm::MCJIT.

Definition at line 367 of file ExecutionEngine/ExecutionEngine.h.

const GlobalValue * ExecutionEngine::getGlobalValueAtAddress ( void *  Addr)

getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address.

Definition at line 224 of file ExecutionEngine.cpp.

References llvm::ValueMap< KeyT, ValueT, Config >::begin(), llvm::ValueMap< KeyT, ValueT, Config >::end(), llvm::ExecutionEngineState::getGlobalAddressMap(), llvm::ExecutionEngineState::getGlobalAddressReverseMap(), I, and lock.

char * ExecutionEngine::getMemoryForGV ( const GlobalVariable GV)
protectedvirtual

getMemoryforGV - Allocate memory for a global variable.

Reimplemented in llvm::JIT.

Definition at line 110 of file ExecutionEngine.cpp.

References getDataLayout().

Referenced by emitGlobals(), and EmitGlobalVariable().

virtual void* llvm::ExecutionEngine::getOrEmitGlobalVariable ( const GlobalVariable GV)
inlinevirtual

getOrEmitGlobalVariable - Return the address of the specified global variable, possibly emitting it to memory if needed. This is used by the Emitter.

This function is deprecated for the MCJIT execution engine. Use getGlobalValueAddress instead.

Reimplemented in llvm::JIT.

Definition at line 416 of file ExecutionEngine/ExecutionEngine.h.

References getPointerToGlobal().

Referenced by getConstantValue().

virtual void* llvm::ExecutionEngine::getPointerToBasicBlock ( BasicBlock BB)
pure 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.

Implemented in llvm::MCJIT, and llvm::JIT.

Referenced by getConstantValue().

virtual void* llvm::ExecutionEngine::getPointerToFunction ( Function F)
pure 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.

Implemented in llvm::MCJIT, and llvm::JIT.

Referenced by getPointerToFunctionOrStub(), and getPointerToGlobal().

virtual void* llvm::ExecutionEngine::getPointerToFunctionOrStub ( Function F)
inlinevirtual

getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the function. If not, compile it, or use a stub to implement lazy compilation if available. See getPointerToFunction for the requirements on destroying F.

This function is deprecated for the MCJIT execution engine. Use getFunctionAddress instead.

Reimplemented in llvm::JIT.

Definition at line 358 of file ExecutionEngine/ExecutionEngine.h.

References getPointerToFunction().

Referenced by getConstantValue().

void * ExecutionEngine::getPointerToGlobal ( const GlobalValue GV)

getPointerToGlobal - This returns the address of the specified global value. This may involve code generation if it's a function.

This function is deprecated for the MCJIT execution engine. Use getGlobalValueAddress instead.

Definition at line 518 of file ExecutionEngine.cpp.

References EmitGlobalVariable(), F(), llvm::ExecutionEngineState::getGlobalAddressMap(), getPointerToFunction(), llvm_unreachable, lock, and P.

Referenced by getOrEmitGlobalVariable().

void * ExecutionEngine::getPointerToGlobalIfAvailable ( const GlobalValue GV)

getPointerToGlobalIfAvailable - This returns the address of the specified global value if it is has already been codegen'd, otherwise it returns null.

This function is deprecated for the MCJIT execution engine. It doesn't seem to be needed in that case, but an equivalent can be added if it is.

Definition at line 216 of file ExecutionEngine.cpp.

References llvm::ValueMap< KeyT, ValueT, Config >::end(), llvm::ValueMap< KeyT, ValueT, Config >::find(), llvm::ExecutionEngineState::getGlobalAddressMap(), I, lock, and llvm::ValueMapIterator< DenseMapT, KeyT >::ValueTypeProxy::second.

Referenced by llvm::Interpreter::callExternalFunction(), emitGlobals(), EmitGlobalVariable(), llvm::JIT::getOrEmitGlobalVariable(), llvm::JIT::getPointerToFunction(), llvm::JIT::getPointerToFunctionOrStub(), and llvm::JIT::recompileAndRelinkFunction().

virtual void* llvm::ExecutionEngine::getPointerToNamedFunction ( const std::string &  Name,
bool  AbortOnFailure = true 
)
pure 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.

This function is deprecated for the MCJIT execution engine.

FIXME: the JIT and MCJIT interfaces should be disentangled or united again, if possible.

Implemented in llvm::MCJIT, llvm::JIT, and llvm::Interpreter.

void ExecutionEngine::InitializeMemory ( const Constant Init,
void *  Addr 
)
void llvm::ExecutionEngine::InstallLazyFunctionCreator ( void *(*)(const std::string &)  P)
inline

InstallLazyFunctionCreator - If an unknown function is needed, the specified function pointer is invoked to create it. If it returns null, the JIT will abort.

Definition at line 481 of file ExecutionEngine/ExecutionEngine.h.

References LazyFunctionCreator, and P.

bool llvm::ExecutionEngine::isCompilingLazily ( ) const
inline

Definition at line 449 of file ExecutionEngine/ExecutionEngine.h.

bool llvm::ExecutionEngine::isGVCompilationDisabled ( ) const
inline

Definition at line 464 of file ExecutionEngine/ExecutionEngine.h.

Referenced by llvm::JIT::getMemoryForGV().

bool llvm::ExecutionEngine::isLazyCompilationDisabled ( ) const
inline

Definition at line 454 of file ExecutionEngine/ExecutionEngine.h.

bool llvm::ExecutionEngine::isSymbolSearchingDisabled ( ) const
inline
void ExecutionEngine::LoadValueFromMemory ( GenericValue Result,
GenericValue Ptr,
Type Ty 
)
protected
virtual void llvm::ExecutionEngine::mapSectionAddress ( const void *  LocalAddress,
uint64_t  TargetAddress 
)
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 in llvm::MCJIT.

Definition at line 245 of file ExecutionEngine/ExecutionEngine.h.

References llvm_unreachable.

virtual void* llvm::ExecutionEngine::recompileAndRelinkFunction ( Function F)
pure 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().

Implemented in llvm::MCJIT, llvm::JIT, and llvm::Interpreter.

virtual void llvm::ExecutionEngine::RegisterJITEventListener ( JITEventListener )
inlinevirtual

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 in llvm::MCJIT, and llvm::JIT.

Definition at line 424 of file ExecutionEngine/ExecutionEngine.h.

bool ExecutionEngine::removeModule ( Module M)
virtual

removeModule - Remove a Module from the list of modules. Returns true if M is found.

Reimplemented in llvm::MCJIT, and llvm::JIT.

Definition at line 114 of file ExecutionEngine.cpp.

References clearGlobalMappingsFromModule(), I, and Modules.

Referenced by llvm::JIT::removeModule().

virtual GenericValue llvm::ExecutionEngine::runFunction ( Function F,
const std::vector< GenericValue > &  ArgValues 
)
pure virtual

runFunction - Execute the specified function with the specified arguments, and return the result.

Implemented in llvm::MCJIT, llvm::JIT, and llvm::Interpreter.

Referenced by runFunctionAsMain(), and runStaticConstructorsDestructors().

int ExecutionEngine::runFunctionAsMain ( Function Fn,
const std::vector< std::string > &  argv,
const char *const *  envp 
)
virtual void llvm::ExecutionEngine::runJITOnFunction ( Function ,
MachineCodeInfo = 0 
)
inlinevirtual

Reimplemented in llvm::JIT.

Definition at line 382 of file ExecutionEngine/ExecutionEngine.h.

void ExecutionEngine::runStaticConstructorsDestructors ( bool  isDtors)
virtual

runStaticConstructorsDestructors - This method is used to execute all of the static constructors or destructors for a program.

Parameters
isDtors- Run the destructors instead of constructors.

Reimplemented in llvm::MCJIT.

Definition at line 331 of file ExecutionEngine.cpp.

References Modules.

void ExecutionEngine::runStaticConstructorsDestructors ( Module module,
bool  isDtors 
)

runStaticConstructorsDestructors - This method is used to execute all of the static constructors or destructors for a particular module.

Parameters
isDtors- Run the destructors instead of constructors.

Definition at line 292 of file ExecutionEngine.cpp.

References llvm::dyn_cast(), F(), llvm::GlobalVariable::getInitializer(), llvm::Module::getNamedGlobal(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::GlobalValue::hasLocalLinkage(), llvm::GlobalValue::isDeclaration(), llvm::Constant::isNullValue(), and runFunction().

void llvm::ExecutionEngine::setDataLayout ( const DataLayout td)
inlineprotected

Definition at line 128 of file ExecutionEngine/ExecutionEngine.h.

References TD.

Referenced by llvm::Interpreter::Interpreter().

virtual void llvm::ExecutionEngine::setObjectCache ( ObjectCache )
inlinevirtual

Sets the pre-compiled object cache. The ownership of the ObjectCache is not changed. Supported by MCJIT but not JIT.

Reimplemented in llvm::MCJIT.

Definition at line 429 of file ExecutionEngine/ExecutionEngine.h.

References llvm_unreachable.

void ExecutionEngine::StoreValueToMemory ( const GenericValue Val,
GenericValue Ptr,
Type Ty 
)
virtual void llvm::ExecutionEngine::UnregisterJITEventListener ( JITEventListener )
inlinevirtual

Reimplemented in llvm::MCJIT, and llvm::JIT.

Definition at line 425 of file ExecutionEngine/ExecutionEngine.h.

void * ExecutionEngine::updateGlobalMapping ( const GlobalValue GV,
void *  Addr 
)

updateGlobalMapping - Replace an existing mapping for GV with a new address. This updates both maps as required. If "Addr" is null, the entry for the global is removed from the mappings. This returns the old value of the pointer, or null if it was not in the map.

Definition at line 189 of file ExecutionEngine.cpp.

References llvm::ExecutionEngineState::getGlobalAddressMap(), llvm::ExecutionEngineState::getGlobalAddressReverseMap(), lock, and llvm::ExecutionEngineState::RemoveMapping().

Referenced by llvm::JIT::freeMachineCodeForFunction().

Friends And Related Function Documentation

friend class EngineBuilder
friend

Definition at line 121 of file ExecutionEngine/ExecutionEngine.h.

Referenced by create().

Member Data Documentation

ExecutionEngine *(* ExecutionEngine::InterpCtor)(Module *M, std::string *ErrorStr)=0
staticprotected
ExecutionEngine *(* ExecutionEngine::JITCtor)(Module *M, std::string *ErrorStr, JITMemoryManager *JMM, bool GVsWithCode, TargetMachine *TM)=0
staticprotected
void*(* llvm::ExecutionEngine::LazyFunctionCreator)(const std::string &)
protected

LazyFunctionCreator - If an unknown function is needed, this function pointer is invoked to create it. If this returns null, the JIT will abort.

Definition at line 153 of file ExecutionEngine/ExecutionEngine.h.

Referenced by llvm::JIT::getPointerToNamedFunction(), llvm::MCJIT::getPointerToNamedFunction(), and InstallLazyFunctionCreator().

sys::Mutex llvm::ExecutionEngine::lock

lock - This lock protects the ExecutionEngine, MCJIT, JIT, JITResolver and JITEmitter classes. It must be held while changing the internal state of any of those classes.

Definition at line 159 of file ExecutionEngine/ExecutionEngine.h.

Referenced by addGlobalMapping(), llvm::JIT::addModule(), llvm::MCJIT::addModule(), llvm::JIT::addPendingFunction(), llvm::JIT::addPointerToBasicBlock(), clearAllGlobalMappings(), clearGlobalMappingsFromModule(), llvm::JIT::clearPointerToBasicBlock(), llvm::MCJIT::emitObject(), llvm::MCJIT::finalizeLoadedModules(), llvm::MCJIT::finalizeModule(), llvm::MCJIT::finalizeObject(), llvm::MCJIT::findModuleForSymbol(), llvm::MCJIT::generateCodeForModule(), llvm::MCJIT::getFunctionAddress(), llvm::MCJIT::getGlobalValueAddress(), getGlobalValueAtAddress(), llvm::JIT::getMemoryForGV(), llvm::ExecutionEngineState::AddressMapConfig::getMutex(), llvm::JIT::getOrEmitGlobalVariable(), llvm::JIT::getPointerToBasicBlock(), llvm::JIT::getPointerToFunction(), llvm::MCJIT::getPointerToFunction(), getPointerToGlobal(), getPointerToGlobalIfAvailable(), llvm::MCJIT::getSymbolAddress(), llvm::JIT::NotifyFreeingMachineCode(), llvm::MCJIT::NotifyFreeingObject(), llvm::JIT::NotifyFunctionEmitted(), llvm::MCJIT::NotifyObjectEmitted(), llvm::JIT::RegisterJITEventListener(), llvm::MCJIT::RegisterJITEventListener(), llvm::JIT::removeModule(), llvm::MCJIT::removeModule(), llvm::JIT::runJITOnFunction(), llvm::MCJIT::setObjectCache(), llvm::JIT::UnregisterJITEventListener(), llvm::MCJIT::UnregisterJITEventListener(), updateGlobalMapping(), and llvm::MCJIT::~MCJIT().

ExecutionEngine *(* ExecutionEngine::MCJITCtor)(Module *M, std::string *ErrorStr, RTDyldMemoryManager *MCJMM, bool GVsWithCode, TargetMachine *TM)=0
staticprotected
SmallVector<Module*, 1> llvm::ExecutionEngine::Modules
protected

The list of Modules that we are JIT'ing from. We use a SmallVector to optimize for the case where there is only one module.

Definition at line 126 of file ExecutionEngine/ExecutionEngine.h.

Referenced by llvm::JIT::addModule(), addModule(), emitGlobals(), ExecutionEngine(), FindFunctionNamed(), llvm::JIT::removeModule(), removeModule(), runStaticConstructorsDestructors(), ~ExecutionEngine(), and llvm::MCJIT::~MCJIT().


The documentation for this class was generated from the following files: