LLVM: llvm::Interpreter Class Reference (original) (raw)

Public Member Functions

Interpreter (std::unique_ptr< Module > M)

~Interpreter () override

void

runAtExitHandlers ()

runAtExitHandlers - Run any functions registered by the program's calls to atexit(3), which we intercept and store in AtExitHandlers.

GenericValue

runFunction (Function *F, ArrayRef< GenericValue > ArgValues) override

run - Start execution with the specified function and arguments.

void *

getPointerToNamedFunction (StringRef Name, bool AbortOnFailure=true) override

getPointerToNamedFunction - This method returns the address of the specified function by using the dlsym function call.

void

callFunction (Function *F, ArrayRef< GenericValue > ArgVals)

void

run ()

void

visitReturnInst (ReturnInst &I)

void

visitBranchInst (BranchInst &I)

void

visitSwitchInst (SwitchInst &I)

void

visitIndirectBrInst (IndirectBrInst &I)

void

visitUnaryOperator (UnaryOperator &I)

void

visitBinaryOperator (BinaryOperator &I)

void

visitICmpInst (ICmpInst &I)

void

visitFCmpInst (FCmpInst &I)

void

visitAllocaInst (AllocaInst &I)

void

visitLoadInst (LoadInst &I)

void

visitStoreInst (StoreInst &I)

void

visitGetElementPtrInst (GetElementPtrInst &I)

void

visitPHINode (PHINode &PN)

void

visitTruncInst (TruncInst &I)

void

visitZExtInst (ZExtInst &I)

void

visitSExtInst (SExtInst &I)

void

visitFPTruncInst (FPTruncInst &I)

void

visitFPExtInst (FPExtInst &I)

void

visitUIToFPInst (UIToFPInst &I)

void

visitSIToFPInst (SIToFPInst &I)

void

visitFPToUIInst (FPToUIInst &I)

void

visitFPToSIInst (FPToSIInst &I)

void

visitPtrToIntInst (PtrToIntInst &I)

void

visitIntToPtrInst (IntToPtrInst &I)

void

visitBitCastInst (BitCastInst &I)

void

visitSelectInst (SelectInst &I)

void

visitVAStartInst (VAStartInst &I)

void

visitVAEndInst (VAEndInst &I)

void

visitVACopyInst (VACopyInst &I)

void

visitIntrinsicInst (IntrinsicInst &I)

void

visitCallBase (CallBase &I)

void

visitUnreachableInst (UnreachableInst &I)

void

visitShl (BinaryOperator &I)

void

visitLShr (BinaryOperator &I)

void

visitAShr (BinaryOperator &I)

void

visitVAArgInst (VAArgInst &I)

void

visitExtractElementInst (ExtractElementInst &I)

void

visitInsertElementInst (InsertElementInst &I)

void

visitShuffleVectorInst (ShuffleVectorInst &I)

void

visitExtractValueInst (ExtractValueInst &I)

void

visitInsertValueInst (InsertValueInst &I)

void

visitInstruction (Instruction &I)

GenericValue

callExternalFunction (Function *F, ArrayRef< GenericValue > ArgVals)

void

exitCalled (GenericValue GV)

void

addAtExitHandler (Function *F)

GenericValue *

getFirstVarArg ()

Public Member Functions inherited from llvm::ExecutionEngine

virtual

~ExecutionEngine ()

virtual void

addModule (std::unique_ptr< Module > M)

Add a Module to the list of modules that we can JIT from.

virtual void

addObjectFile (std::unique_ptr< object::ObjectFile > O)

addObjectFile - Add an ObjectFile to the execution engine.

virtual void

addObjectFile (object::OwningBinary< object::ObjectFile > O)

virtual void

addArchive (object::OwningBinary< object::Archive > A)

addArchive - Add an Archive to the execution engine.

const DataLayout &

getDataLayout () const

virtual bool

removeModule (Module *M)

removeModule - Removes a Module from the list of modules, but does not free the module's memory.

virtual Function *

FindFunctionNamed (StringRef FnName)

FindFunctionNamed - Search all of the active modules to find the function that defines FnName.

virtual GlobalVariable *

FindGlobalVariableNamed (StringRef Name, bool AllowInternal=false)

FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines Name.

virtual void

mapSectionAddress (const void *LocalAddress, uint64_t TargetAddress)

mapSectionAddress - map a section to its target address space value.

virtual void

generateCodeForModule (Module *M)

generateCodeForModule - Run code generation for the specified module and load it into memory.

virtual void

finalizeObject ()

finalizeObject - ensure the module is fully processed and is usable.

bool

hasError () const

Returns true if an error has been recorded.

void

clearErrorMessage ()

Clear the error message.

const std::string &

getErrorMessage () const

Returns the most recent error message.

virtual void

runStaticConstructorsDestructors (bool isDtors)

runStaticConstructorsDestructors - This method is used to execute all of the static constructors or destructors for a program.

void

runStaticConstructorsDestructors (Module &module, bool isDtors)

