LLVM API Documentation

llvm::JIT Class Reference

#include <JIT.h>

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

List of all members.

Public Member Functions

 ~JIT ()
TargetJITInfo & getJITInfo () const
virtual void addModuleProvider (ModuleProvider *MP)
virtual Module * removeModuleProvider (ModuleProvider *MP, std::string *ErrInfo=0)
virtual void deleteModuleProvider (ModuleProvider *P, std::string *ErrInfo=0)
virtual GenericValue runFunction (Function *F, const std::vector< GenericValue > &ArgValues)
void * getPointerToNamedFunction (const std::string &Name, bool AbortOnFailure=true)
void * getPointerToFunction (Function *F)
void * getOrEmitGlobalVariable (const GlobalVariable *GV)
void * getPointerToFunctionOrStub (Function *F)
void * recompileAndRelinkFunction (Function *F)
void freeMachineCodeForFunction (Function *F)
void addPendingFunction (Function *F)
JITCodeEmitter * getCodeEmitter () 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 (const Function &F, void *OldPtr)

Static Public Member Functions

static void Register ()
static ExecutionEngine * create (ModuleProvider *MP, std::string *Err, JITMemoryManager *JMM, CodeGenOpt::Level OptLevel=CodeGenOpt::Default, bool GVsWithCode=true)
static void CompilationCallback ()
static TargetMachine * selectTarget (ModuleProvider *MP, std::string *Err)
static ExecutionEngine * createJIT (ModuleProvider *MP, std::string *ErrorStr, JITMemoryManager *JMM, CodeGenOpt::Level OptLevel, bool GVsWithCode)

Protected Member Functions

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


Detailed Description

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


Constructor & Destructor Documentation

JIT::~JIT (  ) 

Definition at line 272 of file JIT.cpp.

References TM.


Member Function Documentation

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

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

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

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

getJITInfo - Return the target JIT information structure.

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

