2003-04-09 21:51:34 +00:00
|
|
|
//===- ModuloSchedGraph.h - Modulo Scheduling Graph and Set -*- C++ -*-----===//
|
2003-08-28 17:12:14 +00:00
|
|
|
//
|
2003-03-27 17:57:44 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2003-08-28 17:12:14 +00:00
|
|
|
#ifndef LLVM_MODULO_SCHED_GRAPH_H
|
|
|
|
#define LLVM_MODULO_SCHED_GRAPH_H
|
2003-04-09 21:51:34 +00:00
|
|
|
|
2003-03-27 17:57:44 +00:00
|
|
|
#include "llvm/Instruction.h"
|
2003-08-28 17:12:14 +00:00
|
|
|
#include "llvm/CodeGen/SchedGraphCommon.h"
|
2003-03-27 17:57:44 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2003-08-28 17:12:14 +00:00
|
|
|
#include "llvm/BasicBlock.h"
|
|
|
|
#include "llvm/Function.h"
|
2003-04-10 19:19:23 +00:00
|
|
|
#include "Support/hash_map"
|
2003-08-28 17:12:14 +00:00
|
|
|
#include <vector>
|
2003-03-27 17:57:44 +00:00
|
|
|
|
|
|
|
|
2003-08-28 17:12:14 +00:00
|
|
|
class ModuloSchedGraphNode : public SchedGraphNodeCommon {
|
2003-03-27 17:57:44 +00:00
|
|
|
|
2003-08-28 17:12:14 +00:00
|
|
|
const Instruction *Inst; //Node's Instruction
|
|
|
|
unsigned Earliest; //ASAP, or earliest time to be scheduled
|
|
|
|
unsigned Latest; //ALAP, or latested time to be scheduled
|
|
|
|
unsigned Depth; //Max Distance from node to the root
|
|
|
|
unsigned Height; //Max Distance from node to leaf
|
|
|
|
unsigned Mobility; //MOB, number of time slots it can be scheduled
|
|
|
|
const TargetMachine &Target; //Target information.
|
2003-03-27 17:57:44 +00:00
|
|
|
|
|
|
|
public:
|
2003-08-28 17:12:14 +00:00
|
|
|
ModuloSchedGraphNode(unsigned ID, int index, const Instruction *inst,
|
|
|
|
const TargetMachine &target);
|
2003-04-09 21:51:34 +00:00
|
|
|
|
2003-08-28 17:12:14 +00:00
|
|
|
void print(std::ostream &os) const;
|
|
|
|
const Instruction* getInst() { return Inst; }
|
|
|
|
unsigned getEarliest() { return Earliest; }
|
|
|
|
unsigned getLatest() { return Latest; }
|
|
|
|
unsigned getDepth() { return Depth; }
|
|
|
|
unsigned getHeight() { return Height; }
|
|
|
|
unsigned getMobility() { return Mobility; }
|
2003-06-10 19:09:00 +00:00
|
|
|
|
2003-08-28 17:12:14 +00:00
|
|
|
void setEarliest(unsigned early) { Earliest = early; }
|
|
|
|
void setLatest(unsigned late) { Latest = late; }
|
|
|
|
void setDepth(unsigned depth) { Depth = depth; }
|
|
|
|
void setHeight(unsigned height) { Height = height; }
|
|
|
|
void setMobility(unsigned mob) { Mobility = mob; }
|
2003-03-27 17:57:44 +00:00
|
|
|
|
|
|
|
|
2003-08-28 17:12:14 +00:00
|
|
|
};
|
2003-03-27 17:57:44 +00:00
|
|
|
|
2003-08-28 17:12:14 +00:00
|
|
|
class ModuloSchedGraph : public SchedGraphCommon {
|
2003-03-27 17:57:44 +00:00
|
|
|
|
2003-08-28 17:12:14 +00:00
|
|
|
const BasicBlock *BB; //The Basic block this graph represents
|
|
|
|
const TargetMachine &Target;
|
|
|
|
hash_map<const Instruction*, ModuloSchedGraphNode*> GraphMap;
|
2003-04-09 21:51:34 +00:00
|
|
|
|
2003-08-28 17:12:14 +00:00
|
|
|
void buildNodesForBB();
|
2003-04-09 21:51:34 +00:00
|
|
|
|
|
|
|
public:
|
2003-08-28 17:12:14 +00:00
|
|
|
typedef hash_map<const Instruction*,
|
|
|
|
ModuloSchedGraphNode*>::iterator iterator;
|
|
|
|
typedef hash_map<const Instruction*,
|
|
|
|
ModuloSchedGraphNode*>::const_iterator const_iterator;
|
|
|
|
|
|
|
|
|
|
|
|
ModuloSchedGraph(const BasicBlock *bb, const TargetMachine &targ);
|
|
|
|
|
|
|
|
const BasicBlock* getBB() { return BB; }
|
|
|
|
void setBB(BasicBlock *bb) { BB = bb; }
|
|
|
|
unsigned size() { return GraphMap.size(); }
|
|
|
|
void addNode(const Instruction *I, ModuloSchedGraphNode *node);
|
|
|
|
void ASAP(); //Calculate earliest schedule time for all nodes in graph.
|
|
|
|
void ALAP(); //Calculate latest schedule time for all nodes in graph.
|
|
|
|
void MOB(); //Calculate mobility for all nodes in the graph.
|
|
|
|
void ComputeDepth(); //Compute depth of each node in graph
|
|
|
|
void ComputeHeight(); //Computer height of each node in graph
|
|
|
|
void addDepEdges(); //Add Dependencies
|
|
|
|
iterator find(const Instruction *I) { return GraphMap.find(I); }
|
2003-03-27 17:57:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-08-28 17:12:14 +00:00
|
|
|
class ModuloSchedGraphSet {
|
|
|
|
|
|
|
|
const Function *function; //Function this set of graphs represent.
|
|
|
|
std::vector<ModuloSchedGraph*> Graphs;
|
2003-04-09 21:51:34 +00:00
|
|
|
|
2003-03-27 17:57:44 +00:00
|
|
|
public:
|
2003-08-28 17:12:14 +00:00
|
|
|
typedef std::vector<ModuloSchedGraph*>::iterator iterator;
|
|
|
|
typedef std::vector<ModuloSchedGraph*>::const_iterator const_iterator;
|
|
|
|
|
|
|
|
iterator begin() { return Graphs.begin(); }
|
|
|
|
iterator end() { return Graphs.end(); }
|
|
|
|
|
|
|
|
ModuloSchedGraphSet(const Function *func, const TargetMachine &target);
|
2003-04-09 21:51:34 +00:00
|
|
|
~ModuloSchedGraphSet();
|
|
|
|
|
2003-08-28 17:12:14 +00:00
|
|
|
void addGraph(ModuloSchedGraph *graph);
|
2003-04-10 19:19:23 +00:00
|
|
|
void dump() const;
|
2003-03-27 17:57:44 +00:00
|
|
|
|
|
|
|
|
2003-04-10 19:19:23 +00:00
|
|
|
};
|
2003-04-09 21:51:34 +00:00
|
|
|
|
|
|
|
#endif
|