This method is used to execute all of the static constructors or destructors for a particular module.

int

runFunctionAsMain (Function *Fn, const std::vector< std::string > &argv, const char *const *envp)

runFunctionAsMain - This is a helper function which wraps runFunction to handle the common task of starting up main with the specified argc, argv, and envp parameters.

void

addGlobalMapping (const GlobalValue *GV, void *Addr)

addGlobalMapping - Tell the execution engine that the specified global is at the specified location.

void

addGlobalMapping (StringRef Name, uint64_t Addr)

void

clearAllGlobalMappings ()

clearAllGlobalMappings - Clear all global mappings and start over again, for use in dynamic compilation scenarios to move globals.

void

clearGlobalMappingsFromModule (Module *M)

clearGlobalMappingsFromModule - Clear all global mappings that came from a particular module, because it has been removed from the JIT.

uint64_t

updateGlobalMapping (const GlobalValue *GV, void *Addr)

updateGlobalMapping - Replace an existing mapping for GV with a new address.

uint64_t

updateGlobalMapping (StringRef Name, uint64_t Addr)

uint64_t

getAddressToGlobalIfAvailable (StringRef S)

getAddressToGlobalIfAvailable - This returns the address of the specified global symbol.

void *

getPointerToGlobalIfAvailable (StringRef S)

getPointerToGlobalIfAvailable - This returns the address of the specified global value if it is has already been codegen'd, otherwise it returns null.

void *

getPointerToGlobalIfAvailable (const GlobalValue *GV)

void *

getPointerToGlobal (const GlobalValue *GV)

getPointerToGlobal - This returns the address of the specified global value.

virtual void *

getPointerToFunctionOrStub (Function *F)

getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the function.

virtual uint64_t

getGlobalValueAddress (const std::string &Name)

getGlobalValueAddress - Return the address of the specified global value.

virtual uint64_t

getFunctionAddress (const std::string &Name)

getFunctionAddress - Return the address of the specified function.

const GlobalValue *

getGlobalValueAtAddress (void *Addr)

getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address.

void

StoreValueToMemory (const GenericValue &Val, GenericValue *Ptr, Type *Ty)

StoreValueToMemory - Stores the data in Val of type Ty at address Ptr.

void

InitializeMemory (const Constant *Init, void *Addr)

virtual void *

getOrEmitGlobalVariable (const GlobalVariable *GV)

getOrEmitGlobalVariable - Return the address of the specified global variable, possibly emitting it to memory if needed.

virtual void

RegisterJITEventListener (JITEventListener *)

Registers a listener to be called back on various events within the JIT.

virtual void

UnregisterJITEventListener (JITEventListener *)

virtual void

setObjectCache (ObjectCache *)

Sets the pre-compiled object cache.

virtual void

setProcessAllSections (bool ProcessAllSections)

setProcessAllSections (MCJIT Only): By default, only sections that are "required for execution" are passed to the RTDyldMemoryManager, and other sections are discarded.

virtual TargetMachine *

getTargetMachine ()

Return the target machine (if available).

void

DisableLazyCompilation (bool Disabled=true)

DisableLazyCompilation - When lazy compilation is off (the default), the JIT will eagerly compile every function reachable from the argument to getPointerToFunction.

bool

isCompilingLazily () const

void

DisableGVCompilation (bool Disabled=true)

DisableGVCompilation - If called, the JIT will abort if it's asked to allocate space and populate a GlobalVariable that is not internal to the module.

bool

isGVCompilationDisabled () const

void

DisableSymbolSearching (bool Disabled=true)

DisableSymbolSearching - If called, the JIT will not try to lookup unknown symbols with dlsym.

bool

isSymbolSearchingDisabled () const

void

setVerifyModules (bool Verify)

Enable/Disable IR module verification.

bool

getVerifyModules () const

void

InstallLazyFunctionCreator (FunctionCreator C)

InstallLazyFunctionCreator - If an unknown function is needed, the specified function pointer is invoked to create it.

Public Member Functions inherited from llvm::InstVisitor< Interpreter >

void

visit (Iterator Start, Iterator End)

void

visitModule (Module &M)

void

visitFunction (Function &F)

void

visitBasicBlock (BasicBlock &BB)

void

visitICmpInst (ICmpInst &I)

void

visitFCmpInst (FCmpInst &I)

void

visitAllocaInst (AllocaInst &I)

void

visitLoadInst (LoadInst &I)

void

visitStoreInst (StoreInst &I)

void

visitAtomicCmpXchgInst (AtomicCmpXchgInst &I)

void

visitAtomicRMWInst (AtomicRMWInst &I)

void

visitFenceInst (FenceInst &I)

void

visitGetElementPtrInst (GetElementPtrInst &I)

void

visitPHINode (PHINode &I)

void

visitTruncInst (TruncInst &I)

void

visitZExtInst (ZExtInst &I)

void

visitSExtInst (SExtInst &I)

void

visitFPTruncInst (FPTruncInst &I)

void

visitFPExtInst (FPExtInst &I)

void

