const unsigned int nslots;
unsigned int numInstr;
std::vector<InstrGroup*> groups; // indexed by cycle number
- std::vector<cycles_t> startTime; // indexed by node id
+ std::vector<CycleCount_t> startTime; // indexed by node id
InstrSchedule(InstrSchedule&); // DO NOT IMPLEMENT
void operator=(InstrSchedule&); // DO NOT IMPLEMENT
public: // accessor functions to query chosen schedule
const SchedGraphNode* getInstr (unsigned int slotNum,
- cycles_t c) const {
+ CycleCount_t c) const {
const InstrGroup* igroup = this->getIGroup(c);
return (igroup == NULL)? NULL : (*igroup)[slotNum];
}
- inline InstrGroup* getIGroup (cycles_t c) {
+ inline InstrGroup* getIGroup (CycleCount_t c) {
if ((unsigned)c >= groups.size())
groups.resize(c+1);
if (groups[c] == NULL)
return groups[c];
}
- inline const InstrGroup* getIGroup (cycles_t c) const {
+ inline const InstrGroup* getIGroup (CycleCount_t c) const {
assert((unsigned)c < groups.size());
return groups[c];
}
- inline cycles_t getStartTime (unsigned int nodeId) const {
+ inline CycleCount_t getStartTime (unsigned int nodeId) const {
assert(nodeId < startTime.size());
return startTime[nodeId];
}
inline void scheduleInstr (const SchedGraphNode* node,
unsigned int slotNum,
- cycles_t cycle) {
+ CycleCount_t cycle) {
InstrGroup* igroup = this->getIGroup(cycle);
if (!((*igroup)[slotNum] == NULL)) {
std::cerr << "Slot already filled?\n";
: nslots(_nslots),
numInstr(0),
groups(2 * _numNodes / _nslots), // 2 x lower-bound for #cycles
- startTime(_numNodes, (cycles_t) -1) // set all to -1
+ startTime(_numNodes, (CycleCount_t) -1) // set all to -1
{
}
const SchedGraphNode* brNode;
unsigned ndelays;
std::vector<const SchedGraphNode*> delayNodeVec;
- cycles_t delayedNodeCycle;
+ CycleCount_t delayedNodeCycle;
unsigned delayedNodeSlotNum;
DelaySlotInfo(const DelaySlotInfo &); // DO NOT IMPLEMENT
assert(delayNodeVec.size() <= ndelays && "Too many delay slot instrs!");
}
- inline void recordChosenSlot (cycles_t cycle, unsigned slotNum) {
+ inline void recordChosenSlot (CycleCount_t cycle, unsigned slotNum) {
delayedNodeCycle = cycle;
delayedNodeSlotNum = slotNum;
}
private:
unsigned totalInstrCount;
- cycles_t curTime;
- cycles_t nextEarliestIssueTime; // next cycle we can issue
+ CycleCount_t curTime;
+ CycleCount_t nextEarliestIssueTime; // next cycle we can issue
// indexed by slot#
std::vector<hash_set<const SchedGraphNode*> > choicesForSlot;
std::vector<const SchedGraphNode*> choiceVec; // indexed by node ptr
std::vector<int> numInClass; // indexed by sched class
- std::vector<cycles_t> nextEarliestStartTime; // indexed by opCode
+ std::vector<CycleCount_t> nextEarliestStartTime; // indexed by opCode
hash_map<const SchedGraphNode*, DelaySlotInfo*> delaySlotInfoForBranches;
// indexed by branch node ptr
// Interface for checking and updating the current time
//----------------------------------------------------------------------
- inline cycles_t getTime () const {
+ inline CycleCount_t getTime () const {
return curTime;
}
- inline cycles_t getEarliestIssueTime() const {
+ inline CycleCount_t getEarliestIssueTime() const {
return nextEarliestIssueTime;
}
- inline cycles_t getEarliestStartTimeForOp(MachineOpCode opCode) const {
+ inline CycleCount_t getEarliestStartTimeForOp(MachineOpCode opCode) const {
assert(opCode < (int) nextEarliestStartTime.size());
return nextEarliestStartTime[opCode];
}
// Update current time to specified cycle
- inline void updateTime (cycles_t c) {
+ inline void updateTime (CycleCount_t c) {
curTime = c;
schedPrio.updateTime(c);
}
inline void scheduleInstr (const SchedGraphNode* node,
unsigned int slotNum,
- cycles_t cycle)
+ CycleCount_t cycle)
{
assert(! isScheduled(node) && "Instruction already scheduled?");
private:
SchedulingManager(); // DISABLED: DO NOT IMPLEMENT
- void updateEarliestStartTimes(const SchedGraphNode* node, cycles_t schedTime);
+ void updateEarliestStartTimes(const SchedGraphNode* node, CycleCount_t schedTime);
};
choicesForSlot(nslots),
numInClass(target.getSchedInfo()->getNumSchedClasses(), 0), // set all to 0
nextEarliestStartTime(target.getInstrInfo()->getNumOpcodes(),
- (cycles_t) 0) // set all to 0
+ (CycleCount_t) 0) // set all to 0
{
updateTime(0);
void
SchedulingManager::updateEarliestStartTimes(const SchedGraphNode* node,
- cycles_t schedTime)
+ CycleCount_t schedTime)
{
if (schedInfo.numBubblesAfter(node->getOpcode()) > 0)
{ // Update next earliest time before which *nothing* can issue.
for (unsigned i=0; i < conflictVec.size(); i++)
{
MachineOpCode toOp = conflictVec[i];
- cycles_t est=schedTime + schedInfo.getMinIssueGap(node->getOpcode(),toOp);
+ CycleCount_t est=schedTime + schedInfo.getMinIssueGap(node->getOpcode(),toOp);
assert(toOp < (int) nextEarliestStartTime.size());
if (nextEarliestStartTime[toOp] < est)
nextEarliestStartTime[toOp] = est;
{
// find the slot to start from, in the current cycle
unsigned int startSlot = 0;
- cycles_t curTime = S.getTime();
+ CycleCount_t curTime = S.getTime();
assert(maxIssue > 0 && maxIssue <= S.nslots - startSlot);
// highest slot used. But we just mark that for now, and
// schedule it separately because we want to schedule the delay
// slots for the node at the same time.
- cycles_t dcycle = S.getTime();
+ CycleCount_t dcycle = S.getTime();
unsigned int dslot = highestSlotUsed + 1;
if (dslot == S.nslots) {
dslot = 0;
assert(S.schedPrio.getNumReady() > 0
&& "Don't get here without ready instructions.");
- cycles_t firstCycle = S.getTime();
+ CycleCount_t firstCycle = S.getTime();
DelaySlotInfo* getDelaySlotInfo = NULL;
// Choose up to `nslots' feasible instructions and their possible slots.
// Print trace of scheduled instructions before newly ready ones
if (SchedDebugLevel >= Sched_PrintSchedTrace) {
- for (cycles_t c = firstCycle; c <= S.getTime(); c++) {
+ for (CycleCount_t c = firstCycle; c <= S.getTime(); c++) {
std::cerr << " Cycle " << (long)c <<" : Scheduled instructions:\n";
const InstrGroup* igroup = S.isched.getIGroup(c);
for (unsigned int s=0; s < S.nslots; s++) {
S.schedPrio.initialize();
while ((N = S.schedPrio.getNumReady()) > 0) {
- cycles_t nextCycle = S.getTime();
+ CycleCount_t nextCycle = S.getTime();
// Choose one group of instructions for a cycle, plus any delay slot
// instructions (which may overflow into successive cycles).
// Notify the priority manager of scheduled instructions and mark
// any successors that may now be ready
//
- for (cycles_t c = nextCycle; c <= S.getTime(); c++) {
+ for (CycleCount_t c = nextCycle; c <= S.getTime(); c++) {
const InstrGroup* igroup = S.isched.getIGroup(c);
for (unsigned int s=0; s < S.nslots; s++)
if ((node = (*igroup)[s]) != NULL) {
&& "Slot for branch should be empty");
unsigned int nextSlot = delayedNodeSlotNum;
- cycles_t nextTime = delayedNodeCycle;
+ CycleCount_t nextTime = delayedNodeCycle;
S.scheduleInstr(brNode, nextSlot, nextTime);
static inline bool
ViolatesMinimumGap(const SchedulingManager& S,
MachineOpCode opCode,
- const cycles_t inCycle)
+ const CycleCount_t inCycle)
{
return (inCycle < S.getEarliestStartTimeForOp(opCode));
}
po_iterator<const SchedGraph*> poIter = po_begin(graph), poEnd =po_end(graph);
for ( ; poIter != poEnd; ++poIter) {
const SchedGraphNode* node = *poIter;
- cycles_t nodeDelay;
+ CycleCount_t nodeDelay;
if (node->beginOutEdges() == node->endOutEdges())
nodeDelay = node->getLatency();
else {
nodeDelay = 0;
for (SchedGraphNode::const_iterator E=node->beginOutEdges();
E != node->endOutEdges(); ++E) {
- cycles_t sinkDelay = getNodeDelay((SchedGraphNode*)(*E)->getSink());
+ CycleCount_t sinkDelay = getNodeDelay((SchedGraphNode*)(*E)->getSink());
nodeDelay = std::max(nodeDelay, sinkDelay + (*E)->getMinDelay());
}
}
}
void
-SchedPriorities::issuedReadyNodeAt(cycles_t curTime,
+SchedPriorities::issuedReadyNodeAt(CycleCount_t curTime,
const SchedGraphNode* node) {
candsAsHeap.removeNode(node);
candsAsSet.erase(node);
// Now update ready times for successors
for (SchedGraphNode::const_iterator E=node->beginOutEdges();
E != node->endOutEdges(); ++E) {
- cycles_t& etime =
+ CycleCount_t& etime =
getEarliestReadyTimeForNodeRef((SchedGraphNode*)(*E)->getSink());
etime = std::max(etime, curTime + (*E)->getMinDelay());
}
const SchedGraphNode*
SchedPriorities::getNextHighest(const SchedulingManager& S,
- cycles_t curTime) {
+ CycleCount_t curTime) {
int nextIdx = -1;
const SchedGraphNode* nextChoice = NULL;
{ // out of choices at current maximum delay;
// put nodes with next highest delay in mcands
candIndex next = nextToTry;
- cycles_t maxDelay = candsAsHeap.getDelay(next);
+ CycleCount_t maxDelay = candsAsHeap.getDelay(next);
for (; next != candsAsHeap.end()
&& candsAsHeap.getDelay(next) == maxDelay; ++next)
mcands.push_back(next);
struct NodeDelayPair {
const SchedGraphNode* node;
- cycles_t delay;
- NodeDelayPair(const SchedGraphNode* n, cycles_t d) : node(n), delay(d) {}
+ CycleCount_t delay;
+ NodeDelayPair(const SchedGraphNode* n, CycleCount_t d) : node(n), delay(d) {}
inline bool operator<(const NodeDelayPair& np) { return delay < np.delay; }
};
inline unsigned size() const { return _size; }
const SchedGraphNode* getNode (const_iterator i) const { return (*i)->node; }
- cycles_t getDelay(const_iterator i) const { return (*i)->delay;}
+ CycleCount_t getDelay(const_iterator i) const { return (*i)->delay;}
inline void makeHeap() {
// make_heap(begin(), end(), NDPLessThan);
}
};
- void insert(const SchedGraphNode* node, cycles_t delay) {
+ void insert(const SchedGraphNode* node, CycleCount_t delay) {
NodeDelayPair* ndp = new NodeDelayPair(node, delay);
if (_size == 0 || front()->delay < delay)
push_front(ndp);
// This must be called before scheduling begins.
void initialize ();
- cycles_t getTime () const { return curTime; }
- cycles_t getEarliestReadyTime () const { return earliestReadyTime; }
+ CycleCount_t getTime () const { return curTime; }
+ CycleCount_t getEarliestReadyTime () const { return earliestReadyTime; }
unsigned getNumReady () const { return candsAsHeap.size(); }
bool nodeIsReady (const SchedGraphNode* node) const {
return (candsAsSet.find(node) != candsAsSet.end());
}
- void issuedReadyNodeAt (cycles_t curTime,
+ void issuedReadyNodeAt (CycleCount_t curTime,
const SchedGraphNode* node);
void insertReady (const SchedGraphNode* node);
- void updateTime (cycles_t /*unused*/);
+ void updateTime (CycleCount_t /*unused*/);
const SchedGraphNode* getNextHighest (const SchedulingManager& S,
- cycles_t curTime);
+ CycleCount_t curTime);
// choose next highest priority instr
private:
typedef NodeHeap::iterator candIndex;
private:
- cycles_t curTime;
+ CycleCount_t curTime;
const SchedGraph* graph;
FunctionLiveVarInfo &methodLiveVarInfo;
hash_map<const MachineInstr*, bool> lastUseMap;
- std::vector<cycles_t> nodeDelayVec;
- std::vector<cycles_t> nodeEarliestUseVec;
- std::vector<cycles_t> earliestReadyTimeForNode;
- cycles_t earliestReadyTime;
+ std::vector<CycleCount_t> nodeDelayVec;
+ std::vector<CycleCount_t> nodeEarliestUseVec;
+ std::vector<CycleCount_t> earliestReadyTimeForNode;
+ CycleCount_t earliestReadyTime;
NodeHeap candsAsHeap; // candidate nodes, ready to go
hash_set<const SchedGraphNode*> candsAsSet; //same entries as candsAsHeap,
// but as set for fast lookup
// NOTE: The next two return references to the actual vector entries.
// Use the following two if you don't need to modify the value.
- cycles_t& getNodeDelayRef (const SchedGraphNode* node) {
+ CycleCount_t& getNodeDelayRef (const SchedGraphNode* node) {
assert(node->getNodeId() < nodeDelayVec.size());
return nodeDelayVec[node->getNodeId()];
}
- cycles_t& getEarliestReadyTimeForNodeRef (const SchedGraphNode* node) {
+ CycleCount_t& getEarliestReadyTimeForNodeRef (const SchedGraphNode* node) {
assert(node->getNodeId() < earliestReadyTimeForNode.size());
return earliestReadyTimeForNode[node->getNodeId()];
}
- cycles_t getNodeDelay (const SchedGraphNode* node) const {
+ CycleCount_t getNodeDelay (const SchedGraphNode* node) const {
return ((SchedPriorities*) this)->getNodeDelayRef(node);
}
- cycles_t getEarliestReadyTimeForNode(const SchedGraphNode* node) const {
+ CycleCount_t getEarliestReadyTimeForNode(const SchedGraphNode* node) const {
return ((SchedPriorities*) this)->getEarliestReadyTimeForNodeRef(node);
}
};
-inline void SchedPriorities::updateTime(cycles_t c) {
+inline void SchedPriorities::updateTime(CycleCount_t c) {
curTime = c;
nextToTry = candsAsHeap.begin();
mcands.clear();