LLVM API Documentation
#include <Interpreter.h>
Static Public Member Functions | |
static void | Register () |
static ExecutionEngine * | create (Module *M, std::string *ErrorStr=0) |
![]() | |
static ExecutionEngine * | create (Module *M, bool ForceInterpreter=false, std::string *ErrorStr=0, CodeGenOpt::Level OptLevel=CodeGenOpt::Default, bool GVsWithCode=true) |
static ExecutionEngine * | createJIT (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) |
Additional Inherited Members | |
![]() | |
sys::Mutex | lock |
![]() | |
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) |
![]() | |
SmallVector< Module *, 1 > | Modules |
void *(* | LazyFunctionCreator )(const std::string &) |
![]() | |
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) |
Definition at line 83 of file lib/ExecutionEngine/Interpreter/Interpreter.h.
|
explicit |
Definition at line 47 of file Interpreter.cpp.
References llvm::ExecutionEngine::emitGlobals(), llvm::Intrinsic::memset, llvm::ExecutionEngine::setDataLayout(), and llvm::GenericValue::Untyped.
Referenced by create().
Interpreter::~Interpreter | ( | ) |
Definition at line 60 of file Interpreter.cpp.
|
inline |
Definition at line 197 of file lib/ExecutionEngine/Interpreter/Interpreter.h.
Referenced by lle_X_atexit().
GenericValue Interpreter::callExternalFunction | ( | Function * | F, |
const std::vector< GenericValue > & | ArgVals | ||
) |
Definition at line 247 of file ExternalFunctions.cpp.
References llvm::errs(), ExportedFunctions, FunctionsLock, llvm::ExecutionEngine::getDataLayout(), llvm::Function::getFunctionType(), llvm::Value::getName(), llvm::ExecutionEngine::getPointerToGlobalIfAvailable(), llvm::GlobalValue::getType(), lookupFunction(), llvm::report_fatal_error(), llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(), and TheInterpreter.
Referenced by callFunction().
void Interpreter::callFunction | ( | Function * | F, |
const std::vector< GenericValue > & | ArgVals | ||
) |
Definition at line 2074 of file Execution.cpp.
References llvm::Function::arg_begin(), llvm::Function::arg_end(), llvm::Function::arg_size(), llvm::BasicBlock::begin(), llvm::Function::begin(), callExternalFunction(), llvm::ExecutionContext::CurBB, llvm::ExecutionContext::CurFunction, llvm::ExecutionContext::CurInst, F(), llvm::Function::getFunctionType(), llvm::Function::getReturnType(), llvm::GlobalValue::isDeclaration(), llvm::FunctionType::isVarArg(), SetValue(), and llvm::ExecutionContext::VarArgs.
Referenced by runAtExitHandlers(), runFunction(), and visitCallSite().
|
static |
create - Create an interpreter ExecutionEngine. This can never fail.
create - Create a new interpreter object. This can never fail.
Definition at line 35 of file Interpreter.cpp.
References Interpreter(), and llvm::Module::MaterializeAllPermanently().
Referenced by Register().
void Interpreter::exitCalled | ( | GenericValue | GV | ) |
Definition at line 818 of file Execution.cpp.
References llvm::APInt::getZExtValue(), llvm::GenericValue::IntVal, runAtExitHandlers(), and llvm::APInt::zextOrTrunc().
Referenced by lle_X_exit().
|
inlinevirtual |
freeMachineCodeForFunction - The interpreter does not generate any code.
Implements llvm::ExecutionEngine.
Definition at line 133 of file lib/ExecutionEngine/Interpreter/Interpreter.h.
|
inline |
Definition at line 201 of file lib/ExecutionEngine/Interpreter/Interpreter.h.
|
inlinevirtual |
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.
Implements llvm::ExecutionEngine.
Definition at line 118 of file lib/ExecutionEngine/Interpreter/Interpreter.h.
|
inlinevirtual |
recompileAndRelinkFunction - For the interpreter, functions are always up-to-date.
Implements llvm::ExecutionEngine.
Definition at line 127 of file lib/ExecutionEngine/Interpreter/Interpreter.h.
|
inlinestatic |
Definition at line 105 of file lib/ExecutionEngine/Interpreter/Interpreter.h.
References create(), and llvm::ExecutionEngine::InterpCtor.
void Interpreter::run | ( | ) |
Definition at line 2112 of file Execution.cpp.
References llvm::ExecutionContext::CurInst, llvm::dbgs(), DEBUG, llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, llvm::APInt::getBitWidth(), llvm::Value::getType(), llvm::Type::getTypeID(), I, llvm::Type::IntegerTyID, llvm::GenericValue::IntVal, llvm_unreachable, llvm::Type::PointerTyID, llvm::GenericValue::PointerVal, llvm::APInt::toStringUnsigned(), llvm::ExecutionContext::Values, llvm::InstVisitor< Interpreter >::visit(), and llvm::Type::VoidTyID.
Referenced by runAtExitHandlers(), and runFunction().
void Interpreter::runAtExitHandlers | ( | ) |
runAtExitHandlers - Run any functions registered by the program's calls to atexit(3), which we intercept and store in AtExitHandlers.
Definition at line 64 of file Interpreter.cpp.
References callFunction(), and run().
Referenced by exitCalled().
|
virtual |
run - Start execution with the specified function and arguments.
Implements llvm::ExecutionEngine.
Definition at line 75 of file Interpreter.cpp.
References callFunction(), llvm::Function::getFunctionType(), llvm::FunctionType::getNumParams(), and run().
void Interpreter::visitAllocaInst | ( | AllocaInst & | I | ) |
Definition at line 960 of file Execution.cpp.
References llvm::dbgs(), DEBUG, llvm::SequentialType::getElementType(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::AllocaInst::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::tgtok::IntVal, llvm::LibFunc::malloc, llvm::GenericValue::PointerVal, llvm::PTOGV(), and SetValue().
void Interpreter::visitAShr | ( | BinaryOperator & | I | ) |
Definition at line 1189 of file Execution.cpp.
References llvm::GenericValue::AggregateVal, llvm::APInt::ashr(), llvm::User::getOperand(), getShiftAmount(), llvm::Value::getType(), llvm::APInt::getZExtValue(), llvm::GenericValue::IntVal, llvm::Type::isVectorTy(), and SetValue().
void Interpreter::visitBinaryOperator | ( | BinaryOperator & | I | ) |
Definition at line 679 of file Execution.cpp.
References llvm::GenericValue::AggregateVal, llvm::APIntOps::And(), llvm::dbgs(), executeFAddInst(), executeFDivInst(), executeFMulInst(), executeFRemInst(), executeFSubInst(), FLOAT_VECTOR_OP, llvm::LibFunc::fmod, llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), I, INTEGER_VECTOR_FUNCTION, INTEGER_VECTOR_OPERATION, llvm::GenericValue::IntVal, llvm::Type::isVectorTy(), llvm_unreachable, llvm::APIntOps::Or(), llvm::APInt::sdiv(), sdiv(), SetValue(), llvm::APInt::srem(), srem(), llvm::APInt::udiv(), llvm::APIntOps::udiv(), llvm::APInt::urem(), llvm::APIntOps::urem(), and llvm::APIntOps::Xor().
void Interpreter::visitBitCastInst | ( | BitCastInst & | I | ) |
Definition at line 1708 of file Execution.cpp.
References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().
void Interpreter::visitBranchInst | ( | BranchInst & | I | ) |
Definition at line 879 of file Execution.cpp.
References llvm::BranchInst::getCondition(), llvm::BranchInst::getSuccessor(), llvm::tgtok::IntVal, and llvm::BranchInst::isUnconditional().
|
inline |
Definition at line 172 of file lib/ExecutionEngine/Interpreter/Interpreter.h.
References visitCallSite().
void Interpreter::visitCallSite | ( | CallSite | CS | ) |
Definition at line 1062 of file Execution.cpp.
References llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_begin(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_end(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_size(), llvm::ExecutionContext::Caller, callFunction(), llvm::ExecutionContext::CurInst, F(), llvm::GenericValue::IntPair::first, llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledFunction(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledValue(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), llvm::Function::getIntrinsicID(), llvm::Instruction::getParent(), llvm::GVTOP(), llvm::GlobalValue::isDeclaration(), llvm::IntrinsicLowering::LowerIntrinsicCall(), llvm::Intrinsic::not_intrinsic, llvm::GenericValue::IntPair::second, SetValue(), llvm::GenericValue::UIntPairVal, llvm::Intrinsic::vacopy, llvm::Intrinsic::vaend, and llvm::Intrinsic::vastart.
Referenced by visitCallInst(), and visitInvokeInst().
void Interpreter::visitExtractElementInst | ( | ExtractElementInst & | I | ) |
Definition at line 1745 of file Execution.cpp.
References llvm::GenericValue::AggregateVal, llvm::dbgs(), llvm::Type::DoubleTyID, llvm::Type::FloatTyID, llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getTypeID(), llvm::Type::IntegerTyID, llvm_unreachable, and SetValue().
void Interpreter::visitExtractValueInst | ( | ExtractValueInst & | I | ) |
Definition at line 1883 of file Execution.cpp.
References llvm::GenericValue::AggregateVal, llvm::Type::ArrayTyID, llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, llvm::ExtractValueInst::getAggregateOperand(), llvm::ExtractValueInst::getIndexedType(), llvm::ExtractValueInst::getIndices(), llvm::ExtractValueInst::getNumIndices(), llvm::Value::getType(), llvm::Type::getTypeID(), llvm::ExtractValueInst::idx_begin(), llvm::Type::IntegerTyID, llvm::GenericValue::IntVal, llvm_unreachable, llvm::Type::PointerTyID, llvm::GenericValue::PointerVal, SetValue(), llvm::Type::StructTyID, and llvm::Type::VectorTyID.
void Interpreter::visitFCmpInst | ( | FCmpInst & | I | ) |
Definition at line 608 of file Execution.cpp.
References llvm::dbgs(), executeFCMP_BOOL(), executeFCMP_OEQ(), executeFCMP_OGE(), executeFCMP_OGT(), executeFCMP_OLE(), executeFCMP_OLT(), executeFCMP_ONE(), executeFCMP_ORD(), executeFCMP_UEQ(), executeFCMP_UGE(), executeFCMP_UGT(), executeFCMP_ULE(), executeFCMP_ULT(), executeFCMP_UNE(), executeFCMP_UNO(), llvm::CmpInst::FCMP_FALSE, llvm::CmpInst::FCMP_OEQ, llvm::CmpInst::FCMP_OGE, llvm::CmpInst::FCMP_OGT, llvm::CmpInst::FCMP_OLE, llvm::CmpInst::FCMP_OLT, llvm::CmpInst::FCMP_ONE, llvm::CmpInst::FCMP_ORD, llvm::CmpInst::FCMP_TRUE, llvm::CmpInst::FCMP_UEQ, llvm::CmpInst::FCMP_UGE, llvm::CmpInst::FCMP_UGT, llvm::CmpInst::FCMP_ULE, llvm::CmpInst::FCMP_ULT, llvm::CmpInst::FCMP_UNE, llvm::CmpInst::FCMP_UNO, llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::Value::getType(), I, llvm_unreachable, and SetValue().
void Interpreter::visitFPExtInst | ( | FPExtInst & | I | ) |
Definition at line 1673 of file Execution.cpp.
References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().
void Interpreter::visitFPToSIInst | ( | FPToSIInst & | I | ) |
Definition at line 1693 of file Execution.cpp.
References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().
void Interpreter::visitFPToUIInst | ( | FPToUIInst & | I | ) |
Definition at line 1688 of file Execution.cpp.
References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().
void Interpreter::visitFPTruncInst | ( | FPTruncInst & | I | ) |
Definition at line 1668 of file Execution.cpp.
References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().
void Interpreter::visitGetElementPtrInst | ( | GetElementPtrInst & | I | ) |
Definition at line 1031 of file Execution.cpp.
References llvm::gep_type_begin(), llvm::gep_type_end(), llvm::GetElementPtrInst::getPointerOperand(), and SetValue().
void Interpreter::visitICmpInst | ( | ICmpInst & | I | ) |
Definition at line 276 of file Execution.cpp.
References llvm::dbgs(), executeICMP_EQ(), executeICMP_NE(), executeICMP_SGE(), executeICMP_SGT(), executeICMP_SLE(), executeICMP_SLT(), executeICMP_UGE(), executeICMP_UGT(), executeICMP_ULE(), executeICMP_ULT(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::Value::getType(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm_unreachable, and SetValue().
void Interpreter::visitIndirectBrInst | ( | IndirectBrInst & | I | ) |
Definition at line 911 of file Execution.cpp.
References llvm::IndirectBrInst::getAddress(), and llvm::GVTOP().
void Interpreter::visitInsertElementInst | ( | InsertElementInst & | I | ) |
Definition at line 1778 of file Execution.cpp.
References llvm::GenericValue::AggregateVal, llvm::Type::DoubleTyID, llvm::Type::FloatTyID, llvm::Type::getContainedType(), llvm::User::getOperand(), llvm::InsertElementInst::getType(), llvm::Type::getTypeID(), llvm::Type::IntegerTyID, llvm::Type::isVectorTy(), llvm_unreachable, and SetValue().
void Interpreter::visitInsertValueInst | ( | InsertValueInst & | I | ) |
Definition at line 1925 of file Execution.cpp.
References llvm::GenericValue::AggregateVal, llvm::Type::ArrayTyID, llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, llvm::InsertValueInst::getAggregateOperand(), llvm::ExtractValueInst::getIndexedType(), llvm::InsertValueInst::getIndices(), llvm::InsertValueInst::getNumIndices(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getTypeID(), llvm::InsertValueInst::idx_begin(), llvm::Type::IntegerTyID, llvm::GenericValue::IntVal, llvm_unreachable, llvm::Type::PointerTyID, llvm::GenericValue::PointerVal, SetValue(), llvm::Type::StructTyID, and llvm::Type::VectorTyID.
|
inline |
Definition at line 188 of file lib/ExecutionEngine/Interpreter/Interpreter.h.
References llvm::errs(), and llvm_unreachable.
void Interpreter::visitIntToPtrInst | ( | IntToPtrInst & | I | ) |
Definition at line 1703 of file Execution.cpp.
References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().
|
inline |
Definition at line 173 of file lib/ExecutionEngine/Interpreter/Interpreter.h.
References visitCallSite().
void Interpreter::visitLoadInst | ( | LoadInst & | I | ) |
Definition at line 1037 of file Execution.cpp.
References llvm::dbgs(), llvm::LoadInst::getPointerOperand(), llvm::Value::getType(), llvm::GVTOP(), I, llvm::LoadInst::isVolatile(), llvm::ExecutionEngine::LoadValueFromMemory(), PrintVolatile, and SetValue().
void Interpreter::visitLShr | ( | BinaryOperator & | I | ) |
Definition at line 1162 of file Execution.cpp.
References llvm::GenericValue::AggregateVal, llvm::User::getOperand(), getShiftAmount(), llvm::Value::getType(), llvm::APInt::getZExtValue(), llvm::GenericValue::IntVal, llvm::Type::isVectorTy(), llvm::APInt::lshr(), and SetValue().
|
inline |
Definition at line 153 of file lib/ExecutionEngine/Interpreter/Interpreter.h.
References llvm_unreachable.
void Interpreter::visitPtrToIntInst | ( | PtrToIntInst & | I | ) |
Definition at line 1698 of file Execution.cpp.
References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().
void Interpreter::visitReturnInst | ( | ReturnInst & | I | ) |
Definition at line 861 of file Execution.cpp.
References llvm::Value::getContext(), llvm::User::getNumOperands(), llvm::ReturnInst::getReturnValue(), llvm::Value::getType(), and llvm::Type::getVoidTy().
void Interpreter::visitSelectInst | ( | SelectInst & | I | ) |
Definition at line 804 of file Execution.cpp.
References executeSelectInst(), llvm::User::getOperand(), llvm::Value::getType(), and SetValue().
void Interpreter::visitSExtInst | ( | SExtInst & | I | ) |
Definition at line 1658 of file Execution.cpp.
References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().
void Interpreter::visitShl | ( | BinaryOperator & | I | ) |
Definition at line 1135 of file Execution.cpp.
References llvm::GenericValue::AggregateVal, llvm::User::getOperand(), getShiftAmount(), llvm::Value::getType(), llvm::APInt::getZExtValue(), llvm::GenericValue::IntVal, llvm::Type::isVectorTy(), SetValue(), and llvm::APInt::shl().
void Interpreter::visitShuffleVectorInst | ( | ShuffleVectorInst & | I | ) |
Definition at line 1813 of file Execution.cpp.
References llvm::GenericValue::AggregateVal, llvm::Type::DoubleTyID, llvm::Type::FloatTyID, llvm::Type::getContainedType(), llvm::User::getOperand(), llvm::ShuffleVectorInst::getType(), llvm::Type::getTypeID(), llvm::Type::IntegerTyID, llvm::Type::isVectorTy(), llvm_unreachable, and SetValue().
void Interpreter::visitSIToFPInst | ( | SIToFPInst & | I | ) |
Definition at line 1683 of file Execution.cpp.
References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().
void Interpreter::visitStoreInst | ( | StoreInst & | I | ) |
Definition at line 1048 of file Execution.cpp.
References llvm::dbgs(), llvm::User::getOperand(), llvm::StoreInst::getPointerOperand(), llvm::Value::getType(), llvm::GVTOP(), I, llvm::StoreInst::isVolatile(), PrintVolatile, and llvm::ExecutionEngine::StoreValueToMemory().
void Interpreter::visitSwitchInst | ( | SwitchInst & | I | ) |
Definition at line 892 of file Execution.cpp.
References llvm::SwitchInst::case_begin(), llvm::SwitchInst::case_end(), executeICMP_EQ(), llvm::SwitchInst::getCondition(), llvm::SwitchInst::getDefaultDest(), llvm::Value::getType(), and llvm::GenericValue::IntVal.
void Interpreter::visitTruncInst | ( | TruncInst & | I | ) |
Definition at line 1653 of file Execution.cpp.
References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().
void Interpreter::visitUIToFPInst | ( | UIToFPInst & | I | ) |
Definition at line 1678 of file Execution.cpp.
References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().
void Interpreter::visitUnreachableInst | ( | UnreachableInst & | I | ) |
Definition at line 875 of file Execution.cpp.
References llvm::report_fatal_error().
void Interpreter::visitVAArgInst | ( | VAArgInst & | I | ) |
Definition at line 1716 of file Execution.cpp.
References llvm::dbgs(), llvm::GenericValue::IntPair::first, llvm::NVPTX::PTXLdStInstCode::Float, llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getTypeID(), IMPLEMENT_VAARG, llvm::Type::IntegerTyID, llvm::GenericValue::IntVal, llvm_unreachable, llvm::GenericValue::IntPair::second, SetValue(), and llvm::GenericValue::UIntPairVal.
void Interpreter::visitZExtInst | ( | ZExtInst & | I | ) |
Definition at line 1663 of file Execution.cpp.
References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().