43 #ifndef __CPU_O3_DEP_GRAPH_HH__ 44 #define __CPU_O3_DEP_GRAPH_HH__ 49 template <
class DynInstPtr>
72 template <
class DynInstPtr>
80 : numEntries(0), memAllocCounter(0), nodesTraversed(0), nodesRemoved(0)
86 void resize(
int num_entries);
92 void insert(
PhysRegIndex idx,
const DynInstPtr &new_inst);
96 { dependGraph[idx].inst = new_inst; }
100 { dependGraph[idx].inst = NULL; }
103 void remove(
PhysRegIndex idx,
const DynInstPtr &inst_to_remove);
140 template <
class DynInstPtr>
145 template <
class DynInstPtr>
149 numEntries = num_entries;
150 dependGraph.resize(numEntries);
153 template <
class DynInstPtr>
161 for (
int i = 0;
i < numEntries; ++
i) {
162 curr = dependGraph[
i].
next;
174 if (dependGraph[
i].
inst) {
175 dependGraph[
i].
inst = NULL;
178 dependGraph[
i].next = NULL;
182 template <
class DynInstPtr>
185 const DynInstPtr &new_inst)
193 new_entry->
next = dependGraph[idx].next;
194 new_entry->
inst = new_inst;
197 dependGraph[idx].next = new_entry;
203 template <
class DynInstPtr>
206 const DynInstPtr &inst_to_remove)
222 while (curr->
inst != inst_to_remove) {
227 assert(curr != NULL);
241 template <
class DynInstPtr>
246 node = dependGraph[idx].
next;
247 DynInstPtr
inst = NULL;
250 dependGraph[idx].next = node->
next;
258 template <
class DynInstPtr>
262 for (
int i = 0;
i < numEntries; ++
i) {
269 template <
class DynInstPtr>
275 for (
int i = 0;
i < numEntries; ++
i)
277 curr = &dependGraph[
i];
280 cprintf(
"dependGraph[%i]: producer: %s [sn:%lli] consumer: ",
281 i, curr->
inst->pcState(), curr->
inst->seqNum);
283 cprintf(
"dependGraph[%i]: No producer. consumer: ",
i);
286 while (curr->
next != NULL) {
290 curr->
inst->pcState(), curr->
inst->seqNum);
295 cprintf(
"memAllocCounter: %i\n", memAllocCounter);
298 #endif // __CPU_O3_DEP_GRAPH_HH__ DependencyEntry< DynInstPtr > * next
void reset()
Clears all of the linked lists.
std::vector< DepEntry > dependGraph
Array of linked lists.
void setInst(PhysRegIndex idx, const DynInstPtr &new_inst)
Sets the producing instruction of a given register.
DependencyGraph()
Default construction.
void clearInst(PhysRegIndex idx)
Clears the producing instruction.
void remove(PhysRegIndex idx, const DynInstPtr &inst_to_remove)
Removes an instruction from a single linked list.
void resize(int num_entries)
Resize the dependency graph to have num_entries registers.
Array of linked list that maintains the dependencies between producing instructions and consuming ins...
bool empty(PhysRegIndex idx) const
Checks if there are any dependents on a specific register.
short int PhysRegIndex
Physical register index type.
bool empty() const
Checks if the entire dependency graph is empty.
void insert(PhysRegIndex idx, const DynInstPtr &new_inst)
Inserts an instruction to be dependent on the given index.
DependencyEntry< DynInstPtr > DepEntry
int numEntries
Number of linked lists; identical to the number of registers.
void dump()
Debugging function to dump out the dependency graph.
void dump()
Dump all statistics data to the registered outputs.
DynInstPtr pop(PhysRegIndex idx)
Removes and returns the newest dependent of a specific register.
void cprintf(const char *format, const Args &...args)