//===- 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>
#include <math.h>
#define UNIDELAY 1
using std::cerr;
using std::endl;
using std::vector;
/***********member functions for ModuloSchedGraphNode*********/
ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned int in_nodeId,
const BasicBlock * in_bb,
const Instruction * in_inst,
int indexInBB,
const TargetMachine & target)
:SchedGraphNodeCommon(in_nodeId, indexInBB), inst(in_inst){
if (inst) {
//FIXME: find the latency
//currently set the latency to zero
latency = 0;
}
}
/***********member functions for ModuloSchedGraph*********/
void
ModuloSchedGraph::addDefUseEdges(const BasicBlock *bb){
//collect def instructions, store them in vector
const TargetInstrInfo & mii = target.getInstrInfo();
vector < ModuloSchedGraphNode * > defVec;
//find those def instructions
for (BasicBlock::const_iterator I = bb->begin(), E = bb->end(); I != E; ++I) {
if (I->getType() != Type::VoidTy) {
defVec.push_back(this->getGraphNodeForInst(I));
}
}
for (unsigned int i = 0; i < defVec.size(); i++) {
for (Value::use_const_iterator I = defVec[i]->getInst()->use_begin();<