LLVM  8.0.1
Public Member Functions | Static Public Member Functions | List of all members
llvm::Interpreter Class Reference

#include "ExecutionEngine/Interpreter/Interpreter.h"

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

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. More...
 
GenericValue runFunction (Function *F, ArrayRef< GenericValue > ArgValues) override
 run - Start execution with the specified function and arguments. More...
 
void * getPointerToNamedFunction (StringRef Name, bool AbortOnFailure=true) override
 getPointerToNamedFunction - This method returns the address of the specified function by using the dlsym function call. More...
 
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 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 visitCallSite (CallSite CS)
 
void visitCallInst (CallInst &I)
 
void visitInvokeInst (InvokeInst &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)
 
GenericValuegetFirstVarArg ()
 
- 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. More...
 
virtual void addObjectFile (std::unique_ptr< object::ObjectFile > O)
 addObjectFile - Add an ObjectFile to the execution engine. More...
 
virtual void addObjectFile (object::OwningBinary< object::ObjectFile > O)
 
virtual void addArchive (object::OwningBinary< object::Archive > A)
 addArchive - Add an Archive to the execution engine. More...
 
const DataLayoutgetDataLayout () const
 
virtual bool removeModule (Module *M)
 removeModule - Removes a Module from the list of modules, but does not free the module's memory. More...
 
virtual FunctionFindFunctionNamed (StringRef FnName)
 FindFunctionNamed - Search all of the active modules to find the function that defines FnName. More...
 
virtual GlobalVariableFindGlobalVariableNamed (StringRef Name, bool AllowInternal=false)
 FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines Name. More...
 
virtual void mapSectionAddress (const void *LocalAddress, uint64_t TargetAddress)
 mapSectionAddress - map a section to its target address space value. More...
 
virtual void generateCodeForModule (Module *M)
 generateCodeForModule - Run code generation for the specified module and load it into memory. More...
 
virtual void finalizeObject ()
 finalizeObject - ensure the module is fully processed and is usable. More...
 
virtual void runStaticConstructorsDestructors (bool isDtors)
 runStaticConstructorsDestructors - This method is used to execute all of the static constructors or destructors for a program. More...
 
void runStaticConstructorsDestructors (Module &module, bool isDtors)
 This method is used to execute all of the static constructors or destructors for a particular module. More...
 
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. More...
 
void addGlobalMapping (const GlobalValue *GV, void *Addr)
 addGlobalMapping - Tell the execution engine that the specified global is at the specified location. More...
 
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. More...
 
void clearGlobalMappingsFromModule (Module *M)
 clearGlobalMappingsFromModule - Clear all global mappings that came from a particular module, because it has been removed from the JIT. More...
 
uint64_t updateGlobalMapping (const GlobalValue *GV, void *Addr)
 updateGlobalMapping - Replace an existing mapping for GV with a new address. More...
 
uint64_t updateGlobalMapping (StringRef Name, uint64_t Addr)
 
uint64_t getAddressToGlobalIfAvailable (StringRef S)
 getAddressToGlobalIfAvailable - This returns the address of the specified global symbol. More...
 
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. More...
 
void * getPointerToGlobalIfAvailable (const GlobalValue *GV)
 
void * getPointerToGlobal (const GlobalValue *GV)
 getPointerToGlobal - This returns the address of the specified global value. More...
 
virtual void * getPointerToFunctionOrStub (Function *F)
 getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the function. More...
 
virtual uint64_t getGlobalValueAddress (const std::string &Name)
 getGlobalValueAddress - Return the address of the specified global value. More...
 
virtual uint64_t getFunctionAddress (const std::string &Name)
 getFunctionAddress - Return the address of the specified function. More...
 
const GlobalValuegetGlobalValueAtAddress (void *Addr)
 getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address. More...
 
void StoreValueToMemory (const GenericValue &Val, GenericValue *Ptr, Type *Ty)
 StoreValueToMemory - Stores the data in Val of type Ty at address Ptr. More...
 
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. More...
 
virtual void RegisterJITEventListener (JITEventListener *)
 Registers a listener to be called back on various events within the JIT. More...
 
virtual void UnregisterJITEventListener (JITEventListener *)
 
virtual void setObjectCache (ObjectCache *)
 Sets the pre-compiled object cache. More...
 
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. More...
 
virtual TargetMachinegetTargetMachine ()
 Return the target machine (if available). More...
 
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. More...
 
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. More...
 
bool isGVCompilationDisabled () const
 
void DisableSymbolSearching (bool Disabled=true)
 DisableSymbolSearching - If called, the JIT will not try to lookup unknown symbols with dlsym. More...
 
bool isSymbolSearchingDisabled () const
 
void setVerifyModules (bool Verify)
 Enable/Disable IR module verification. More...
 
bool getVerifyModules () const
 
