LLVM API Documentation

Public Member Functions | Static Public Member Functions | Protected Member Functions
llvm::JIT Class Reference

#include <JIT.h>

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

List of all members.

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.
void clearPointerToBasicBlock (const BasicBlock *BB)
 clearPointerToBasicBlock - Removes address of specific basic block.
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 &)

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)

Protected Member Functions

virtual char * getMemoryForGV (const GlobalVariable *GV)
 getMemoryforGV - Allocate memory for a global variable.

Detailed Description

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


Constructor & Destructor Documentation

JIT::~JIT ( )

Definition at line 320 of file JIT.cpp.

References llvm::ExecutionEngine::DeregisterAllTables().


Member Function Documentation

void JIT::addModule ( Module M) [virtual]
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 842 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 689 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 701 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 
) [inline, static]

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 createJIT().

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 207 of file JIT.cpp.

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

Referenced by create(), and 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) [protected, virtual]
void * JIT::getOrEmitGlobalVariable ( const GlobalVariable GV) [virtual]
void * JIT::getPointerToBasicBlock ( BasicBlock BB) [virtual]

getPointerToBasicBlock - This returns the address of the specified basic block, assuming function is compiled.

Implements llvm::ExecutionEngine.

Definition at line 706 of file JIT.cpp.

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

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 656 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 723 of file JIT.cpp.

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

Referenced by getPointerToFunction().

void JIT::NotifyFreeingMachineCode ( void *  OldPtr)

Definition at line 587 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 577 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 781 of file JIT.cpp.

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

static void llvm::JIT::Register ( ) [inline, static]

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 560 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 359 of file JIT.cpp.

References llvm::FunctionPassManager::add(), llvm::TargetMachine::addPassesToEmitMachineCode(), llvm::FunctionPassManager::doInitialization(), llvm::SmallVectorBase::empty(), llvm::TargetMachine::getDataLayout(), llvm::ExecutionEngine::lock, llvm::ExecutionEngine::Modules, 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 389 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::RetTy, 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 598 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 566 of file JIT.cpp.

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

Referenced by runJITOnFunction().


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