visitFPToUIInst (FPToUIInst &I)

void

visitFPToSIInst (FPToSIInst &I)

void

visitUIToFPInst (UIToFPInst &I)

void

visitSIToFPInst (SIToFPInst &I)

void

visitPtrToIntInst (PtrToIntInst &I)

void

visitPtrToAddrInst (PtrToAddrInst &I)

void

visitIntToPtrInst (IntToPtrInst &I)

void

visitBitCastInst (BitCastInst &I)

void

visitAddrSpaceCastInst (AddrSpaceCastInst &I)

void

visitSelectInst (SelectInst &I)

void

visitVAArgInst (VAArgInst &I)

void

visitExtractElementInst (ExtractElementInst &I)

void

visitInsertElementInst (InsertElementInst &I)

void

visitShuffleVectorInst (ShuffleVectorInst &I)

void

visitExtractValueInst (ExtractValueInst &I)

void

visitInsertValueInst (InsertValueInst &I)

void

visitLandingPadInst (LandingPadInst &I)

void

visitFuncletPadInst (FuncletPadInst &I)

void

visitCleanupPadInst (CleanupPadInst &I)

void

visitCatchPadInst (CatchPadInst &I)

void

visitFreezeInst (FreezeInst &I)

void

visitMemSetInst (MemSetInst &I)

void

visitMemSetPatternInst (MemSetPatternInst &I)

void

visitMemCpyInst (MemCpyInst &I)

void

visitMemMoveInst (MemMoveInst &I)

void

visitMemTransferInst (MemTransferInst &I)

void

visitMemIntrinsic (MemIntrinsic &I)

void

visitVAStartInst (VAStartInst &I)

void

visitVAEndInst (VAEndInst &I)

void

visitVACopyInst (VACopyInst &I)

void

visitIntrinsicInst (IntrinsicInst &I)

void

visitCallInst (CallInst &I)

void

visitInvokeInst (InvokeInst &I)

void

visitCallBrInst (CallBrInst &I)

void

visitReturnInst (ReturnInst &I)

void

visitBranchInst (BranchInst &I)

void

visitSwitchInst (SwitchInst &I)

void

visitIndirectBrInst (IndirectBrInst &I)

void

visitResumeInst (ResumeInst &I)

void

visitUnreachableInst (UnreachableInst &I)

void

visitCleanupReturnInst (CleanupReturnInst &I)

void

visitCatchReturnInst (CatchReturnInst &I)

void

visitCatchSwitchInst (CatchSwitchInst &I)

void

visitTerminator (Instruction &I)

void

visitCastInst (CastInst &I)

void

visitUnaryOperator (UnaryOperator &I)

void

visitBinaryOperator (BinaryOperator &I)

void

visitCmpInst (CmpInst &I)

void

visitUnaryInstruction (UnaryInstruction &I)

void

visitCallBase (CallBase &I)

void

visitInstruction (Instruction &I)

Additional Inherited Members

Public Attributes inherited from llvm::ExecutionEngine

sys::Mutex

lock

lock - This lock protects the ExecutionEngine and MCJIT classes.

Protected Member Functions inherited from llvm::ExecutionEngine

virtual char *

getMemoryForGV (const GlobalVariable *GV)

getMemoryforGV - Allocate memory for a global variable.

std::string

getMangledName (const GlobalValue *GV)

getMangledName - Get mangled name.

ExecutionEngine (DataLayout DL)

ExecutionEngine (DataLayout DL, std::unique_ptr< Module > M)

ExecutionEngine (std::unique_ptr< Module > M)

void

emitGlobals ()

EmitGlobals - Emit all of the global variables to memory, storing their addresses into GlobalAddress.

void

emitGlobalVariable (const GlobalVariable *GV)

GenericValue

getConstantValue (const Constant *C)

Converts a Constant* into a GenericValue, including handling of ConstantExpr values.

void

LoadValueFromMemory (GenericValue &Result, GenericValue *Ptr, Type *Ty)

FIXME: document.

Protected Attributes inherited from llvm::ExecutionEngine

SmallVector< std::unique_ptr< Module >, 1 >

Modules

The list of Modules that we are JIT'ing from.

FunctionCreator

LazyFunctionCreator

LazyFunctionCreator - If an unknown function is needed, this function pointer is invoked to create it.

std::string

ErrMsg

Static Protected Attributes inherited from llvm::ExecutionEngine

static ExecutionEngine *(*

MCJITCtor )(std::unique_ptr< Module > M, std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MM, std::shared_ptr< LegacyJITSymbolResolver > SR, std::unique_ptr< TargetMachine > TM) = nullptr

static ExecutionEngine *(*

InterpCtor )(std::unique_ptr< Module > M, std::string *ErrorStr) =nullptr

Definition at line 74 of file Interpreter.h.

void * llvm::Interpreter::getPointerToNamedFunction ( StringRef Name, bool AbortOnFailure = true ) inlineoverridevirtual

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.

Implements llvm::ExecutionEngine.

Definition at line 109 of file Interpreter.h.