LLVM  8.0.1
Macros | Functions | Variables
Execution.cpp File Reference
#include "Interpreter.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/IntrinsicLowering.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/Instructions.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cmath>
Include dependency graph for Execution.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "interpreter"
 
#define IMPLEMENT_BINARY_OPERATOR(OP, TY)
 
#define IMPLEMENT_INTEGER_ICMP(OP, TY)
 
#define IMPLEMENT_VECTOR_INTEGER_ICMP(OP, TY)
 
#define IMPLEMENT_POINTER_ICMP(OP)
 
#define IMPLEMENT_FCMP(OP, TY)
 
#define IMPLEMENT_VECTOR_FCMP_T(OP, TY)
 
#define IMPLEMENT_VECTOR_FCMP(OP)
 
#define IMPLEMENT_SCALAR_NANS(TY, X, Y)
 
#define MASK_VECTOR_NANS_T(X, Y, TZ, FLAG)
 
#define MASK_VECTOR_NANS(TY, X, Y, FLAG)
 
#define IMPLEMENT_UNORDERED(TY, X, Y)
 
#define IMPLEMENT_VECTOR_UNORDERED(TY, X, Y, FUNC)
 
#define INTEGER_VECTOR_OPERATION(OP)
 
#define INTEGER_VECTOR_FUNCTION(OP)
 
#define FLOAT_VECTOR_FUNCTION(OP, TY)
 
#define FLOAT_VECTOR_OP(OP)
 
#define IMPLEMENT_VAARG(TY)   case Type::TY##TyID: Dest.TY##Val = Src.TY##Val; break
 

Functions

 STATISTIC (NumDynamicInsts, "Number of dynamic instructions executed")
 
static void SetValue (Value *V, GenericValue Val, ExecutionContext &SF)
 
static void executeFAddInst (GenericValue &Dest, GenericValue Src1, GenericValue Src2, Type *Ty)
 
static void executeFSubInst (GenericValue &Dest, GenericValue Src1, GenericValue Src2, Type *Ty)
 
static void executeFMulInst (GenericValue &Dest, GenericValue Src1, GenericValue Src2, Type *Ty)
 
static void executeFDivInst (GenericValue &Dest, GenericValue Src1, GenericValue Src2, Type *Ty)
 
