//===-- Execution.cpp - Implement code to simulate the program ------------===//
//
// This file contains the actual instruction interpreter.
//
//===----------------------------------------------------------------------===//
#include "Interpreter.h"
#include "ExecutionAnnotations.h"
#include "llvm/GlobalVariable.h"
#include "llvm/Function.h"
#include "llvm/iPHINode.h"
#include "llvm/iOther.h"
#include "llvm/iTerminators.h"
#include "llvm/iMemory.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Constants.h"
#include "llvm/Assembly/Writer.h"
#include "Support/CommandLine.h"
#include "Support/Statistic.h"
#include <math.h> // For fmod
#include <signal.h>
#include <setjmp.h>
using std::vector;
using std::cout;
using std::cerr;
Interpreter *TheEE = 0;
namespace {
Statistic<> NumDynamicInsts("lli", "Number of dynamic instructions executed");
cl::opt<bool>
QuietMode("quiet", cl::desc("Do not emit any non-program output"),
cl::init(true));
cl::alias
QuietModeA("q", cl::desc("Alias for -quiet"), cl::aliasopt(QuietMode));
cl::opt<bool>
ArrayChecksEnabled("array-checks", cl::desc("Enable array bound checks"));
cl::opt<bool>
AbortOnExceptions("abort-on-exception",
cl::desc("Halt execution on a machine exception"));
}
// Create a TargetData structure to handle memory addressing and size/alignment
// computations
//
CachedWriter CW; // Object to accelerate printing of LLVM
#ifdef PROFILE_STRUCTURE_FIELDS
static cl::opt<bool>
ProfileStructureFields("profilestructfields",
cl::desc("Profile Structure Field Accesses"));
#include <map>
static std::map<const StructType *, vector<unsigned> > FieldAccessCounts;
#endif
sigjmp_buf SignalRecoverBuffer;
static bool InInstruction = false;
extern "C" {
static void SigHandler(int Signal) {
if (InInstruction)
siglongjmp(SignalRecoverBuffer, Signal);
}
}
static void initializeSignalHandlers() {
struct sigaction Action;
Action.sa_handler = SigHandler;
Action.sa_flags = SA_SIGINFO;
sigemptyset(&Action.sa_mask);
<