LLVM API Documentation

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

#include <JIT.h>

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

Public Member Functions

 ~JIT ()
 
TargetJITInfogetJITInfo () const
 
virtual void addModule (Module *M)
 
virtual bool removeModule (Module *M)
 
virtual GenericValue runFunction (Function *F, const std::vector< GenericValue > &ArgValues)
 
virtual void * getPointerToNamedFunction (const std::string &Name, bool AbortOnFailure=true)
 
void * getPointerToFunction (Function *F)
 
void addPointerToBasicBlock (const BasicBlock *BB, void *Addr)
 addPointerToBasicBlock - Adds address of the specific basic block. More...
 
void clearPointerToBasicBlock (const BasicBlock *BB)
 clearPointerToBasicBlock - Removes address of specific basic block. More...
 
void * getPointerToBasicBlock (BasicBlock *BB)
 
void * getOrEmitGlobalVariable (const GlobalVariable *GV)
 
void * getPointerToFunctionOrStub (Function *F)
 
void * recompileAndRelinkFunction (Function *F)
 
void freeMachineCodeForFunction (Function *F)
 
void addPendingFunction (Function *F)
 
JITCodeEmittergetCodeEmitter () const
 
void runJITOnFunction (Function *F, MachineCodeInfo *MCI=0)
 
virtual void RegisterJITEventListener (JITEventListener *L)
 
virtual void UnregisterJITEventListener (JITEventListener *L)
 
void NotifyFunctionEmitted (const Function &F, void *Code, size_t Size, const JITEvent_EmittedFunctionDetails &Details)
 
void NotifyFreeingMachineCode (void *OldPtr)
 
BasicBlockAddressMapTygetBasicBlockAddressMap (const MutexGuard &)
 
- Public Member Functions inherited from llvm::ExecutionEngine
virtual ~ExecutionEngine ()
 
const DataLayoutgetDataLayout () const
 
virtual FunctionFindFunctionNamed (const char *FnName)
 
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 uint64_t getGlobalValueAddress (const std::string &Name)
 
virtual uint64_t getFunctionAddress (const std::string &Name)
 
const GlobalValuegetGlobalValueAtAddress (void *Addr)
 
void StoreValueToMemory (const GenericValue &Val, GenericValue *Ptr, Type *Ty)
 
void InitializeMemory (const Constant *Init, void *Addr)
 
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 void Register ()
 
static ExecutionEnginecreate (Module *M, std::string *Err, JITMemoryManager *JMM, CodeGenOpt::Level OptLevel=CodeGenOpt::Default, bool GVsWithCode=true, Reloc::Model RM=Reloc::Default, CodeModel::Model CMM=CodeModel::JITDefault)
 
static void CompilationCallback ()
 
static ExecutionEnginecreateJIT (Module *M, std::string *ErrorStr, JITMemoryManager *JMM, bool GVsWithCode, TargetMachine *TM)
 
- Static Public Member Functions inherited from llvm::ExecutionEngine
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)
 

Protected Member Functions

virtual char * getMemoryForGV (const GlobalVariable *GV)
 getMemoryforGV - Allocate memory for a global variable. More...
 
- Protected Member Functions inherited from llvm::ExecutionEngine
void setDataLayout (const DataLayout *td)
 
 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

- Public Attributes inherited from llvm::ExecutionEngine
sys::Mutex lock
 
- Protected Attributes inherited from llvm::ExecutionEngine
SmallVector< Module *, 1 > Modules
 
void *(* LazyFunctionCreator )(const std::string &)
 
- Static Protected Attributes inherited from llvm::ExecutionEngine
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)
 

Detailed Description

Definition at line 53 of file lib/ExecutionEngine/JIT/JIT.h.

Constructor & Destructor Documentation

JIT::~JIT ( )

Definition at line 166 of file JIT.cpp.

Member Function Documentation

void JIT::addModule ( Module M)
virtual

addModule - Add a new Module to the JIT. If we previously removed the last Module, we need re-initialize jitstate with a valid Module.

Reimplemented from llvm::ExecutionEngine.

Definition at line 177 of file JIT.cpp.

References llvm::ExecutionEngine::addModule(), llvm::TargetMachine::addPassesToEmitMachineCode(), llvm::TargetMachine::getDataLayout(), llvm::ExecutionEngine::lock, llvm::ExecutionEngine::Modules, and llvm::report_fatal_error().

void JIT::addPendingFunction ( Function F)

addPendingFunction - while jitting non-lazily, a called but non-codegen'd function was encountered. Add it to a pending list to be processed after the current function.

Definition at line 686 of file JIT.cpp.