static void executeFRemInst (GenericValue &Dest, GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeICMP_EQ (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeICMP_NE (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeICMP_ULT (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeICMP_SLT (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeICMP_UGT (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeICMP_SGT (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeICMP_ULE (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeICMP_SLE (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeICMP_UGE (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeICMP_SGE (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_OEQ (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_ONE (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_OLE (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_OGE (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_OLT (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_OGT (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_UEQ (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_UNE (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_ULE (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_UGE (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_ULT (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_UGT (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_ORD (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_UNO (GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeFCMP_BOOL (GenericValue Src1, GenericValue Src2, Type *Ty, const bool val)
 
static GenericValue executeCmpInst (unsigned predicate, GenericValue Src1, GenericValue Src2, Type *Ty)
 
static GenericValue executeSelectInst (GenericValue Src1, GenericValue Src2, GenericValue Src3, Type *Ty)
 
static unsigned getShiftAmount (uint64_t orgShiftAmount, llvm::APInt valueToShift)
 

Variables

static cl::opt< boolPrintVolatile ("interpreter-print-volatile", cl::Hidden, cl::desc("make the interpreter print every volatile load and store"))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "interpreter"

Definition at line 31 of file Execution.cpp.

◆ FLOAT_VECTOR_FUNCTION

#define FLOAT_VECTOR_FUNCTION (   OP,
  TY 
)
Value:
for (unsigned i = 0; i < R.AggregateVal.size(); ++i) \
R.AggregateVal[i].TY = \
Src1.AggregateVal[i].TY OP Src2.AggregateVal[i].TY;
#define OP(n)
Definition: regex2.h:73

◆ FLOAT_VECTOR_OP

#define FLOAT_VECTOR_OP (   OP)
Value:
{ \
if (cast<VectorType>(Ty)->getElementType()->isFloatTy()) \
FLOAT_VECTOR_FUNCTION(OP, FloatVal) \
else { \
if (cast<VectorType>(Ty)->getElementType()->isDoubleTy()) \
FLOAT_VECTOR_FUNCTION(OP, DoubleVal) \
else { \
dbgs() << "Unhandled type for OP instruction: " << *Ty << "\n"; \
llvm_unreachable(0); \
} \
} \
}
#define OP(n)
Definition: regex2.h:73

Referenced by llvm::Interpreter::visitBinaryOperator().

◆ IMPLEMENT_BINARY_OPERATOR

#define IMPLEMENT_BINARY_OPERATOR (   OP,
  TY 
)
Value:
case Type::TY##TyID: \
Dest.TY##Val = Src1.TY##Val OP Src2.TY##Val; \
break
#define OP(n)
Definition: regex2.h:73

Definition at line 50 of file Execution.cpp.

Referenced by executeFAddInst(), executeFDivInst(), executeFMulInst(), and executeFSubInst().

◆ IMPLEMENT_FCMP

#define IMPLEMENT_FCMP (   OP,
  TY 
)
Value:
case Type::TY##TyID: \
Dest.IntVal = APInt(1,Src1.TY##Val OP Src2.TY##Val); \
break
Class for arbitrary precision integers.
Definition: APInt.h:70
#define OP(n)
Definition: regex2.h:73

Definition at line 304 of file Execution.cpp.

Referenced by executeFCMP_OEQ(), executeFCMP_OGE(), executeFCMP_OGT(), executeFCMP_OLE(), executeFCMP_OLT(), and executeFCMP_ONE().

◆ IMPLEMENT_INTEGER_ICMP

#define IMPLEMENT_INTEGER_ICMP (   OP,
  TY 
)
Value:
case Type::IntegerTyID: \
Dest.IntVal = APInt(1,Src1.IntVal.OP(Src2.IntVal)); \
break;
Class for arbitrary precision integers.
Definition: APInt.h:70

Definition at line 114 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().

◆ IMPLEMENT_POINTER_ICMP

#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;
Class for arbitrary precision integers.
Definition: APInt.h:70
#define OP(n)
Definition: regex2.h:73

Definition at line 132 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().

◆ IMPLEMENT_SCALAR_NANS

#define IMPLEMENT_SCALAR_NANS (   TY,
  X,
  Y 
)
Value:
if (TY->isFloatTy()) { \
if (X.FloatVal != X.FloatVal || Y.FloatVal != Y.FloatVal) { \
Dest.IntVal = APInt(1,false); \
return Dest; \
} \
} else { \
if (X.DoubleVal != X.DoubleVal || Y.DoubleVal != Y.DoubleVal) { \
Dest.IntVal = APInt(1,false); \
return Dest; \
} \
}
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
Class for arbitrary precision integers.
Definition: APInt.h:70

Definition at line 339 of file Execution.cpp.

Referenced by executeFCMP_ONE().

◆ IMPLEMENT_UNORDERED

#define IMPLEMENT_UNORDERED (   TY,
  X,
  Y 
)
Value:
if (TY->isFloatTy()) { \
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; \
}
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
Class for arbitrary precision integers.
Definition: APInt.h:70

Definition at line 457 of file Execution.cpp.

Referenced by executeFCMP_UEQ(), executeFCMP_UGE(), executeFCMP_UGT(), executeFCMP_ULE(), executeFCMP_ULT(), and executeFCMP_UNE().

◆ IMPLEMENT_VAARG

#define IMPLEMENT_VAARG (   TY)    case Type::TY##TyID: Dest.TY##Val = Src.TY##Val; break

Definition at line 1714 of file Execution.cpp.

Referenced by llvm::Interpreter::visitVAArgInst().

◆ IMPLEMENT_VECTOR_FCMP

#define IMPLEMENT_VECTOR_FCMP (   OP)
Value:
case Type::VectorTyID: \
if (cast<VectorType>(Ty)->getElementType()->isFloatTy()) { \
IMPLEMENT_VECTOR_FCMP_T(OP, Float); \
} else { \
IMPLEMENT_VECTOR_FCMP_T(OP, Double); \
}
#define OP(n)
Definition: regex2.h:73

Definition at line 317 of file Execution.cpp.

Referenced by executeFCMP_OEQ(), executeFCMP_OGE(), executeFCMP_OGT(), executeFCMP_OLE(), executeFCMP_OLT(), and executeFCMP_ONE().

◆ IMPLEMENT_VECTOR_FCMP_T

#define IMPLEMENT_VECTOR_FCMP_T (   OP,
  TY 
)
Value:
assert(Src1.AggregateVal.size() == Src2.AggregateVal.size()); \
Dest.AggregateVal.resize( Src1.AggregateVal.size() ); \
for( uint32_t _i=0;_i<Src1.AggregateVal.size();_i++) \
Dest.AggregateVal[_i].IntVal = APInt(1, \
Src1.AggregateVal[_i].TY##Val OP Src2.AggregateVal[_i].TY##Val);\
break;
Class for arbitrary precision integers.
Definition: APInt.h:70
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
#define OP(n)
Definition: regex2.h:73

Definition at line 309 of file Execution.cpp.

◆ IMPLEMENT_VECTOR_INTEGER_ICMP

#define IMPLEMENT_VECTOR_INTEGER_ICMP (   OP,
  TY 
)
Value:
case Type::VectorTyID: { \
assert(Src1.AggregateVal.size() == Src2.AggregateVal.size()); \
Dest.AggregateVal.resize( Src1.AggregateVal.size() ); \
for( uint32_t _i=0;_i<Src1.AggregateVal.size();_i++) \
Dest.AggregateVal[_i].IntVal = APInt(1, \
Src1.AggregateVal[_i].IntVal.OP(Src2.AggregateVal[_i].IntVal));\
} break;
Class for arbitrary precision integers.
Definition: APInt.h:70

Definition at line 119 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().

◆ IMPLEMENT_VECTOR_UNORDERED

#define IMPLEMENT_VECTOR_UNORDERED (   TY,
  X,
  Y,
  FUNC 
)
Value:
if (TY->isVectorTy()) { \
GenericValue DestMask = Dest; \
Dest = FUNC(Src1, Src2, Ty); \
for (size_t _i = 0; _i < Src1.AggregateVal.size(); _i++) \
if (DestMask.AggregateVal[_i].IntVal == true) \
Dest.AggregateVal[_i].IntVal = APInt(1, true); \
return Dest; \
}
Class for arbitrary precision integers.
Definition: APInt.h:70

Definition at line 468 of file Execution.cpp.

Referenced by executeFCMP_UEQ(), executeFCMP_UGE(), executeFCMP_UGT(), executeFCMP_ULE(), executeFCMP_ULT(), and executeFCMP_UNE().

◆ INTEGER_VECTOR_FUNCTION

#define INTEGER_VECTOR_FUNCTION (   OP)
Value:
for (unsigned i = 0; i < R.AggregateVal.size(); ++i) \
R.AggregateVal[i].IntVal = \
Src1.AggregateVal[i].IntVal.OP(Src2.AggregateVal[i].IntVal);

Referenced by llvm::Interpreter::visitBinaryOperator().

◆ INTEGER_VECTOR_OPERATION

#define INTEGER_VECTOR_OPERATION (   OP)
Value:
for (unsigned i = 0; i < R.AggregateVal.size(); ++i) \
R.AggregateVal[i].IntVal = \
Src1.AggregateVal[i].IntVal OP Src2.AggregateVal[i].IntVal;
#define OP(n)
Definition: regex2.h:73

Referenced by llvm::Interpreter::visitBinaryOperator().

◆ MASK_VECTOR_NANS

#define MASK_VECTOR_NANS (   TY,
  X,
  Y,
  FLAG 
)
Value:
if (TY->isVectorTy()) { \
if (cast<VectorType>(TY)->getElementType()->isFloatTy()) { \
MASK_VECTOR_NANS_T(X, Y, Float, FLAG) \
} else { \
MASK_VECTOR_NANS_T(X, Y, Double, FLAG) \
} \
} \
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")

Definition at line 364 of file Execution.cpp.

Referenced by executeFCMP_ONE(), executeFCMP_UEQ(), executeFCMP_UGE(), executeFCMP_UGT(), executeFCMP_ULE(), executeFCMP_ULT(), and executeFCMP_UNE().

◆ MASK_VECTOR_NANS_T

#define MASK_VECTOR_NANS_T (   X,
  Y,
  TZ,
  FLAG 
)
Value:
assert(X.AggregateVal.size() == Y.AggregateVal.size()); \
Dest.AggregateVal.resize( X.AggregateVal.size() ); \
for( uint32_t _i=0;_i<X.AggregateVal.size();_i++) { \
if (X.AggregateVal[_i].TZ##Val != X.AggregateVal[_i].TZ##Val || \
Y.AggregateVal[_i].TZ##Val != Y.AggregateVal[_i].TZ##Val) \
Dest.AggregateVal[_i].IntVal = APInt(1,FLAG); \
else { \
Dest.AggregateVal[_i].IntVal = APInt(1,!FLAG); \
} \
}
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
Class for arbitrary precision integers.
Definition: APInt.h:70
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

Definition at line 352 of file Execution.cpp.

Function Documentation

◆ executeCmpInst()

static GenericValue executeCmpInst ( unsigned  predicate,
GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFAddInst()

static void executeFAddInst ( GenericValue Dest,
GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFCMP_BOOL()

static GenericValue executeFCMP_BOOL ( GenericValue  Src1,
GenericValue  Src2,
Type Ty,
const bool  val 
)
static

◆ executeFCMP_OEQ()

static GenericValue executeFCMP_OEQ ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFCMP_OGE()

static GenericValue executeFCMP_OGE ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFCMP_OGT()

static GenericValue executeFCMP_OGT ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFCMP_OLE()

static GenericValue executeFCMP_OLE ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFCMP_OLT()

static GenericValue executeFCMP_OLT ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFCMP_ONE()

static GenericValue executeFCMP_ONE ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFCMP_ORD()

static GenericValue executeFCMP_ORD ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFCMP_UEQ()

static GenericValue executeFCMP_UEQ ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFCMP_UGE()

static GenericValue executeFCMP_UGE ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFCMP_UGT()

static GenericValue executeFCMP_UGT ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFCMP_ULE()

static GenericValue executeFCMP_ULE ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFCMP_ULT()

static GenericValue executeFCMP_ULT ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFCMP_UNE()

static GenericValue executeFCMP_UNE ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFCMP_UNO()

static GenericValue executeFCMP_UNO ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFDivInst()

static void executeFDivInst ( GenericValue Dest,
GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFMulInst()

static void executeFMulInst ( GenericValue Dest,
GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFRemInst()

static void executeFRemInst ( GenericValue Dest,
GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeFSubInst()

static void executeFSubInst ( GenericValue Dest,
GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeICMP_EQ()

static GenericValue executeICMP_EQ ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeICMP_NE()

static GenericValue executeICMP_NE ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeICMP_SGE()

static GenericValue executeICMP_SGE ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeICMP_SGT()

static GenericValue executeICMP_SGT ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeICMP_SLE()

static GenericValue executeICMP_SLE ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeICMP_SLT()

static GenericValue executeICMP_SLT ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeICMP_UGE()

static GenericValue executeICMP_UGE ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeICMP_UGT()

static GenericValue executeICMP_UGT ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeICMP_ULE()

static GenericValue executeICMP_ULE ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeICMP_ULT()

static GenericValue executeICMP_ULT ( GenericValue  Src1,
GenericValue  Src2,
Type Ty 
)
static

◆ executeSelectInst()

static GenericValue executeSelectInst ( GenericValue  Src1,
GenericValue  Src2,
GenericValue  Src3,
Type Ty 
)
static

◆ getShiftAmount()

static unsigned getShiftAmount ( uint64_t  orgShiftAmount,
llvm::APInt  valueToShift 
)
static

◆ SetValue()

static void SetValue ( Value V,
GenericValue  Val,
ExecutionContext SF 
)
static

◆ STATISTIC()

STATISTIC ( NumDynamicInsts  ,
"Number of dynamic instructions executed"   
)

Variable Documentation

◆ PrintVolatile

cl::opt<bool> PrintVolatile("interpreter-print-volatile", cl::Hidden, cl::desc("make the interpreter print every volatile load and store"))
static