LLVM API Documentation
#include "Interpreter.h"#include "llvm/Constants.h"#include "llvm/DerivedTypes.h"#include "llvm/Instructions.h"#include "llvm/CodeGen/IntrinsicLowering.h"#include "llvm/Support/GetElementPtrTypeIterator.h"#include "llvm/ADT/APInt.h"#include "llvm/ADT/Statistic.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Debug.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Support/MathExtras.h"#include <algorithm>#include <cmath>#include <cstring>
Go to the source code of this file.
| #define DEBUG_TYPE "interpreter" |
Definition at line 14 of file Execution.cpp.
| #define IMPLEMENT_BINARY_OPERATOR | ( | OP, | |||
| TY | ) |
Value:
Definition at line 49 of file Execution.cpp.
Referenced by executeFAddInst(), executeFDivInst(), executeFMulInst(), and executeFSubInst().
| #define IMPLEMENT_FCMP | ( | OP, | |||
| TY | ) |
Value:
Definition at line 284 of file Execution.cpp.
Referenced by executeFCMP_OEQ(), executeFCMP_OGE(), executeFCMP_OGT(), executeFCMP_OLE(), executeFCMP_OLT(), and executeFCMP_ONE().
| #define IMPLEMENT_INTEGER_ICMP | ( | OP, | |||
| TY | ) |
Value:
case Type::IntegerTyID: \ Dest.IntVal = APInt(1,Src1.IntVal.OP(Src2.IntVal)); \ break;
Definition at line 113 of file Execution.cpp.
Referenced by executeICMP_EQ(), executeICMP_NE(), executeICMP_SGE(), executeICMP_SGT(), executeICMP_SLE(), executeICMP_SLT(), executeICMP_UGE(), executeICMP_UGT(), executeICMP_ULE(), and executeICMP_ULT().
| #define IMPLEMENT_POINTER_ICMP | ( | OP | ) |
Value:
case Type::PointerTyID: \ Dest.IntVal = APInt(1,(void*)(intptr_t)Src1.PointerVal OP \ (void*)(intptr_t)Src2.PointerVal); \ break;
Definition at line 122 of file Execution.cpp.
Referenced by executeICMP_EQ(), executeICMP_NE(), executeICMP_SGE(), executeICMP_SGT(), executeICMP_SLE(), executeICMP_SLT(), executeICMP_UGE(), executeICMP_UGT(), executeICMP_ULE(), and executeICMP_ULT().
Value:
if (TY == Type::getFloatTy(Ty->getContext())) { \ if (X.FloatVal != X.FloatVal || Y.FloatVal != Y.FloatVal) { \ Dest.IntVal = APInt(1,true); \ return Dest; \ } \ } else if (X.DoubleVal != X.DoubleVal || Y.DoubleVal != Y.DoubleVal) { \ Dest.IntVal = APInt(1,true); \ return Dest; \ }
Definition at line 368 of file Execution.cpp.
Referenced by executeFCMP_UEQ(), executeFCMP_UGE(), executeFCMP_UGT(), executeFCMP_ULE(), executeFCMP_ULT(), and executeFCMP_UNE().
| static GenericValue executeCmpInst | ( | unsigned | predicate, | |
| GenericValue | Src1, | |||
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 478 of file Execution.cpp.
References llvm::cerr(), executeFCMP_OEQ(), executeFCMP_OGE(), executeFCMP_OGT(), executeFCMP_OLE(), executeFCMP_OLT(), executeFCMP_ONE(), executeFCMP_ORD(), executeFCMP_UEQ(), executeFCMP_UGE(), executeFCMP_UGT(), executeFCMP_ULE(), executeFCMP_ULT(), executeFCMP_UNE(), executeFCMP_UNO(), executeICMP_EQ(), executeICMP_NE(), executeICMP_SGE(), executeICMP_SGT(), executeICMP_SLE(), executeICMP_SLT(), executeICMP_UGE(), executeICMP_UGT(), executeICMP_ULE(), executeICMP_ULT(), llvm::CmpInst::FCMP_FALSE, llvm::CmpInst::FCMP_OEQ, llvm::CmpInst::FCMP_OGE, llvm::CmpInst::FCMP_OGT, llvm::CmpInst::FCMP_OLE, llvm::CmpInst::FCMP_OLT, llvm::CmpInst::FCMP_ONE, llvm::CmpInst::FCMP_ORD, llvm::CmpInst::FCMP_TRUE, llvm::CmpInst::FCMP_UEQ, llvm::CmpInst::FCMP_UGE, llvm::CmpInst::FCMP_UGT, llvm::CmpInst::FCMP_ULE, llvm::CmpInst::FCMP_ULT, llvm::CmpInst::FCMP_UNE, llvm::CmpInst::FCMP_UNO, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::GenericValue::IntVal, and llvm_unreachable.
| static void executeFAddInst | ( | GenericValue & | Dest, | |
| GenericValue | Src1, | |||
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 54 of file Execution.cpp.
References llvm::cerr(), llvm::Type::getTypeID(), IMPLEMENT_BINARY_OPERATOR, and llvm_unreachable.
Referenced by llvm::Interpreter::visitBinaryOperator().
| static GenericValue executeFCMP_OEQ | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 289 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_FCMP, and llvm_unreachable.
Referenced by executeCmpInst(), executeFCMP_UEQ(), and llvm::Interpreter::visitFCmpInst().
| static GenericValue executeFCMP_OGE | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 329 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_FCMP, and llvm_unreachable.
Referenced by executeCmpInst(), executeFCMP_UGE(), and llvm::Interpreter::visitFCmpInst().
| static GenericValue executeFCMP_OGT | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 355 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_FCMP, and llvm_unreachable.
Referenced by executeCmpInst(), executeFCMP_UGT(), and llvm::Interpreter::visitFCmpInst().
| static GenericValue executeFCMP_OLE | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 316 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_FCMP, and llvm_unreachable.
Referenced by executeCmpInst(), executeFCMP_ULE(), and llvm::Interpreter::visitFCmpInst().
| static GenericValue executeFCMP_OLT | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 342 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_FCMP, and llvm_unreachable.
Referenced by executeCmpInst(), executeFCMP_ULT(), and llvm::Interpreter::visitFCmpInst().
| static GenericValue executeFCMP_ONE | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 302 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_FCMP, and llvm_unreachable.
Referenced by executeCmpInst(), executeFCMP_UNE(), and llvm::Interpreter::visitFCmpInst().
| static GenericValue executeFCMP_ORD | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 422 of file Execution.cpp.
References Dest, llvm::GenericValue::DoubleVal, llvm::GenericValue::FloatVal, llvm::Type::getContext(), llvm::Type::getFloatTy(), and llvm::GenericValue::IntVal.
Referenced by executeCmpInst(), and llvm::Interpreter::visitFCmpInst().
| static GenericValue executeFCMP_UEQ | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 380 of file Execution.cpp.
References Dest, executeFCMP_OEQ(), and IMPLEMENT_UNORDERED.
Referenced by executeCmpInst(), and llvm::Interpreter::visitFCmpInst().
| static GenericValue executeFCMP_UGE | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 401 of file Execution.cpp.
References Dest, executeFCMP_OGE(), and IMPLEMENT_UNORDERED.
Referenced by executeCmpInst(), and llvm::Interpreter::visitFCmpInst().
| static GenericValue executeFCMP_UGT | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 415 of file Execution.cpp.
References Dest, executeFCMP_OGT(), and IMPLEMENT_UNORDERED.
Referenced by executeCmpInst(), and llvm::Interpreter::visitFCmpInst().
| static GenericValue executeFCMP_ULE | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 394 of file Execution.cpp.
References Dest, executeFCMP_OLE(), and IMPLEMENT_UNORDERED.
Referenced by executeCmpInst(), and llvm::Interpreter::visitFCmpInst().
| static GenericValue executeFCMP_ULT | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 408 of file Execution.cpp.
References Dest, executeFCMP_OLT(), and IMPLEMENT_UNORDERED.
Referenced by executeCmpInst(), and llvm::Interpreter::visitFCmpInst().
| static GenericValue executeFCMP_UNE | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 387 of file Execution.cpp.
References Dest, executeFCMP_ONE(), and IMPLEMENT_UNORDERED.
Referenced by executeCmpInst(), and llvm::Interpreter::visitFCmpInst().
| static GenericValue executeFCMP_UNO | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 434 of file Execution.cpp.
References Dest, llvm::GenericValue::DoubleVal, llvm::GenericValue::FloatVal, llvm::Type::getContext(), llvm::Type::getFloatTy(), and llvm::GenericValue::IntVal.
Referenced by executeCmpInst(), and llvm::Interpreter::visitFCmpInst().
| static void executeFDivInst | ( | GenericValue & | Dest, | |
| GenericValue | Src1, | |||
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 87 of file Execution.cpp.
References llvm::cerr(), llvm::Type::getTypeID(), IMPLEMENT_BINARY_OPERATOR, and llvm_unreachable.
Referenced by llvm::Interpreter::visitBinaryOperator().
| static void executeFMulInst | ( | GenericValue & | Dest, | |
| GenericValue | Src1, | |||
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 76 of file Execution.cpp.
References llvm::cerr(), llvm::Type::getTypeID(), IMPLEMENT_BINARY_OPERATOR, and llvm_unreachable.
Referenced by llvm::Interpreter::visitBinaryOperator().
| static void executeFRemInst | ( | GenericValue & | Dest, | |
| GenericValue | Src1, | |||
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 98 of file Execution.cpp.
References llvm::cerr(), llvm::GenericValue::DoubleVal, llvm::GenericValue::FloatVal, llvm::Type::getTypeID(), and llvm_unreachable.
Referenced by llvm::Interpreter::visitBinaryOperator().
| static void executeFSubInst | ( | GenericValue & | Dest, | |
| GenericValue | Src1, | |||
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 65 of file Execution.cpp.
References llvm::cerr(), llvm::Type::getTypeID(), IMPLEMENT_BINARY_OPERATOR, and llvm_unreachable.
Referenced by llvm::Interpreter::visitBinaryOperator().
| static GenericValue executeICMP_EQ | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 128 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_INTEGER_ICMP, IMPLEMENT_POINTER_ICMP, and llvm_unreachable.
Referenced by executeCmpInst(), llvm::Interpreter::visitICmpInst(), and llvm::Interpreter::visitSwitchInst().
| static GenericValue executeICMP_NE | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 141 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_INTEGER_ICMP, IMPLEMENT_POINTER_ICMP, and llvm_unreachable.
Referenced by executeCmpInst(), and llvm::Interpreter::visitICmpInst().
| static GenericValue executeICMP_SGE | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 245 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_INTEGER_ICMP, IMPLEMENT_POINTER_ICMP, and llvm_unreachable.
Referenced by executeCmpInst(), and llvm::Interpreter::visitICmpInst().
| static GenericValue executeICMP_SGT | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 193 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_INTEGER_ICMP, IMPLEMENT_POINTER_ICMP, and llvm_unreachable.
Referenced by executeCmpInst(), and llvm::Interpreter::visitICmpInst().
| static GenericValue executeICMP_SLE | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 219 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_INTEGER_ICMP, IMPLEMENT_POINTER_ICMP, and llvm_unreachable.
Referenced by executeCmpInst(), and llvm::Interpreter::visitICmpInst().
| static GenericValue executeICMP_SLT | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 167 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_INTEGER_ICMP, IMPLEMENT_POINTER_ICMP, and llvm_unreachable.
Referenced by executeCmpInst(), and llvm::Interpreter::visitICmpInst().
| static GenericValue executeICMP_UGE | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 232 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_INTEGER_ICMP, IMPLEMENT_POINTER_ICMP, and llvm_unreachable.
Referenced by executeCmpInst(), and llvm::Interpreter::visitICmpInst().
| static GenericValue executeICMP_UGT | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 180 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_INTEGER_ICMP, IMPLEMENT_POINTER_ICMP, and llvm_unreachable.
Referenced by executeCmpInst(), and llvm::Interpreter::visitICmpInst().
| static GenericValue executeICMP_ULE | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 206 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_INTEGER_ICMP, IMPLEMENT_POINTER_ICMP, and llvm_unreachable.
Referenced by executeCmpInst(), and llvm::Interpreter::visitICmpInst().
| static GenericValue executeICMP_ULT | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| const Type * | Ty | |||
| ) | [static] |
Definition at line 154 of file Execution.cpp.
References llvm::cerr(), Dest, llvm::Type::getTypeID(), IMPLEMENT_INTEGER_ICMP, IMPLEMENT_POINTER_ICMP, and llvm_unreachable.
Referenced by executeCmpInst(), and llvm::Interpreter::visitICmpInst().
| static GenericValue executeSelectInst | ( | GenericValue | Src1, | |
| GenericValue | Src2, | |||
| GenericValue | Src3 | |||
| ) | [static] |
Definition at line 553 of file Execution.cpp.
References llvm::GenericValue::IntVal.
Referenced by llvm::Interpreter::visitSelectInst().
| static void SetValue | ( | Value * | V, | |
| GenericValue | Val, | |||
| ExecutionContext & | SF | |||
| ) | [static] |
Definition at line 41 of file Execution.cpp.
References llvm::ExecutionContext::Values.
Referenced by llvm::Interpreter::callFunction(), llvm::Interpreter::visitAllocationInst(), llvm::Interpreter::visitAShr(), llvm::Interpreter::visitBinaryOperator(), llvm::Interpreter::visitBitCastInst(), llvm::Interpreter::visitCallSite(), llvm::Interpreter::visitFCmpInst(), llvm::Interpreter::visitFPExtInst(), llvm::Interpreter::visitFPToSIInst(), llvm::Interpreter::visitFPToUIInst(), llvm::Interpreter::visitFPTruncInst(), llvm::Interpreter::visitGetElementPtrInst(), llvm::Interpreter::visitICmpInst(), llvm::Interpreter::visitIntToPtrInst(), llvm::Interpreter::visitLoadInst(), llvm::Interpreter::visitLShr(), llvm::Interpreter::visitPtrToIntInst(), llvm::Interpreter::visitSelectInst(), llvm::Interpreter::visitSExtInst(), llvm::Interpreter::visitShl(), llvm::Interpreter::visitSIToFPInst(), llvm::Interpreter::visitTruncInst(), llvm::Interpreter::visitUIToFPInst(), llvm::Interpreter::visitVAArgInst(), and llvm::Interpreter::visitZExtInst().
| STATISTIC | ( | NumDynamicInsts | , | |
| "Number of dynamic instructions executed" | ||||
| ) |
cl::opt<bool> PrintVolatile("interpreter-print-volatile", cl::Hidden, cl::desc("make the interpreter print every volatile load and store")) [static] |
Referenced by llvm::Interpreter::visitLoadInst(), and llvm::Interpreter::visitStoreInst().