static ExecutionEngine* llvm::JIT::create ( ModuleProvider *  MP,
std::string *  Err,
JITMemoryManager *  JMM,
CodeGenOpt::Level  OptLevel = CodeGenOpt::Default,
bool  GVsWithCode = true 
) [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 82 of file lib/ExecutionEngine/JIT/JIT.h.

References llvm::ExecutionEngine::createJIT().

Referenced by Register().

void JIT::addModuleProvider ( ModuleProvider *  MP  )  [virtual]

Module * JIT::removeModuleProvider ( ModuleProvider *  MP,
std::string *  E = 0 
) [virtual]

removeModuleProvider - Remove a ModuleProvider from the list of modules. Relases the Module from the ModuleProvider, materializing it in the process, and returns the materialized Module.

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

Reimplemented from llvm::ExecutionEngine.

Definition at line 308 of file JIT.cpp.

References llvm::FunctionPassManager::add(), llvm::TargetMachine::addPassesToEmitMachineCode(), llvm::CodeGenOpt::Default, llvm::FunctionPassManager::doInitialization(), llvm::TargetMachine::getTargetData(), llvm::llvm_report_error(), llvm::ExecutionEngine::lock, llvm::ExecutionEngine::Modules, llvm::ExecutionEngine::removeModuleProvider(), and TM.

void JIT::deleteModuleProvider ( ModuleProvider *  MP,
std::string *  E = 0 
) [virtual]

deleteModuleProvider - Remove a ModuleProvider from the list of modules, and deletes the ModuleProvider and owned Module. Avoids materializing the underlying module.

deleteModuleProvider - Remove a ModuleProvider from the list of modules, and deletes the ModuleProvider and owned Module. Avoids materializing the underlying module.

Reimplemented from llvm::ExecutionEngine.

Definition at line 339 of file JIT.cpp.

References llvm::FunctionPassManager::add(), llvm::TargetMachine::addPassesToEmitMachineCode(), llvm::CodeGenOpt::Default, llvm::ExecutionEngine::deleteModuleProvider(), llvm::FunctionPassManager::doInitialization(), llvm::TargetMachine::getTargetData(), llvm::llvm_report_error(), llvm::ExecutionEngine::lock, llvm::ExecutionEngine::Modules, and TM.

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

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

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.

getPointerToNamedFunction - This method returns the address of the specified function by using the dynamic loader interface. As such it is only useful for resolving library symbols, not code generated symbols.

If a LazyFunctionCreator is installed, use it to get/create the function.

Definition at line 99 of file Intercept.cpp.

References llvm::ExecutionEngine::isSymbolSearchingDisabled(), jit_atexit(), jit_exit(), llvm::ExecutionEngine::LazyFunctionCreator, llvm::llvm_report_error(), llvm::cl::Prefix, and llvm::sys::DynamicLibrary::SearchForAddressOfSymbol().

Referenced by getPointerToFunction(), and getPointerToNamedFunction().

static void llvm::JIT::CompilationCallback (  )  [static]

void * JIT::getPointerToFunction ( Function *  F  )  [virtual]

void * JIT::getOrEmitGlobalVariable ( const GlobalVariable *  GV  )  [virtual]

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

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

Reimplemented from llvm::ExecutionEngine.

Definition at line 680 of file JIT.cpp.

References llvm::ExecutionEngine::addGlobalMapping(), llvm::ExecutionEngine::areDlsymStubsEnabled(), llvm::ExecutionEngine::EmitGlobalVariable(), getMemoryForGV(), llvm::Value::getName(), llvm::ExecutionEngine::getPointerToGlobalIfAvailable(), llvm::GlobalVariable::isDeclaration(), llvm::llvm_report_error(), llvm::ExecutionEngine::lock, and llvm::sys::DynamicLibrary::SearchForAddressOfSymbol().

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 1415 of file JITEmitter.cpp.

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

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

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

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

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 1526 of file JITEmitter.cpp.

References NotifyFreeingMachineCode(), and llvm::ExecutionEngine::updateGlobalMapping().

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

References llvm::ExecutionEngine::lock.

JITCodeEmitter* llvm::JIT::getCodeEmitter (  )  const [inline]

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

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

Referenced by getPointerToFunctionOrStub().

TargetMachine * JIT::selectTarget ( ModuleProvider *  MP,
std::string *  ErrorStr 
) [static]

selectTarget - Pick a target either via -march or by guessing the native arch. Add any CPU features specified via -mcpu or -mattr.

selectTarget - Pick a target either via -march or by guessing the native arch. Add any CPU features specified via -mcpu or -mattr.

Definition at line 45 of file TargetSelect.cpp.

References llvm::SubtargetFeatures::AddFeature(), llvm::TargetRegistry::begin(), llvm::Target::createTargetMachine(), llvm::TargetRegistry::end(), Error(), llvm::errs(), llvm::Triple::getArchTypeForLLVMName(), llvm::sys::getHostTriple(), llvm::ModuleProvider::getModule(), llvm::SubtargetFeatures::getString(), llvm::Module::getTargetTriple(), llvm::Target::hasJIT(), llvm::TargetRegistry::lookupTarget(), MArch, MAttrs, MCPU, Mod, llvm::SubtargetFeatures::setCPU(), and llvm::Triple::UnknownArch.

Referenced by createJIT().

ExecutionEngine * JIT::createJIT ( ModuleProvider *  MP,
std::string *  ErrorStr,
JITMemoryManager *  JMM,
CodeGenOpt::Level  OptLevel,
bool  GVsWithCode 
) [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 ModuleProvider 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 provider.

Reimplemented from llvm::ExecutionEngine.

Definition at line 205 of file JIT.cpp.

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

Referenced by llvm::ExecutionEngine::createJIT().

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

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

Referenced by recompileAndRelinkFunction().

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

References llvm::ExecutionEngine::lock.

Referenced by runJITOnFunction().

void JIT::UnregisterJITEventListener ( JITEventListener *  L  )  [virtual]

Reimplemented from llvm::ExecutionEngine.

Definition at line 538 of file JIT.cpp.

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

Referenced by runJITOnFunction().

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

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

Referenced by runJITOnFunction().

void JIT::NotifyFreeingMachineCode ( const Function &  F,
void *  OldPtr 
)

Definition at line 559 of file JIT.cpp.

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

Referenced by freeMachineCodeForFunction().

char * JIT::getMemoryForGV ( const GlobalVariable *  GV  )  [protected, virtual]


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