Go to the documentation of this file.
13 #ifndef LLVM_LIB_EXECUTIONENGINE_INTERPRETER_INTERPRETER_H
14 #define LLVM_LIB_EXECUTIONENGINE_INTERPRETER_INTERPRETER_H
26 class IntrinsicLowering;
27 template<
typename T>
class generic_gep_type_iterator;
37 std::vector<void *> Allocations;
47 for (
void *Allocation : Allocations)
51 void add(
void *Mem) { Allocations.push_back(Mem); }
65 std::map<Value *, GenericValue>
Values;
80 std::vector<ExecutionContext> ECStack;
84 std::vector<Function*> AtExitHandlers;
102 std::string *ErrorStr =
nullptr);
110 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.
void visitUnreachableInst(UnreachableInst &I)
void visitCallBase(CallBase &I)
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Return a value (possibly void), from a function.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
void visitFPExtInst(FPExtInst &I)
InstListType::iterator iterator
Instruction iterators...
void visitVAEndInst(VAEndInst &I)
void visitLoadInst(LoadInst &I)
void visitShl(BinaryOperator &I)
This class represents a no-op cast from one type to another.
void visitInsertElementInst(InsertElementInst &I)
void visitReturnInst(ReturnInst &I)
void runAtExitHandlers()
runAtExitHandlers - Run any functions registered by the program's calls to atexit(3),...
std::vector< GenericValue > ValuePlaneTy
void visitBranchInst(BranchInst &I)
void visitInstruction(Instruction &I)
void visitUnaryOperator(UnaryOperator &I)
void callFunction(Function *F, ArrayRef< GenericValue > ArgVals)
void visitFPTruncInst(FPTruncInst &I)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void visitICmpInst(ICmpInst &I)
void visitVAArgInst(VAArgInst &I)
void visitStoreInst(StoreInst &I)
LLVM Basic Block Representation.
This represents the llvm.va_start intrinsic.
void addAtExitHandler(Function *F)
void visitSIToFPInst(SIToFPInst &I)
std::map< Value *, GenericValue > Values
void exitCalled(GenericValue GV)
void visitZExtInst(ZExtInst &I)
void visitIntrinsicInst(IntrinsicInst &I)
void visitIndirectBrInst(IndirectBrInst &I)
GenericValue * getFirstVarArg()
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
GenericValue runFunction(Function *F, ArrayRef< GenericValue > ArgValues) override
run - Start execution with the specified function and arguments.
void visitAllocaInst(AllocaInst &I)
This instruction compares its operands according to the predicate given to the constructor.
This instruction inserts a single (scalar) element into a VectorType value.
static ExecutionEngine *(* InterpCtor)(std::unique_ptr< Module > M, std::string *ErrorStr)
void visitTruncInst(TruncInst &I)
void visitBitCastInst(BitCastInst &I)
An instruction for storing to memory.
This instruction compares its operands according to the predicate given to the constructor.
void visitVAStartInst(VAStartInst &I)
This class represents a cast from floating point to signed integer.
This class represents a truncation of integer types.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
void visitVACopyInst(VACopyInst &I)
void visitInsertValueInst(InsertValueInst &I)
void visitExtractElementInst(ExtractElementInst &I)
generic_gep_type_iterator<> gep_type_iterator
This class represents the LLVM 'select' instruction.
This class represents a cast from floating point to unsigned integer.
void visitPtrToIntInst(PtrToIntInst &I)
void visitFCmpInst(FCmpInst &I)
This class represents zero extension of integer types.
void visitFPToUIInst(FPToUIInst &I)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This represents the llvm.va_end intrinsic.
void * getPointerToNamedFunction(StringRef Name, bool AbortOnFailure=true) override
getPointerToNamedFunction - This method returns the address of the specified function by using the dl...
BasicBlock::iterator CurInst
StringRef - Represent a constant reference to a string, i.e.
AllocaHolder & operator=(AllocaHolder &&RHS)=default
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::vector< GenericValue > VarArgs
void visitLShr(BinaryOperator &I)
void visitSExtInst(SExtInst &I)
This class represents a cast from a pointer to an integer.
void visitSwitchInst(SwitchInst &I)
Base class for instruction visitors.
This class represents an extension of floating point types.
This class represents a sign extension of integer types.
An instruction for reading from memory.
void visitUIToFPInst(UIToFPInst &I)
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter...
This represents the llvm.va_copy intrinsic.
void visitBinaryOperator(BinaryOperator &I)
This class represents a cast unsigned integer to floating point.
void visitFPToSIInst(FPToSIInst &I)
This class represents a cast from an integer to a pointer.
Indirect Branch Instruction.
Interpreter(std::unique_ptr< Module > M)
A wrapper class for inspecting calls to intrinsic functions.
void visitShuffleVectorInst(ShuffleVectorInst &I)
void visitAShr(BinaryOperator &I)
void visitSelectInst(SelectInst &I)
This instruction constructs a fixed permutation of two input vectors.
This class represents a cast from signed integer to floating point.
This class represents a truncation of floating point types.
GenericValue callExternalFunction(Function *F, ArrayRef< GenericValue > ArgVals)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
This function has undefined behavior.
void visitGetElementPtrInst(GetElementPtrInst &I)
an instruction to allocate memory on the stack
Conditional or Unconditional Branch instruction.
void visitPHINode(PHINode &PN)
void visitIntToPtrInst(IntToPtrInst &I)
This instruction inserts a struct field of array element value into an aggregate value.
void visitExtractValueInst(ExtractValueInst &I)
LLVM Value Representation.