void InstallLazyFunctionCreator (FunctionCreator C)
 InstallLazyFunctionCreator - If an unknown function is needed, the specified function pointer is invoked to create it. More...
 
- Public Member Functions inherited from llvm::InstVisitor< Interpreter >
void visit (Iterator Start, Iterator End)
 
void visit (Module &M)
 
void visit (Function &F)
 
void visit (BasicBlock &BB)
 
void visit (Module *M)
 
void visit (Function *F)
 
void visit (BasicBlock *BB)
 
void visit (Instruction *I)
 
void visit (Instruction &I)
 
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 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 visitDbgDeclareInst (DbgDeclareInst &I)
 
void visitDbgValueInst (DbgValueInst &I)
 
void visitDbgVariableIntrinsic (DbgVariableIntrinsic &I)
 
void visitDbgLabelInst (DbgLabelInst &I)
 
void visitDbgInfoIntrinsic (DbgInfoIntrinsic &I)
 
void visitMemSetInst (MemSetInst &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 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 visitCallSite (CallSite CS)
 
void visitInstruction (Instruction &I)
 

Static Public Member Functions

static void Register ()
 
static ExecutionEnginecreate (std::unique_ptr< Module > M, std::string *ErrorStr=nullptr)
 Create an interpreter ExecutionEngine. More...
 

Additional Inherited Members

- Public Attributes inherited from llvm::ExecutionEngine
sys::Mutex lock
 lock - This lock protects the ExecutionEngine and MCJIT classes. More...
 
- Protected Member Functions inherited from llvm::ExecutionEngine
virtual chargetMemoryForGV (const GlobalVariable *GV)
 getMemoryforGV - Allocate memory for a global variable. More...
 
std::string getMangledName (const GlobalValue *GV)
 getMangledName - Get mangled name. More...
 
 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. More...
 
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)
 FIXME: document. More...
 
- Protected Attributes inherited from llvm::ExecutionEngine
SmallVector< std::unique_ptr< Module >, 1 > Modules
 The list of Modules that we are JIT'ing from. More...
 
FunctionCreator LazyFunctionCreator
 LazyFunctionCreator - If an unknown function is needed, this function pointer is invoked to create it. More...
 
