LLVM API Documentation

Execution.cpp File Reference

#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/Statistic.h"
#include "llvm/Support/Debug.h"
#include <cmath>

Include dependency graph for Execution.cpp:

Go to the source code of this file.

Defines

#define DEBUG_TYPE   "interpreter"
#define IMPLEMENT_BINARY_OPERATOR(OP, TY)   case Type::TY##TyID: Dest.TY##Val = Src1.TY##Val OP Src2.TY##Val; break
#define IMPLEMENT_SETCC(OP, TY)   case Type::TY##TyID: Dest.BoolVal = Src1.TY##Val OP Src2.TY##Val; break
#define IMPLEMENT_POINTERSETCC(OP)
#define IMPLEMENT_SHIFT(OP, TY)   case Type::TY##TyID: Dest.TY##Val = Src1.TY##Val OP Src2.UByteVal; break
#define IMPLEMENT_CAST(DTY, DCTY, STY)   case Type::STY##TyID: Dest.DTY##Val = DCTY Src.STY##Val; break;
#define IMPLEMENT_CAST_CASE_START(DESTTY, DESTCTY)
#define IMPLEMENT_CAST_CASE_FP_IMP(DESTTY, DESTCTY)
#define IMPLEMENT_CAST_CASE_END()
#define IMPLEMENT_CAST_CASE(DESTTY, DESTCTY)
#define IMPLEMENT_VAARG(TY)   case Type::TY##TyID: Dest.TY##Val = Src.TY##Val; break

Functions

static GenericValue executeAddInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeSubInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeMulInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeRemInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeDivInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeAndInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeOrInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeXorInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeSetEQInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeSetNEInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeSetLTInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeSetGTInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeSetLEInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeSetGEInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeShlInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeShrInst (GenericValue Src1, GenericValue Src2, const Type *Ty)
static GenericValue executeSelectInst (GenericValue Src1, GenericValue Src2, GenericValue Src3)
static void SetValue (Value *V, GenericValue Val, ExecutionContext &SF)

Variables

Statistic NumDynamicInsts ("lli","Number of dynamic instructions executed")
InterpreterTheEE = 0


Define Documentation

#define DEBUG_TYPE   "interpreter"

Definition at line 14 of file Execution.cpp.

#define IMPLEMENT_BINARY_OPERATOR ( OP,
TY   )     case Type::TY##TyID: Dest.TY##Val = Src1.TY##Val OP Src2.TY##Val; break

Definition at line 179 of file Execution.cpp.

Referenced by executeAddInst(), executeAndInst(), executeDivInst(), executeMulInst(), executeOrInst(), executeRemInst(), executeSubInst(), and executeXorInst().

#define IMPLEMENT_CAST ( DTY,
DCTY,
STY   )     case Type::STY##TyID: Dest.DTY##Val = DCTY Src.STY##Val; break;

Definition at line 928 of file Execution.cpp.

#define IMPLEMENT_CAST_CASE ( DESTTY,
DESTCTY   ) 

Value:

Definition at line 955 of file Execution.cpp.

 
#define IMPLEMENT_CAST_CASE_END (  ) 

Value:

default: std::cout << "Unhandled cast: " << *SrcTy << " to " << *Ty << "\n"; \
      abort();                                  \
    }                                           \
    break

Definition at line 949 of file Execution.cpp.

#define IMPLEMENT_CAST_CASE_FP_IMP ( DESTTY,
DESTCTY   ) 

Value:

IMPLEMENT_CAST(DESTTY, DESTCTY, Float);   \
      IMPLEMENT_CAST(DESTTY, DESTCTY, Double)

Definition at line 945 of file Execution.cpp.

#define IMPLEMENT_CAST_CASE_START ( DESTTY,
DESTCTY   ) 

Value:

case Type::DESTTY##TyID:                      \
    switch (SrcTy->getTypeID()) {          \
      IMPLEMENT_CAST(DESTTY, DESTCTY, Bool);    \
      IMPLEMENT_CAST(DESTTY, DESTCTY, UByte);   \
      IMPLEMENT_CAST(DESTTY, DESTCTY, SByte);   \
      IMPLEMENT_CAST(DESTTY, DESTCTY, UShort);  \
      IMPLEMENT_CAST(DESTTY, DESTCTY, Short);   \
      IMPLEMENT_CAST(DESTTY, DESTCTY, UInt);    \
      IMPLEMENT_CAST(DESTTY, DESTCTY, Int);     \
      IMPLEMENT_CAST(DESTTY, DESTCTY, ULong);   \
      IMPLEMENT_CAST(DESTTY, DESTCTY, Long);    \
      IMPLEMENT_CAST(DESTTY, DESTCTY, Pointer);

Definition at line 931 of file Execution.cpp.

#define IMPLEMENT_POINTERSETCC ( OP   ) 

Value:

case Type::PointerTyID: \
        Dest.BoolVal = (void*)(intptr_t)Src1.PointerVal OP \
                       (void*)(intptr_t)Src2.PointerVal; break

Definition at line 358 of file Execution.cpp.

Referenced by executeSetEQInst(), executeSetGEInst(), executeSetGTInst(), executeSetLEInst(), executeSetLTInst(), and executeSetNEInst().

#define IMPLEMENT_SETCC ( OP,
TY   )     case Type::TY##TyID: Dest.BoolVal = Src1.TY##Val OP Src2.TY##Val; break

Definition at line 351 of file Execution.cpp.

Referenced by executeSetEQInst(), executeSetGEInst(), executeSetGTInst(), executeSetLEInst(), executeSetLTInst(), and executeSetNEInst().

#define IMPLEMENT_SHIFT ( OP,
TY   )     case Type::TY##TyID: Dest.TY##Val = Src1.TY##Val OP Src2.UByteVal; break

Definition at line 868 of file Execution.cpp.

Referenced by executeShlInst(), and executeShrInst().

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

Definition at line 991 of file Execution.cpp.

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


Function Documentation

static GenericValue executeAddInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 182 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_BINARY_OPERATOR, and Ty.

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

static GenericValue executeAndInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 291 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_BINARY_OPERATOR, and Ty.

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

static GenericValue executeDivInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 245 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_BINARY_OPERATOR, and Ty.

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

static GenericValue executeMulInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 224 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_BINARY_OPERATOR, and Ty.

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

static GenericValue executeOrInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 311 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_BINARY_OPERATOR, and Ty.

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

static GenericValue executeRemInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 266 of file Execution.cpp.

References Dest, llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, llvm::Type::getTypeID(), IMPLEMENT_BINARY_OPERATOR, and Ty.

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

static GenericValue executeSelectInst ( GenericValue  Src1,
GenericValue  Src2,
GenericValue  Src3 
) [static]

Definition at line 526 of file Execution.cpp.

References llvm::GenericValue::BoolVal.

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

static GenericValue executeSetEQInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 363 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_POINTERSETCC, IMPLEMENT_SETCC, and Ty.

Referenced by llvm::Interpreter::visitBinaryOperator(), and llvm::Interpreter::visitSwitchInst().

static GenericValue executeSetGEInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 430 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_POINTERSETCC, IMPLEMENT_SETCC, and Ty.

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

static GenericValue executeSetGTInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 474 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_POINTERSETCC, IMPLEMENT_SETCC, and Ty.

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

static GenericValue executeSetLEInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 408 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_POINTERSETCC, IMPLEMENT_SETCC, and Ty.

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

static GenericValue executeSetLTInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 452 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_POINTERSETCC, IMPLEMENT_SETCC, and Ty.

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

static GenericValue executeSetNEInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 385 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_POINTERSETCC, IMPLEMENT_SETCC, and Ty.

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

static GenericValue executeShlInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 871 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_SHIFT, and Ty.

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

static GenericValue executeShrInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 889 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_SHIFT, and Ty.

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

static GenericValue executeSubInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 203 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_BINARY_OPERATOR, and Ty.

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

static GenericValue executeXorInst ( GenericValue  Src1,
GenericValue  Src2,
const Type Ty 
) [static]

Definition at line 331 of file Execution.cpp.

References Dest, llvm::Type::getTypeID(), IMPLEMENT_BINARY_OPERATOR, and Ty.

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

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

Definition at line 167 of file Execution.cpp.

References V, Val, and llvm::ExecutionContext::Values.

Referenced by llvm::Interpreter::callFunction(), llvm::Interpreter::visitAllocationInst(), llvm::Interpreter::visitBinaryOperator(), llvm::Interpreter::visitCallSite(), llvm::Interpreter::visitCastInst(), llvm::Interpreter::visitGetElementPtrInst(), llvm::Interpreter::visitLoadInst(), llvm::Interpreter::visitSelectInst(), llvm::Interpreter::visitShl(), llvm::Interpreter::visitShr(), and llvm::Interpreter::visitVAArgInst().


Variable Documentation

Statistic NumDynamicInsts("lli","Number of dynamic instructions executed") [static]

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

Interpreter* TheEE = 0 [static]

Definition at line 29 of file Execution.cpp.

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