References llvm::ExecutionEngine::lock.

void JIT::addPointerToBasicBlock ( const BasicBlock BB,
void *  Addr 
)

addPointerToBasicBlock - Adds address of the specific basic block.

Definition at line 533 of file JIT.cpp.

References llvm::sys::path::end(), llvm::ValueMap< KeyT, ValueT, Config >::find(), getBasicBlockAddressMap(), I, and llvm::ExecutionEngine::lock.

void JIT::clearPointerToBasicBlock ( const BasicBlock BB)

clearPointerToBasicBlock - Removes address of specific basic block.

Definition at line 545 of file JIT.cpp.

References llvm::ValueMap< KeyT, ValueT, Config >::erase(), getBasicBlockAddressMap(), and llvm::ExecutionEngine::lock.

static void llvm::JIT::CompilationCallback ( )
static
static ExecutionEngine* llvm::JIT::create ( Module M,
std::string *  Err,
JITMemoryManager JMM,
CodeGenOpt::Level  OptLevel = CodeGenOpt::Default,
bool  GVsWithCode = true,
Reloc::Model  RM = Reloc::Default,
CodeModel::Model  CMM = CodeModel::JITDefault 
)
inlinestatic

create - Create an return a new JIT compiler if there is one available for the current target. Otherwise, return null.

Definition at line 97 of file lib/ExecutionEngine/JIT/JIT.h.

References llvm::ExecutionEngine::createJIT(), and llvm::NVPTX::PTXCvtMode::RM.

ExecutionEngine * JIT::createJIT ( Module M,
std::string *  ErrorStr,
JITMemoryManager JMM,
bool  GVsWithCode,
TargetMachine TM 
)
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.

Definition at line 73 of file JIT.cpp.

References llvm::TargetMachine::getJITInfo(), and llvm::sys::DynamicLibrary::LoadLibraryPermanently().

Referenced by Register().

void JIT::freeMachineCodeForFunction ( Function F)
virtual

freeMachineCodeForFunction - deallocate memory used to code-generate this Function.

freeMachineCodeForFunction - release machine code memory for given Function.

Implements llvm::ExecutionEngine.

Definition at line 1244 of file JITEmitter.cpp.

References llvm::ExecutionEngine::updateGlobalMapping().

BasicBlockAddressMapTy& llvm::JIT::getBasicBlockAddressMap ( const MutexGuard )
inline
JITCodeEmitter* llvm::JIT::getCodeEmitter ( ) const
inline

getCodeEmitter - Return the code emitter this JIT is emitting into.

Definition at line 183 of file lib/ExecutionEngine/JIT/JIT.h.

Referenced by getPointerToFunctionOrStub().

TargetJITInfo& llvm::JIT::getJITInfo ( ) const
inline

getJITInfo - Return the target JIT information structure.

Definition at line 92 of file lib/ExecutionEngine/JIT/JIT.h.

char * JIT::getMemoryForGV ( const GlobalVariable GV)
protectedvirtual
void * JIT::getOrEmitGlobalVariable ( const GlobalVariable GV)
virtual
void * JIT::getPointerToBasicBlock ( BasicBlock BB)
virtual
void * JIT::getPointerToFunction ( Function F)
virtual

getPointerToFunction - This returns the address of the specified function, compiling it if necessary.

getPointerToFunction - This method is used to get the address of the specified function, compiling it if necessary.

Implements llvm::ExecutionEngine.

Definition at line 500 of file JIT.cpp.

References llvm::ExecutionEngine::addGlobalMapping(), llvm::Value::getName(), llvm::ExecutionEngine::getPointerToGlobalIfAvailable(), getPointerToNamedFunction(), llvm::GlobalValue::hasAvailableExternallyLinkage(), llvm::GlobalValue::hasExternalWeakLinkage(), llvm::GlobalValue::isDeclaration(), llvm::ExecutionEngine::lock, llvm::GlobalValue::Materialize(), and llvm::report_fatal_error().

Referenced by getPointerToBasicBlock(), recompileAndRelinkFunction(), and runFunction().

void * JIT::getPointerToFunctionOrStub ( Function F)
virtual

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.

Reimplemented from llvm::ExecutionEngine.

Definition at line 1217 of file JITEmitter.cpp.

References getCodeEmitter(), and llvm::ExecutionEngine::getPointerToGlobalIfAvailable().

void * JIT::getPointerToNamedFunction ( const std::string &  Name,
bool  AbortOnFailure = true 
)
virtual

getPointerToNamedFunction - This method returns the address of the specified function by using the MemoryManager. 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 567 of file JIT.cpp.

