//===- ModuloSchedGraph.cpp - Graph datastructure for Modulo Scheduling ---===//
//
//
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/InstrSelection.h"
#include "llvm/Function.h"
#include "llvm/Instructions.h"
#include "llvm/Type.h"
#include "llvm/CodeGen/MachineCodeForInstruction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Target/TargetSchedInfo.h"
#include "Support/StringExtras.h"
#include "Support/STLExtras.h"
#include "Support/hash_map"
#include "Support/Statistic.h"
#include "ModuloScheduling.h"
#include "ModuloSchedGraph.h"
#include <algorithm>
#include <ostream>
#include <vector>
// FIXME: Should be using #include <cmath>
#include <math.h>
//#include <swig.h>
#define UNIDELAY 1
//*********************** Internal Data Structures *************************/
// The following two types need to be classes, not typedefs, so we can use
// opaque declarations in SchedGraph.h
//
struct RefVec:public std::vector<std::pair<ModuloSchedGraphNode*,int> > {
typedef std::vector<std::pair<ModuloSchedGraphNode*,
int> >::iterator iterator;
typedef std::vector<std::pair<ModuloSchedGraphNode*,
int> >::const_iterator const_iterator;
};
struct RegToRefVecMap:public hash_map<int,RefVec> {
typedef hash_map<int,RefVec>::iterator iterator;
typedef hash_map<int,RefVec>::const_iterator const_iterator;
};
struct ValueToDefVecMap:public hash_map<const Instruction*,RefVec> {
typedef hash_map<const Instruction*, RefVec>::iterator iterator;
typedef hash_map<const Instruction*,
RefVec>::const_iterator const_iterator;
};
// class Modulo SchedGraphNode
ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned int _nodeId,
const BasicBlock * _bb,
const Instruction * _inst,
int indexInBB,
const TargetMachine