// class Modulo SchedGraphNode
-ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned int _nodeId,
- const BasicBlock * _bb,
- const Instruction * _inst,
+ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned int in_nodeId,
+ const BasicBlock * in_bb,
+ const Instruction * in_inst,
int indexInBB,
const TargetMachine & target)
-:SchedGraphNodeCommon(_nodeId, _bb, indexInBB), inst(_inst)
+:SchedGraphNodeCommon(in_nodeId, indexInBB), inst(in_inst)
{
if (inst) {
//FIXME: find the latency
//only if the last instruction in the basicblock is branch instruction and
//there is at least an option to branch itself
- assert(bbVec.size() == 1 && "only 1 basicblock in a graph");
- const BasicBlock *bb = bbVec[0];
+ assert(this->bb&& "the basicblock is not empty");
const Instruction *inst = &(bb->back());
if (BranchInst::classof(inst))
for (unsigned i = 0; i < ((BranchInst *) inst)->getNumSuccessors();
if (sb == bb)
return true;
}
-
+
return false;
}
oNodes.clear();
std::vector < ModuloSchedGraphNode * >set;
- const BasicBlock *bb = bbVec[0];
unsigned numNodes = bb->size();
// first order all the sets
void ModuloSchedGraph::buildGraph(const TargetMachine & target)
{
- const BasicBlock *bb = bbVec[0];
- assert(bbVec.size() == 1 && "only handling a single basic block here");
+ assert(this->bb && "The basicBlock is NULL?");
// Use this data structure to note all machine operands that compute
// ordinary LLVM values. These must be computed defs (i.e., instructions).
void ModuloSchedGraph::dump() const
{
DEBUG(std::cerr << " ModuloSchedGraph for basic Blocks:");
- for (unsigned i = 0, N = bbVec.size(); i < N; i++) {
- DEBUG(std::cerr << (bbVec[i]->hasName()? bbVec[i]->getName() : "block")
- << " (" << bbVec[i] << ")" << ((i == N - 1) ? "" : ", "));
- }
+
+ DEBUG(std::cerr << (bb->hasName()? bb->getName() : "block")
+ << " (" << bb << ")" << "");
DEBUG(std::cerr << "\n\n Actual Root nodes : ");
for (unsigned i = 0, N = graphRoot->outEdges.size(); i < N; i++)
DEBUG(std::cerr << "\n Graph Nodes:\n");
//for (const_iterator I=begin(); I != end(); ++I)
//DEBUG(std::cerr << "\n" << *I->second;
- unsigned numNodes = bbVec[0]->size();
+ unsigned numNodes = bb->size();
for (unsigned i = 2; i < numNodes + 2; i++) {
ModuloSchedGraphNode *node = getNode(i);
DEBUG(std::cerr << "\n" << *node);
void ModuloSchedGraph::dumpNodeProperty() const
{
- const BasicBlock *bb = bbVec[0];
+
unsigned numNodes = bb->size();
for (unsigned i = 2; i < numNodes + 2; i++) {
ModuloSchedGraphNode *node = getNode(i);
void ModuloSchedGraphSet::buildGraphsForMethod(const Function *F,
const TargetMachine &target)
{
- for (Function::const_iterator BI = F->begin(); BI != F->end(); ++BI)
- addGraph(new ModuloSchedGraph(BI, target));
+ for (Function::const_iterator BI = F->begin(); BI != F->end(); ++BI){
+ const BasicBlock* local_bb;
+ local_bb=BI;
+ addGraph(new ModuloSchedGraph((BasicBlock*)local_bb, target));
+ }
}
std::ostream& operator<<(std::ostream &os,
const unsigned getInstOpcode() const {
return inst->getOpcode();
}
+
//return whether the node is NULL
bool isNullNode() const {
return (inst == NULL);
protected hash_map<const Instruction*,ModuloSchedGraphNode*> {
private:
+
+ BasicBlock* bb;
+
//iteration Interval
int MII;
typedef std::vector<ModuloSchedGraphNode*> NodeVec;
//the function to compute properties
- void computeNodeASAP(const BasicBlock *bb);
- void computeNodeALAP(const BasicBlock *bb);
- void computeNodeMov(const BasicBlock *bb);
- void computeNodeDepth(const BasicBlock *bb);
- void computeNodeHeight(const BasicBlock *bb);
+ void computeNodeASAP(const BasicBlock * in_bb);
+ void computeNodeALAP(const BasicBlock * in_bb);
+ void computeNodeMov(const BasicBlock * in_bb);
+ void computeNodeDepth(const BasicBlock * in_bb);
+ void computeNodeHeight(const BasicBlock * in_bb);
//the function to compute node property
- void computeNodeProperty(const BasicBlock *bb);
+ void computeNodeProperty(const BasicBlock * in_bb);
//the function to sort nodes
void orderNodes();
const TargetMachine & getTarget() {
return target;
}
+
+ //get the basic block
+ BasicBlock* getBasicBlock() const {
+ return bb;
+ }
+
+
//get the iteration interval
const int getMII() {
return MII;
friend class ModuloSchedGraphSet; //give access to ctor
public:
- ModuloSchedGraph(const BasicBlock *bb, const TargetMachine &_target)
- :SchedGraphCommon(bb), target(_target)
+ ModuloSchedGraph(BasicBlock * in_bb,
+ const TargetMachine & in_target)
+ :SchedGraphCommon(), bb(in_bb),target(in_target)
{
buildGraph(target);
}
graph(_graph), target(graph.getTarget()), oNodes(graph.getONodes())
{
II = graph.getMII();
- bb = (BasicBlock *) graph.getBasicBlocks()[0];
+ bb = graph.getBasicBlock();
instrScheduling();
};
// class Modulo SchedGraphNode
-ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned int _nodeId,
- const BasicBlock * _bb,
- const Instruction * _inst,
+ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned int in_nodeId,
+ const BasicBlock * in_bb,
+ const Instruction * in_inst,
int indexInBB,
const TargetMachine & target)
-:SchedGraphNodeCommon(_nodeId, _bb, indexInBB), inst(_inst)
+:SchedGraphNodeCommon(in_nodeId, indexInBB), inst(in_inst)
{
if (inst) {
//FIXME: find the latency
//only if the last instruction in the basicblock is branch instruction and
//there is at least an option to branch itself
- assert(bbVec.size() == 1 && "only 1 basicblock in a graph");
- const BasicBlock *bb = bbVec[0];
+ assert(this->bb&& "the basicblock is not empty");
const Instruction *inst = &(bb->back());
if (BranchInst::classof(inst))
for (unsigned i = 0; i < ((BranchInst *) inst)->getNumSuccessors();
if (sb == bb)
return true;
}
-
+
return false;
}
oNodes.clear();
std::vector < ModuloSchedGraphNode * >set;
- const BasicBlock *bb = bbVec[0];
unsigned numNodes = bb->size();
// first order all the sets
void ModuloSchedGraph::buildGraph(const TargetMachine & target)
{
- const BasicBlock *bb = bbVec[0];
- assert(bbVec.size() == 1 && "only handling a single basic block here");
+ assert(this->bb && "The basicBlock is NULL?");
// Use this data structure to note all machine operands that compute
// ordinary LLVM values. These must be computed defs (i.e., instructions).
void ModuloSchedGraph::dump() const
{
DEBUG(std::cerr << " ModuloSchedGraph for basic Blocks:");
- for (unsigned i = 0, N = bbVec.size(); i < N; i++) {
- DEBUG(std::cerr << (bbVec[i]->hasName()? bbVec[i]->getName() : "block")
- << " (" << bbVec[i] << ")" << ((i == N - 1) ? "" : ", "));
- }
+
+ DEBUG(std::cerr << (bb->hasName()? bb->getName() : "block")
+ << " (" << bb << ")" << "");
DEBUG(std::cerr << "\n\n Actual Root nodes : ");
for (unsigned i = 0, N = graphRoot->outEdges.size(); i < N; i++)
DEBUG(std::cerr << "\n Graph Nodes:\n");
//for (const_iterator I=begin(); I != end(); ++I)
//DEBUG(std::cerr << "\n" << *I->second;
- unsigned numNodes = bbVec[0]->size();
+ unsigned numNodes = bb->size();
for (unsigned i = 2; i < numNodes + 2; i++) {
ModuloSchedGraphNode *node = getNode(i);
DEBUG(std::cerr << "\n" << *node);
void ModuloSchedGraph::dumpNodeProperty() const
{
- const BasicBlock *bb = bbVec[0];
+
unsigned numNodes = bb->size();
for (unsigned i = 2; i < numNodes + 2; i++) {
ModuloSchedGraphNode *node = getNode(i);
void ModuloSchedGraphSet::buildGraphsForMethod(const Function *F,
const TargetMachine &target)
{
- for (Function::const_iterator BI = F->begin(); BI != F->end(); ++BI)
- addGraph(new ModuloSchedGraph(BI, target));
+ for (Function::const_iterator BI = F->begin(); BI != F->end(); ++BI){
+ const BasicBlock* local_bb;
+ local_bb=BI;
+ addGraph(new ModuloSchedGraph((BasicBlock*)local_bb, target));
+ }
}
std::ostream& operator<<(std::ostream &os,
const unsigned getInstOpcode() const {
return inst->getOpcode();
}
+
//return whether the node is NULL
bool isNullNode() const {
return (inst == NULL);
protected hash_map<const Instruction*,ModuloSchedGraphNode*> {
private:
+
+ BasicBlock* bb;
+
//iteration Interval
int MII;
typedef std::vector<ModuloSchedGraphNode*> NodeVec;
//the function to compute properties
- void computeNodeASAP(const BasicBlock *bb);
- void computeNodeALAP(const BasicBlock *bb);
- void computeNodeMov(const BasicBlock *bb);
- void computeNodeDepth(const BasicBlock *bb);
- void computeNodeHeight(const BasicBlock *bb);
+ void computeNodeASAP(const BasicBlock * in_bb);
+ void computeNodeALAP(const BasicBlock * in_bb);
+ void computeNodeMov(const BasicBlock * in_bb);
+ void computeNodeDepth(const BasicBlock * in_bb);
+ void computeNodeHeight(const BasicBlock * in_bb);
//the function to compute node property
- void computeNodeProperty(const BasicBlock *bb);
+ void computeNodeProperty(const BasicBlock * in_bb);
//the function to sort nodes
void orderNodes();
const TargetMachine & getTarget() {
return target;
}
+
+ //get the basic block
+ BasicBlock* getBasicBlock() const {
+ return bb;
+ }
+
+
//get the iteration interval
const int getMII() {
return MII;
friend class ModuloSchedGraphSet; //give access to ctor
public:
- ModuloSchedGraph(const BasicBlock *bb, const TargetMachine &_target)
- :SchedGraphCommon(bb), target(_target)
+ ModuloSchedGraph(BasicBlock * in_bb,
+ const TargetMachine & in_target)
+ :SchedGraphCommon(), bb(in_bb),target(in_target)
{
buildGraph(target);
}
graph(_graph), target(graph.getTarget()), oNodes(graph.getONodes())
{
II = graph.getMII();
- bb = (BasicBlock *) graph.getBasicBlocks()[0];
+ bb = graph.getBasicBlock();
instrScheduling();
};