LLVM API Documentation
#include <JIT.h>
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) |
| MachineCodeEmitter * | getCodeEmitter () const |
| getCodeEmitter - Return the code emitter this JIT is emitting into. | |
Static Public Member Functions | |
| static void | Register () |
| static ExecutionEngine * | create (ModuleProvider *MP, std::string *Err, bool Fast=false) |
| static void | CompilationCallback () |
| static ExecutionEngine * | createJIT (ModuleProvider *MP, std::string *Err, JITMemoryManager *JMM, bool Fast) |
Protected Member Functions | |
| virtual char * | getMemoryForGV (const GlobalVariable *GV) |
| getMemoryforGV - Allocate memory for a global variable. | |
Definition at line 51 of file lib/ExecutionEngine/JIT/JIT.h.
| static void llvm::JIT::Register | ( | ) | [inline, static] |
Definition at line 63 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 69 of file lib/ExecutionEngine/JIT/JIT.h.
| static ExecutionEngine* llvm::JIT::create | ( | ModuleProvider * | MP, | |
| std::string * | Err, | |||
| bool | Fast = false | |||
| ) | [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 74 of file lib/ExecutionEngine/JIT/JIT.h.
References createJIT().
Referenced by Register().
| void JIT::addModuleProvider | ( | ModuleProvider * | MP | ) | [virtual] |
addModuleProvider - Add a new ModuleProvider to the JIT. If we previously removed the last ModuleProvider, we need re-initialize jitstate with a valid ModuleProvider.
Reimplemented from llvm::ExecutionEngine.
Definition at line 260 of file JIT.cpp.
References llvm::FunctionPassManager::add(), llvm::ExecutionEngine::addModuleProvider(), llvm::TargetMachine::addPassesToEmitMachineCode(), llvm::cerr(), llvm::FunctionPassManager::doInitialization(), llvm::TargetMachine::getTargetData(), llvm::ExecutionEngine::lock, MCE, llvm::ExecutionEngine::Modules, and TM.
| 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 288 of file JIT.cpp.
References llvm::ExecutionEngine::lock, llvm::ExecutionEngine::Modules, and llvm::ExecutionEngine::removeModuleProvider().
| 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 303 of file JIT.cpp.
References llvm::ExecutionEngine::deleteModuleProvider(), llvm::ExecutionEngine::lock, and llvm::ExecutionEngine::Modules.
| 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 315 of file JIT.cpp.
References llvm::lltok::APFloat, llvm::SmallVectorImpl< T >::begin(), llvm::CallingConv::C, llvm::ReturnInst::Create(), llvm::CallInst::Create(), llvm::BasicBlock::Create(), llvm::Function::Create(), llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::SmallVectorImpl< T >::end(), llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, llvm::Type::FP128TyID, llvm::ConstantFP::get(), llvm::ConstantInt::get(), llvm::FunctionType::get(), llvm::Function::getCallingConv(), llvm::Function::getFunctionType(), 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::Int32Ty, llvm::Type::Int64Ty, llvm::Type::IntegerTyID, llvm::GlobalValue::InternalLinkage, llvm::GenericValue::IntVal, llvm::FunctionType::isVarArg(), llvm::Type::PointerTyID, llvm::Type::PPC_FP128TyID, llvm::PTOGV(), llvm::SmallVectorImpl< T >::push_back(), llvm::RetTy, llvm::CallInst::setCallingConv(), llvm::CallInst::setTailCall(), llvm::PICStyles::Stub, llvm::Type::VoidTy, llvm::Type::VoidTyID, and llvm::Type::X86_FP80TyID.
| 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 93 of file Intercept.cpp.
References llvm::cerr(), llvm::ExecutionEngine::isSymbolSearchingDisabled(), jit_atexit(), jit_exit(), llvm::ExecutionEngine::LazyFunctionCreator, 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] |
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 neccesary.
Implements llvm::ExecutionEngine.
Definition at line 501 of file JIT.cpp.
References llvm::ExecutionEngine::addGlobalMapping(), llvm::cerr(), llvm::GlobalValue::ExternalWeakLinkage, llvm::GlobalValue::getLinkage(), llvm::Value::getName(), llvm::GlobalValue::getParent(), llvm::ExecutionEngine::getPointerToGlobalIfAvailable(), getPointerToNamedFunction(), llvm::GlobalValue::hasNotBeenReadFromBitcode(), llvm::Function::isDeclaration(), llvm::ExecutionEngine::lock, M, llvm::ModuleProvider::materializeFunction(), and llvm::ExecutionEngine::Modules.
Referenced by getPointerToNamedFunction(), recompileAndRelinkFunction(), and runFunction().
| 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 550 of file JIT.cpp.
References A, llvm::ExecutionEngine::addGlobalMapping(), llvm::TargetJITInfo::allocateSeparateGVMemory(), llvm::MachineCodeEmitter::allocateSpace(), llvm::TargetJITInfo::allocateThreadLocalMemory(), llvm::cerr(), llvm::ExecutionEngine::EmitGlobalVariable(), llvm::SequentialType::getElementType(), llvm::Value::getName(), llvm::ExecutionEngine::getPointerToGlobalIfAvailable(), llvm::TargetData::getPreferredAlignment(), llvm::ExecutionEngine::getTargetData(), llvm::GlobalValue::getType(), llvm::TargetData::getTypePaddedSize(), llvm::GlobalVariable::isConstant(), llvm::GlobalVariable::isDeclaration(), llvm::ExecutionEngine::isGVCompilationDisabled(), llvm::GlobalVariable::isThreadLocal(), llvm::ExecutionEngine::lock, MCE, 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 1240 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 611 of file JIT.cpp.
References llvm::ExecutionEngine::addGlobalMapping(), getPointerToFunction(), llvm::ExecutionEngine::getPointerToGlobalIfAvailable(), and llvm::TargetJITInfo::replaceMachineCodeForFunction().
| 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 1253 of file JITEmitter.cpp.
References RemoveFunctionFromSymbolTable(), and llvm::ExecutionEngine::updateGlobalMapping().
| MachineCodeEmitter* llvm::JIT::getCodeEmitter | ( | ) | const [inline] |
getCodeEmitter - Return the code emitter this JIT is emitting into.
Definition at line 143 of file lib/ExecutionEngine/JIT/JIT.h.
Referenced by getPointerToFunctionOrStub().
| ExecutionEngine * JIT::createJIT | ( | ModuleProvider * | MP, | |
| std::string * | ErrorStr, | |||
| JITMemoryManager * | JMM, | |||
| bool | Fast | |||
| ) | [static] |
createInternal - Create an return a new JIT compiler if there is one available for the current target. Otherwise, return null.
Reimplemented from llvm::ExecutionEngine.
Definition at line 44 of file TargetSelect.cpp.
References llvm::SubtargetFeatures::AddFeature(), llvm::cerr(), Error(), llvm::TargetMachineRegistry::getClosestTargetForJIT(), llvm::TargetMachine::getJITInfo(), llvm::ModuleProvider::getModule(), llvm::SubtargetFeatures::getString(), MArch, MAttrs, MCPU, and llvm::SubtargetFeatures::setCPU().
Referenced by create(), and llvm::ExecutionEngine::createJIT().
| char * JIT::getMemoryForGV | ( | const GlobalVariable * | GV | ) | [protected, virtual] |
getMemoryforGV - Allocate memory for a global variable.
getMemoryForGV - This method abstracts memory allocation of global variable so that the JIT can allocate thread local variables depending on the target.
Reimplemented from llvm::ExecutionEngine.
Definition at line 634 of file JIT.cpp.
References llvm::TargetJITInfo::allocateThreadLocalMemory(), llvm::SequentialType::getElementType(), llvm::ExecutionEngine::getTargetData(), llvm::GlobalValue::getType(), llvm::TargetData::getTypePaddedSize(), llvm::GlobalVariable::isThreadLocal(), and llvm::ExecutionEngine::lock.