14 #ifndef LLI_INTERPRETER_H
15 #define LLI_INTERPRETER_H
23 #include "llvm/Support/DataTypes.h"
28 class IntrinsicLowering;
30 template<
typename T>
class generic_gep_type_iterator;
41 std::vector<void*> Allocations;
45 void add(
void *mem) { Allocations.push_back(mem); }
47 for (
unsigned i = 0; i < Allocations.size(); ++i)
74 std::map<Value *, GenericValue>
Values;
90 std::vector<ExecutionContext> ECStack;
94 std::vector<Function*> AtExitHandlers;
116 const std::vector<GenericValue> &ArgValues);
119 bool AbortOnFailure =
true) {
128 return getPointerToFunction(F);
194 const std::vector<GenericValue> &ArgVals);
198 AtExitHandlers.push_back(F);
202 return &(ECStack.back ().VarArgs[0]);
215 void *getPointerToFunction(
Function *
F) {
return (
void*)
F; }
216 void *getPointerToBasicBlock(
BasicBlock *BB) {
return (
void*)BB; }
218 void initializeExecutionEngine() { }
219 void initializeExternalFunctions();
220 GenericValue getConstantExprValue(ConstantExpr *CE, ExecutionContext &SF);
221 GenericValue getOperandValue(Value *V, ExecutionContext &SF);
222 GenericValue executeTruncInst(Value *SrcVal,
Type *DstTy,
223 ExecutionContext &SF);
224 GenericValue executeSExtInst(Value *SrcVal,
Type *DstTy,
225 ExecutionContext &SF);
226 GenericValue executeZExtInst(Value *SrcVal,
Type *DstTy,
227 ExecutionContext &SF);
228 GenericValue executeFPTruncInst(Value *SrcVal,
Type *DstTy,
229 ExecutionContext &SF);
230 GenericValue executeFPExtInst(Value *SrcVal,
Type *DstTy,
231 ExecutionContext &SF);
232 GenericValue executeFPToUIInst(Value *SrcVal,
Type *DstTy,
233 ExecutionContext &SF);
234 GenericValue executeFPToSIInst(Value *SrcVal,
Type *DstTy,
235 ExecutionContext &SF);
236 GenericValue executeUIToFPInst(Value *SrcVal,
Type *DstTy,
237 ExecutionContext &SF);
238 GenericValue executeSIToFPInst(Value *SrcVal,
Type *DstTy,
239 ExecutionContext &SF);
240 GenericValue executePtrToIntInst(Value *SrcVal,
Type *DstTy,
241 ExecutionContext &SF);
242 GenericValue executeIntToPtrInst(Value *SrcVal,
Type *DstTy,
243 ExecutionContext &SF);
244 GenericValue executeBitCastInst(Value *SrcVal,
Type *DstTy,
245 ExecutionContext &SF);
247 Type *Ty, ExecutionContext &SF);
248 void popStackAndReturnValueToCaller(
Type *RetTy, GenericValue Result);
virtual GenericValue runFunction(Function *F, const std::vector< GenericValue > &ArgValues)
void visitVAArgInst(VAArgInst &I)
COFF::RelocationTypeX86 Type
generic_gep_type_iterator gep_type_iterator
std::vector< GenericValue > ValuePlaneTy
Base class for instruction visitors.
GenericValue callExternalFunction(Function *F, const std::vector< GenericValue > &ArgVals)
void visitAllocaInst(AllocaInst &I)
void visitStoreInst(StoreInst &I)
The main container class for the LLVM Intermediate Representation.
void visitTruncInst(TruncInst &I)
void visitFPToUIInst(FPToUIInst &I)
This class represents zero extension of integer types.
void visitGetElementPtrInst(GetElementPtrInst &I)
BasicBlock::iterator CurInst
std::map< Value *, GenericValue > Values
void visitExtractElementInst(ExtractElementInst &I)
void visitShl(BinaryOperator &I)
This class represents a sign extension of integer types.
static ExecutionEngine *(* InterpCtor)(Module *M, std::string *ErrorStr)
void visitFCmpInst(FCmpInst &I)
void visitCallInst(CallInst &I)
#define llvm_unreachable(msg)
void visitSelectInst(SelectInst &I)
void visitInvokeInst(InvokeInst &I)
void callFunction(Function *F, const std::vector< GenericValue > &ArgVals)
This class represents a cast from a pointer to an integer.
void visitInsertElementInst(InsertElementInst &I)
void visitFPTruncInst(FPTruncInst &I)
void visitPHINode(PHINode &PN)
Represents a floating point comparison operator.
This class represents a no-op cast from one type to another.
void visitInsertValueInst(InsertValueInst &I)
This class represents a cast from floating point to signed integer.
void visitBitCastInst(BitCastInst &I)
This class represents a truncation of integer types.
void visitLShr(BinaryOperator &I)
void visitICmpInst(ICmpInst &I)
LLVM Basic Block Representation.
void visitCallSite(CallSite CS)
virtual void * recompileAndRelinkFunction(Function *F)
virtual void * getPointerToNamedFunction(const std::string &Name, bool AbortOnFailure=true)
void visitIndirectBrInst(IndirectBrInst &I)
void visitZExtInst(ZExtInst &I)
AllocaHolderHandle Allocas
void exitCalled(GenericValue GV)
Represent an integer comparison operator.
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)
void visitUnreachableInst(UnreachableInst &I)
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter...
static ExecutionEngine * create(Module *M, std::string *ErrorStr=0)
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.
void visitPtrToIntInst(PtrToIntInst &I)
void visitBranchInst(BranchInst &I)
void visitAShr(BinaryOperator &I)
void freeMachineCodeForFunction(Function *F)
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)
AllocaHolderHandle(const AllocaHolderHandle &AH)
void visitSwitchInst(SwitchInst &I)
This class represents an extension of floating point types.