14 #ifndef LLVM_LIB_EXECUTIONENGINE_INTERPRETER_INTERPRETER_H
15 #define LLVM_LIB_EXECUTIONENGINE_INTERPRETER_INTERPRETER_H
23 #include "llvm/Support/DataTypes.h"
28 class IntrinsicLowering;
29 template<
typename T>
class generic_gep_type_iterator;
39 std::vector<void *> Allocations;
53 void add(
void *Mem) { Allocations.push_back(Mem); }
67 std::map<Value *, GenericValue>
Values;
82 std::vector<ExecutionContext> ECStack;
86 std::vector<Function*> AtExitHandlers;
104 std::string *ErrorStr =
nullptr);
112 bool AbortOnFailure =
true)
override {
180 AtExitHandlers.push_back(F);
184 return &(ECStack.back ().VarArgs[0]);
197 void *getPointerToFunction(
Function *
F)
override {
return (
void*)
F; }
199 void initializeExecutionEngine() { }
200 void initializeExternalFunctions();
201 GenericValue getConstantExprValue(ConstantExpr *CE, ExecutionContext &SF);
202 GenericValue getOperandValue(Value *V, ExecutionContext &SF);
203 GenericValue executeTruncInst(Value *SrcVal,
Type *DstTy,
204 ExecutionContext &SF);
205 GenericValue executeSExtInst(Value *SrcVal,
Type *DstTy,
206 ExecutionContext &SF);
207 GenericValue executeZExtInst(Value *SrcVal,
Type *DstTy,
208 ExecutionContext &SF);
209 GenericValue executeFPTruncInst(Value *SrcVal,
Type *DstTy,
210 ExecutionContext &SF);
211 GenericValue executeFPExtInst(Value *SrcVal,
Type *DstTy,
212 ExecutionContext &SF);
213 GenericValue executeFPToUIInst(Value *SrcVal,
Type *DstTy,
214 ExecutionContext &SF);
215 GenericValue executeFPToSIInst(Value *SrcVal,
Type *DstTy,
216 ExecutionContext &SF);
217 GenericValue executeUIToFPInst(Value *SrcVal,
Type *DstTy,
218 ExecutionContext &SF);
219 GenericValue executeSIToFPInst(Value *SrcVal,
Type *DstTy,
220 ExecutionContext &SF);
221 GenericValue executePtrToIntInst(Value *SrcVal,
Type *DstTy,
222 ExecutionContext &SF);
223 GenericValue executeIntToPtrInst(Value *SrcVal,
Type *DstTy,
224 ExecutionContext &SF);
225 GenericValue executeBitCastInst(Value *SrcVal,
Type *DstTy,
226 ExecutionContext &SF);
228 Type *Ty, ExecutionContext &SF);
229 void popStackAndReturnValueToCaller(
Type *RetTy, GenericValue Result);
static ExecutionEngine * create(std::unique_ptr< Module > M, std::string *ErrorStr=nullptr)
Create an interpreter ExecutionEngine.
Return a value (possibly void), from a function.
void visitVAArgInst(VAArgInst &I)
generic_gep_type_iterator<> gep_type_iterator
std::vector< GenericValue > ValuePlaneTy
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Base class for instruction visitors.
Interpreter(std::unique_ptr< Module > M)
void visitAllocaInst(AllocaInst &I)
void visitStoreInst(StoreInst &I)
void visitTruncInst(TruncInst &I)
void visitFPToUIInst(FPToUIInst &I)
This class represents zero extension of integer types.
void visitGetElementPtrInst(GetElementPtrInst &I)
This class represents a function call, abstracting a target machine's calling convention.
BasicBlock::iterator CurInst
std::map< Value *, GenericValue > Values
This instruction constructs a fixed permutation of two input vectors.
void visitExtractElementInst(ExtractElementInst &I)
void visitShl(BinaryOperator &I)
This class represents a sign extension of integer types.
An instruction for reading from memory.
void visitFCmpInst(FCmpInst &I)
void visitCallInst(CallInst &I)
This class represents the LLVM 'select' instruction.
void visitSelectInst(SelectInst &I)
void visitInvokeInst(InvokeInst &I)
void * getPointerToNamedFunction(StringRef Name, bool AbortOnFailure=true) override
getPointerToNamedFunction - This method returns the address of the specified function by using the dl...
This class represents a cast from a pointer to an integer.
void visitInsertElementInst(InsertElementInst &I)
void visitFPTruncInst(FPTruncInst &I)
void visitPHINode(PHINode &PN)
This instruction compares its operands according to the predicate given to the constructor.
This class represents a no-op cast from one type to another.
void callFunction(Function *F, ArrayRef< GenericValue > ArgVals)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
void visitInsertValueInst(InsertValueInst &I)
An instruction for storing to memory.
This class represents a cast from floating point to signed integer.
void visitBitCastInst(BitCastInst &I)
This class represents a truncation of integer types.
Local Stack Slot Allocation
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
void visitLShr(BinaryOperator &I)
void visitICmpInst(ICmpInst &I)
This instruction inserts a single (scalar) element into a VectorType value.
LLVM Basic Block Representation.
Conditional or Unconditional Branch instruction.
void visitCallSite(CallSite CS)
This function has undefined behavior.
AllocaHolder & operator=(AllocaHolder &&RHS)=default
Indirect Branch Instruction.
void visitIndirectBrInst(IndirectBrInst &I)
void visitZExtInst(ZExtInst &I)
void exitCalled(GenericValue GV)
This instruction compares its operands according to the predicate given to the constructor.
GenericValue * getFirstVarArg()
void visitExtractValueInst(ExtractValueInst &I)
This class represents a cast from an integer to a pointer.
void visitFPToSIInst(FPToSIInst &I)
void visitIntToPtrInst(IntToPtrInst &I)
void visitFPExtInst(FPExtInst &I)
void visitInstruction(Instruction &I)
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
void visitUnreachableInst(UnreachableInst &I)
static ExecutionEngine *(* InterpCtor)(std::unique_ptr< Module > M, std::string *ErrorStr)
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter...
Iterator for intrusive lists based on ilist_node.
void visitShuffleVectorInst(ShuffleVectorInst &I)
std::vector< GenericValue > VarArgs
void visitReturnInst(ReturnInst &I)
void visitSExtInst(SExtInst &I)
This class represents a cast from floating point to unsigned integer.
GenericValue runFunction(Function *F, ArrayRef< GenericValue > ArgValues) override
run - Start execution with the specified function and arguments.
void visitPtrToIntInst(PtrToIntInst &I)
void runAtExitHandlers()
runAtExitHandlers - Run any functions registered by the program's calls to atexit(3), which we intercept and store in AtExitHandlers.
llvm_unreachable("Unknown RegBank!")
void visitBranchInst(BranchInst &I)
void visitAShr(BinaryOperator &I)
void visitSIToFPInst(SIToFPInst &I)
This class represents a cast unsigned integer to floating point.
void visitBinaryOperator(BinaryOperator &I)
void visitLoadInst(LoadInst &I)
This class represents a cast from signed integer to floating point.
This class represents a truncation of floating point types.
LLVM Value Representation.
void visitUIToFPInst(UIToFPInst &I)
void addAtExitHandler(Function *F)
GenericValue callExternalFunction(Function *F, ArrayRef< GenericValue > ArgVals)
void visitSwitchInst(SwitchInst &I)
StringRef - Represent a constant reference to a string, i.e.
This class represents an extension of floating point types.
an instruction to allocate memory on the stack
This instruction inserts a struct field of array element value into an aggregate value.