LLVM: lib/ExecutionEngine/Interpreter/Interpreter.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_LIB_EXECUTIONENGINE_INTERPRETER_INTERPRETER_H
14#define LLVM_LIB_EXECUTIONENGINE_INTERPRETER_INTERPRETER_H
15
24namespace llvm {
25
30
31
32
33
34
35
37 std::vector<void *> Allocations;
38
39public:
41
42
45
47 for (void *Allocation : Allocations)
48 free(Allocation);
49 }
50
51 void add(void *Mem) { Allocations.push_back(Mem); }
52};
53
55
56
57
58
64
65 std::map<Value *, GenericValue> Values;
68
70};
71
72
73
75 GenericValue ExitValue;
77
78
79
80 std::vector ECStack;
81
82
83
84 std::vector<Function*> AtExitHandlers;
85
86public:
87 explicit Interpreter(std::unique_ptr M);
89
90
91
92
94
98
99
100
102 std::string *ErrorStr = nullptr);
103
104
105
108
110 bool AbortOnFailure = true) override {
111
112 return nullptr;
113 }
114
115
116
118 void run();
119
120
125
150
157
161
166
169
173 }
174
178
180 AtExitHandlers.push_back(F);
181 }
182
184 return &(ECStack.back ().VarArgs[0]);
185 }
186
187private:
190
191
192
193
194
196
197 void *getPointerToFunction(Function *F) override { return (void*)F; }
198
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);
227 void popStackAndReturnValueToCaller(Type *RetTy, GenericValue Result);
228
229};
230
231}
232
233#endif
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Definition Interpreter.h:36
~AllocaHolder()
Definition Interpreter.h:46
AllocaHolder & operator=(AllocaHolder &&RHS)=default
void add(void *Mem)
Definition Interpreter.h:51
AllocaHolder(AllocaHolder &&)=default
an instruction to allocate memory on the stack
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
InstListType::iterator iterator
Instruction iterators...
This class represents a no-op cast from one type to another.
Conditional or Unconditional Branch instruction.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
A constant value that is initialized with an expression using other constant values.
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter...
static ExecutionEngine *(* InterpCtor)(std::unique_ptr< Module > M, std::string *ErrorStr)
ExecutionEngine(DataLayout DL)
This instruction compares its operands according to the predicate given to the constructor.
This class represents an extension of floating point types.
This class represents a cast from floating point to signed integer.
This class represents a cast from floating point to unsigned integer.
This class represents a truncation of floating point types.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
This instruction compares its operands according to the predicate given to the constructor.
Indirect Branch Instruction.
This instruction inserts a single (scalar) element into a VectorType value.
This instruction inserts a struct field of array element value into an aggregate value.
Base class for instruction visitors.
This class represents a cast from an integer to a pointer.
void visitSIToFPInst(SIToFPInst &I)
void visitFCmpInst(FCmpInst &I)
void visitPtrToIntInst(PtrToIntInst &I)
void visitPHINode(PHINode &PN)
Definition Interpreter.h:134
void visitShuffleVectorInst(ShuffleVectorInst &I)
void addAtExitHandler(Function *F)
Definition Interpreter.h:179
static void Register()
Definition Interpreter.h:95
void visitCallBase(CallBase &I)
void visitAllocaInst(AllocaInst &I)
void visitSelectInst(SelectInst &I)
void exitCalled(GenericValue GV)
void visitReturnInst(ReturnInst &I)
void visitIntToPtrInst(IntToPtrInst &I)
void visitUnreachableInst(UnreachableInst &I)
void visitICmpInst(ICmpInst &I)
void visitLShr(BinaryOperator &I)
void visitUIToFPInst(UIToFPInst &I)
void visitIndirectBrInst(IndirectBrInst &I)
void visitInsertValueInst(InsertValueInst &I)
GenericValue * getFirstVarArg()
Definition Interpreter.h:183
void runAtExitHandlers()
runAtExitHandlers - Run any functions registered by the program's calls to atexit(3),...
void visitBranchInst(BranchInst &I)
void visitVAArgInst(VAArgInst &I)
void visitStoreInst(StoreInst &I)
void visitExtractValueInst(ExtractValueInst &I)
void visitSwitchInst(SwitchInst &I)
void visitExtractElementInst(ExtractElementInst &I)
void * getPointerToNamedFunction(StringRef Name, bool AbortOnFailure=true) override
getPointerToNamedFunction - This method returns the address of the specified function by using the dl...
Definition Interpreter.h:109
void visitVACopyInst(VACopyInst &I)
void visitVAEndInst(VAEndInst &I)
void visitTruncInst(TruncInst &I)
void visitFPToUIInst(FPToUIInst &I)
Interpreter(std::unique_ptr< Module > M)
void visitLoadInst(LoadInst &I)
void visitGetElementPtrInst(GetElementPtrInst &I)
void callFunction(Function *F, ArrayRef< GenericValue > ArgVals)
void visitInsertElementInst(InsertElementInst &I)
void visitUnaryOperator(UnaryOperator &I)
GenericValue runFunction(Function *F, ArrayRef< GenericValue > ArgValues) override
run - Start execution with the specified function and arguments.
void visitFPExtInst(FPExtInst &I)
void visitVAStartInst(VAStartInst &I)
void visitBitCastInst(BitCastInst &I)
void visitSExtInst(SExtInst &I)
void visitAShr(BinaryOperator &I)
GenericValue callExternalFunction(Function *F, ArrayRef< GenericValue > ArgVals)
void visitFPTruncInst(FPTruncInst &I)
void visitBinaryOperator(BinaryOperator &I)
void visitShl(BinaryOperator &I)
void visitZExtInst(ZExtInst &I)
void visitFPToSIInst(FPToSIInst &I)
void visitIntrinsicInst(IntrinsicInst &I)
static ExecutionEngine * create(std::unique_ptr< Module > M, std::string *ErrorStr=nullptr)
Create an interpreter ExecutionEngine.
void visitInstruction(Instruction &I)
Definition Interpreter.h:170
A wrapper class for inspecting calls to intrinsic functions.
An instruction for reading from memory.
This class represents a cast from a pointer to an integer.
Return a value (possibly void), from a function.
This class represents a sign extension of integer types.
This class represents a cast from signed integer to floating point.
This class represents the LLVM 'select' instruction.
This instruction constructs a fixed permutation of two input vectors.
An instruction for storing to memory.
StringRef - Represent a constant reference to a string, i.e.
This class represents a truncation of integer types.
This class represents a cast unsigned integer to floating point.
This function has undefined behavior.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
This represents the llvm.va_copy intrinsic.
This represents the llvm.va_end intrinsic.
This represents the llvm.va_start intrinsic.
LLVM Value Representation.
This class represents zero extension of integer types.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
std::vector< GenericValue > ValuePlaneTy
Definition Interpreter.h:54
generic_gep_type_iterator<> gep_type_iterator
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition Interpreter.h:59
CallBase * Caller
Definition Interpreter.h:63
ExecutionContext()
Definition Interpreter.h:69
AllocaHolder Allocas
Definition Interpreter.h:67
BasicBlock::iterator CurInst
Definition Interpreter.h:62
std::map< Value *, GenericValue > Values
Definition Interpreter.h:65
std::vector< GenericValue > VarArgs
Definition Interpreter.h:66
Function * CurFunction
Definition Interpreter.h:60
BasicBlock * CurBB
Definition Interpreter.h:61