43 #ifndef __CPU_O3_DEP_GRAPH_HH__
44 #define __CPU_O3_DEP_GRAPH_HH__
49 template <
class DynInstPtr>
72 template <
class DynInstPtr>
86 void resize(
int num_entries);
103 void remove(
PhysRegIndex idx, DynInstPtr &inst_to_remove);
140 template <
class DynInstPtr>
143 delete [] dependGraph;
146 template <
class DynInstPtr>
150 numEntries = num_entries;
151 dependGraph =
new DepEntry[numEntries];
154 template <
class DynInstPtr>
162 for (
int i = 0;
i < numEntries; ++
i) {
163 curr = dependGraph[
i].
next;
175 if (dependGraph[
i].inst) {
176 dependGraph[
i].
inst = NULL;
179 dependGraph[
i].next = NULL;
183 template <
class DynInstPtr>
193 new_entry->
next = dependGraph[idx].next;
194 new_entry->
inst = new_inst;
197 dependGraph[idx].next = new_entry;
203 template <
class DynInstPtr>
206 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.
void remove(PhysRegIndex idx, DynInstPtr &inst_to_remove)
Removes an instruction from a single linked list.
DependencyGraph()
Default construction.
void insert(PhysRegIndex idx, DynInstPtr &new_inst)
Inserts an instruction to be dependent on the given index.
void clearInst(PhysRegIndex idx)
Clears the producing instruction.
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...
DepEntry * dependGraph
Array of linked lists.
bool empty(PhysRegIndex idx) const
Checks if there are any dependents on a specific register.
DependencyEntry< DynInstPtr > DepEntry
int numEntries
Number of linked lists; identical to the number of registers.
bool empty() const
Checks if the entire dependency graph is empty.
void dump()
Debugging function to dump out the dependency graph.
DynInstPtr pop(PhysRegIndex idx)
Removes and returns the newest dependent of a specific register.
void setInst(PhysRegIndex idx, DynInstPtr &new_inst)
Sets the producing instruction of a given register.
void cprintf(const char *format, const Args &...args)