- 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 *(* OrcMCJITReplacementCtor )(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
 

Detailed Description

Definition at line 76 of file Interpreter.h.

Constructor & Destructor Documentation

◆ Interpreter()

Interpreter::Interpreter ( std::unique_ptr< Module M)
explicit

◆ ~Interpreter()

Interpreter::~Interpreter ( )
override

Definition at line 67 of file Interpreter.cpp.

Member Function Documentation

◆ addAtExitHandler()

void llvm::Interpreter::addAtExitHandler ( Function F)
inline

Definition at line 179 of file Interpreter.h.

Referenced by lle_X_atexit().

◆ callExternalFunction()

GenericValue Interpreter::callExternalFunction ( Function F,
ArrayRef< GenericValue ArgVals 
)

◆ callFunction()

void Interpreter::callFunction ( Function F,
ArrayRef< GenericValue ArgVals 
)

◆ create()

ExecutionEngine * Interpreter::create ( std::unique_ptr< Module M,
std::string *  ErrorStr = nullptr 
)
static

Create an interpreter ExecutionEngine.

Create a new interpreter object.

Definition at line 35 of file Interpreter.cpp.

◆ exitCalled()

void Interpreter::exitCalled ( GenericValue  GV)

◆ getFirstVarArg()

GenericValue* llvm::Interpreter::getFirstVarArg ( )
inline

Definition at line 183 of file Interpreter.h.

References E, and F().

◆ getPointerToNamedFunction()

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 111 of file Interpreter.h.

References I.

◆ Register()

static void llvm::Interpreter::Register ( )
inlinestatic

Definition at line 97 of file Interpreter.h.

References F().

◆ run()

void Interpreter::run ( )

◆ runAtExitHandlers()

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 71 of file Interpreter.cpp.

References callFunction(), llvm::None, and run().

Referenced by exitCalled().

◆ runFunction()

GenericValue Interpreter::runFunction ( Function F,
ArrayRef< GenericValue ArgValues 
)
overridevirtual

run - Start execution with the specified function and arguments.

Implements llvm::ExecutionEngine.

Definition at line 81 of file Interpreter.cpp.

References assert(), callFunction(), llvm::Function::getFunctionType(), llvm::FunctionType::getNumParams(), run(), llvm::ArrayRef< T >::size(), and llvm::ArrayRef< T >::slice().

◆ visitAllocaInst()

void Interpreter::visitAllocaInst ( AllocaInst I)

◆ visitAShr()

void Interpreter::visitAShr ( BinaryOperator I)

◆ visitBinaryOperator()

void Interpreter::visitBinaryOperator ( BinaryOperator I)

◆ visitBitCastInst()

void Interpreter::visitBitCastInst ( BitCastInst I)

Definition at line 1709 of file Execution.cpp.

References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().

◆ visitBranchInst()

void Interpreter::visitBranchInst ( BranchInst I)

◆ visitCallInst()

void llvm::Interpreter::visitCallInst ( CallInst I)
inline

Definition at line 154 of file Interpreter.h.

◆ visitCallSite()

void Interpreter::visitCallSite ( CallSite  CS)

◆ visitExtractElementInst()

void Interpreter::visitExtractElementInst ( ExtractElementInst I)

◆ visitExtractValueInst()

void Interpreter::visitExtractValueInst ( ExtractValueInst I)

◆ visitFCmpInst()

void Interpreter::visitFCmpInst ( FCmpInst I)

◆ visitFPExtInst()

void Interpreter::visitFPExtInst ( FPExtInst I)

Definition at line 1674 of file Execution.cpp.

References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().

◆ visitFPToSIInst()

void Interpreter::visitFPToSIInst ( FPToSIInst I)

Definition at line 1694 of file Execution.cpp.

References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().

◆ visitFPToUIInst()

void Interpreter::visitFPToUIInst ( FPToUIInst I)

Definition at line 1689 of file Execution.cpp.

References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().

◆ visitFPTruncInst()

void Interpreter::visitFPTruncInst ( FPTruncInst I)

Definition at line 1669 of file Execution.cpp.

References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().

◆ visitGetElementPtrInst()

void Interpreter::visitGetElementPtrInst ( GetElementPtrInst I)

◆ visitICmpInst()

void Interpreter::visitICmpInst ( ICmpInst I)

◆ visitIndirectBrInst()

void Interpreter::visitIndirectBrInst ( IndirectBrInst I)

◆ visitInsertElementInst()

void Interpreter::visitInsertElementInst ( InsertElementInst I)

◆ visitInsertValueInst()

void Interpreter::visitInsertValueInst ( InsertValueInst I)

◆ visitInstruction()

void llvm::Interpreter::visitInstruction ( Instruction I)
inline

Definition at line 170 of file Interpreter.h.

References llvm::errs(), and llvm_unreachable.

◆ visitIntToPtrInst()

void Interpreter::visitIntToPtrInst ( IntToPtrInst I)

Definition at line 1704 of file Execution.cpp.

References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().

◆ visitInvokeInst()

void llvm::Interpreter::visitInvokeInst ( InvokeInst I)
inline

Definition at line 155 of file Interpreter.h.

◆ visitLoadInst()

void Interpreter::visitLoadInst ( LoadInst I)

◆ visitLShr()

void Interpreter::visitLShr ( BinaryOperator I)

◆ visitPHINode()

void llvm::Interpreter::visitPHINode ( PHINode PN)
inline

Definition at line 135 of file Interpreter.h.

References llvm_unreachable.

◆ visitPtrToIntInst()

void Interpreter::visitPtrToIntInst ( PtrToIntInst I)

Definition at line 1699 of file Execution.cpp.

References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().

◆ visitReturnInst()

void Interpreter::visitReturnInst ( ReturnInst I)

◆ visitSelectInst()

void Interpreter::visitSelectInst ( SelectInst I)

◆ visitSExtInst()

void Interpreter::visitSExtInst ( SExtInst I)

Definition at line 1659 of file Execution.cpp.

References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().

◆ visitShl()

void Interpreter::visitShl ( BinaryOperator I)

◆ visitShuffleVectorInst()

void Interpreter::visitShuffleVectorInst ( ShuffleVectorInst I)

◆ visitSIToFPInst()

void Interpreter::visitSIToFPInst ( SIToFPInst I)

Definition at line 1684 of file Execution.cpp.

References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().

◆ visitStoreInst()

void Interpreter::visitStoreInst ( StoreInst I)

◆ visitSwitchInst()

void Interpreter::visitSwitchInst ( SwitchInst I)

◆ visitTruncInst()

void Interpreter::visitTruncInst ( TruncInst I)

Definition at line 1654 of file Execution.cpp.

References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().

◆ visitUIToFPInst()

void Interpreter::visitUIToFPInst ( UIToFPInst I)

Definition at line 1679 of file Execution.cpp.

References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().

◆ visitUnreachableInst()

void Interpreter::visitUnreachableInst ( UnreachableInst I)

Definition at line 877 of file Execution.cpp.

References llvm::report_fatal_error().

◆ visitVAArgInst()

void Interpreter::visitVAArgInst ( VAArgInst I)

◆ visitZExtInst()

void Interpreter::visitZExtInst ( ZExtInst I)

Definition at line 1664 of file Execution.cpp.

References llvm::User::getOperand(), llvm::Value::getType(), and SetValue().


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