References llvm::RTDyldMemoryManager::getPointerToNamedFunction(), llvm::ExecutionEngine::isSymbolSearchingDisabled(), llvm::ExecutionEngine::LazyFunctionCreator, llvm::report_fatal_error(), and llvm::NVPTX::PTXCvtMode::RP.

Referenced by getPointerToFunction().

void JIT::NotifyFreeingMachineCode ( void *  OldPtr)

Definition at line 431 of file JIT.cpp.

References I, and llvm::ExecutionEngine::lock.

void JIT::NotifyFunctionEmitted ( const Function F,
void *  Code,
size_t  Size,
const JITEvent_EmittedFunctionDetails Details 
)

These functions correspond to the methods on JITEventListener. They iterate over the registered listeners and call the corresponding method on each.

Definition at line 421 of file JIT.cpp.

References I, and llvm::ExecutionEngine::lock.

Referenced by runJITOnFunction().

void * JIT::recompileAndRelinkFunction ( Function F)
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 JIT::getPointerToFunction().

Implements llvm::ExecutionEngine.

Definition at line 625 of file JIT.cpp.

References llvm::ExecutionEngine::addGlobalMapping(), getPointerToFunction(), llvm::ExecutionEngine::getPointerToGlobalIfAvailable(), llvm::TargetJITInfo::replaceMachineCodeForFunction(), and runJITOnFunction().

static void llvm::JIT::Register ( )
inlinestatic

Definition at line 86 of file lib/ExecutionEngine/JIT/JIT.h.

References createJIT(), and llvm::ExecutionEngine::JITCtor.

void JIT::RegisterJITEventListener ( JITEventListener )
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 404 of file JIT.cpp.

References llvm::ExecutionEngine::lock.

Referenced by runJITOnFunction().

bool JIT::removeModule ( Module M)
virtual

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

removeModule - If we are removing the last Module, invalidate the jitstate since the PassManager it contains references a released Module.

Reimplemented from llvm::ExecutionEngine.

Definition at line 203 of file JIT.cpp.

References llvm::TargetMachine::addPassesToEmitMachineCode(), llvm::TargetMachine::getDataLayout(), llvm::ExecutionEngine::lock, llvm::ExecutionEngine::Modules, llvm::ExecutionEngine::removeModule(), and llvm::report_fatal_error().

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

runFunction - Start execution with the specified function and arguments.

run - Start execution with the specified function and arguments.

Implements llvm::ExecutionEngine.

Definition at line 233 of file JIT.cpp.

References llvm::lltok::APFloat, llvm::CallingConv::C, llvm::BasicBlock::Create(), llvm::Function::Create(), llvm::CallInst::Create(), llvm::ReturnInst::Create(), llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::Function::eraseFromParent(), llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, llvm::Type::FP128TyID, llvm::ConstantInt::get(), llvm::FunctionType::get(), llvm::ConstantFP::get(), getBitWidth(), llvm::Function::getCallingConv(), llvm::Function::getContext(), llvm::Type::getFltSemantics(), llvm::Function::getFunctionType(), llvm::Type::getInt32Ty(), llvm::Type::getInt64Ty(), llvm::ConstantExpr::getIntToPtr(), llvm::FunctionType::getNumParams(), llvm::FunctionType::getParamType(), llvm::GlobalValue::getParent(), getPointerToFunction(), llvm::FunctionType::getReturnType(), llvm::Value::getType(), llvm::Type::getTypeID(), llvm::GVTOP(), llvm::Type::IntegerTyID, llvm::GlobalValue::InternalLinkage, 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::CallInst::setCallingConv(), llvm::CallInst::setTailCall(), llvm::Type::VoidTyID, and llvm::Type::X86_FP80TyID.

void JIT::runJITOnFunction ( Function F,
MachineCodeInfo MCI = 0 
)
virtual

runJITOnFunction - Run the FunctionPassManager full of just-in-time compilation passes on F, hopefully filling in GlobalAddress[F] with the address of F's machine code.

Reimplemented from llvm::ExecutionEngine.

Definition at line 442 of file JIT.cpp.

References llvm::tgtok::Code, llvm::ExecutionEngine::lock, NotifyFunctionEmitted(), RegisterJITEventListener(), llvm::MachineCodeInfo::setAddress(), llvm::MachineCodeInfo::setSize(), and UnregisterJITEventListener().

Referenced by recompileAndRelinkFunction().

void JIT::UnregisterJITEventListener ( JITEventListener L)
virtual

Reimplemented from llvm::ExecutionEngine.

Definition at line 410 of file JIT.cpp.

References I, llvm::ExecutionEngine::lock, and std::swap().

Referenced by runJITOnFunction().


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