From 47877cf2dbd6ee2f1cf9b2c609d37b0589e876ca Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 26 May 2009 09:23:13 -0700 Subject: types: add a type for thread IDs and try to use it everywhere --- src/cpu/o3/decode_impl.hh | 79 ++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 39 deletions(-) (limited to 'src/cpu/o3/decode_impl.hh') diff --git a/src/cpu/o3/decode_impl.hh b/src/cpu/o3/decode_impl.hh index d92e97f61..86f87991c 100644 --- a/src/cpu/o3/decode_impl.hh +++ b/src/cpu/o3/decode_impl.hh @@ -29,9 +29,10 @@ */ #include "cpu/o3/decode.hh" - #include "params/DerivO3CPU.hh" +using namespace std; + template DefaultDecode::DefaultDecode(O3CPU *_cpu, DerivO3CPUParams *params) : cpu(_cpu), @@ -45,12 +46,12 @@ DefaultDecode::DefaultDecode(O3CPU *_cpu, DerivO3CPUParams *params) _status = Inactive; // Setup status, make sure stall signals are clear. - for (int i = 0; i < numThreads; ++i) { - decodeStatus[i] = Idle; + for (ThreadID tid = 0; tid < numThreads; ++tid) { + decodeStatus[tid] = Idle; - stalls[i].rename = false; - stalls[i].iew = false; - stalls[i].commit = false; + stalls[tid].rename = false; + stalls[tid].iew = false; + stalls[tid].commit = false; } // @todo: Make into a parameter @@ -148,7 +149,7 @@ DefaultDecode::setFetchQueue(TimeBuffer *fq_ptr) template void -DefaultDecode::setActiveThreads(std::list *at_ptr) +DefaultDecode::setActiveThreads(std::list *at_ptr) { activeThreads = at_ptr; } @@ -169,24 +170,24 @@ DefaultDecode::takeOverFrom() _status = Inactive; // Be sure to reset state and clear out any old instructions. - for (int i = 0; i < numThreads; ++i) { - decodeStatus[i] = Idle; - - stalls[i].rename = false; - stalls[i].iew = false; - stalls[i].commit = false; - while (!insts[i].empty()) - insts[i].pop(); - while (!skidBuffer[i].empty()) - skidBuffer[i].pop(); - branchCount[i] = 0; + for (ThreadID tid = 0; tid < numThreads; ++tid) { + decodeStatus[tid] = Idle; + + stalls[tid].rename = false; + stalls[tid].iew = false; + stalls[tid].commit = false; + while (!insts[tid].empty()) + insts[tid].pop(); + while (!skidBuffer[tid].empty()) + skidBuffer[tid].pop(); + branchCount[tid] = 0; } wroteToTimeBuffer = false; } template bool -DefaultDecode::checkStall(unsigned tid) const +DefaultDecode::checkStall(ThreadID tid) const { bool ret_val = false; @@ -213,7 +214,7 @@ DefaultDecode::fetchInstsValid() template bool -DefaultDecode::block(unsigned tid) +DefaultDecode::block(ThreadID tid) { DPRINTF(Decode, "[tid:%u]: Blocking.\n", tid); @@ -241,7 +242,7 @@ DefaultDecode::block(unsigned tid) template bool -DefaultDecode::unblock(unsigned tid) +DefaultDecode::unblock(ThreadID tid) { // Decode is done unblocking only if the skid buffer is empty. if (skidBuffer[tid].empty()) { @@ -260,7 +261,7 @@ DefaultDecode::unblock(unsigned tid) template void -DefaultDecode::squash(DynInstPtr &inst, unsigned tid) +DefaultDecode::squash(DynInstPtr &inst, ThreadID tid) { DPRINTF(Decode, "[tid:%i]: [sn:%i] Squashing due to incorrect branch prediction " "detected at decode.\n", tid, inst->seqNum); @@ -320,7 +321,7 @@ DefaultDecode::squash(DynInstPtr &inst, unsigned tid) template unsigned -DefaultDecode::squash(unsigned tid) +DefaultDecode::squash(ThreadID tid) { DPRINTF(Decode, "[tid:%i]: Squashing.\n",tid); @@ -369,7 +370,7 @@ DefaultDecode::squash(unsigned tid) template void -DefaultDecode::skidInsert(unsigned tid) +DefaultDecode::skidInsert(ThreadID tid) { DynInstPtr inst = NULL; @@ -395,11 +396,11 @@ template bool DefaultDecode::skidsEmpty() { - std::list::iterator threads = activeThreads->begin(); - std::list::iterator end = activeThreads->end(); + list::iterator threads = activeThreads->begin(); + list::iterator end = activeThreads->end(); while (threads != end) { - unsigned tid = *threads++; + ThreadID tid = *threads++; if (!skidBuffer[tid].empty()) return false; } @@ -413,11 +414,11 @@ DefaultDecode::updateStatus() { bool any_unblocking = false; - std::list::iterator threads = activeThreads->begin(); - std::list::iterator end = activeThreads->end(); + list::iterator threads = activeThreads->begin(); + list::iterator end = activeThreads->end(); while (threads != end) { - unsigned tid = *threads++; + ThreadID tid = *threads++; if (decodeStatus[tid] == Unblocking) { any_unblocking = true; @@ -452,8 +453,8 @@ DefaultDecode::sortInsts() { int insts_from_fetch = fromFetch->size; #ifdef DEBUG - for (int i=0; i < numThreads; i++) - assert(insts[i].empty()); + for (ThreadID tid = 0; tid < numThreads; tid++) + assert(insts[tid].empty()); #endif for (int i = 0; i < insts_from_fetch; ++i) { insts[fromFetch->insts[i]->threadNumber].push(fromFetch->insts[i]); @@ -462,7 +463,7 @@ DefaultDecode::sortInsts() template void -DefaultDecode::readStallSignals(unsigned tid) +DefaultDecode::readStallSignals(ThreadID tid) { if (fromRename->renameBlock[tid]) { stalls[tid].rename = true; @@ -494,7 +495,7 @@ DefaultDecode::readStallSignals(unsigned tid) template bool -DefaultDecode::checkSignalsAndUpdate(unsigned tid) +DefaultDecode::checkSignalsAndUpdate(ThreadID tid) { // Check if there's a squash signal, squash if there is. // Check stall signals, block if necessary. @@ -569,14 +570,14 @@ DefaultDecode::tick() toRenameIndex = 0; - std::list::iterator threads = activeThreads->begin(); - std::list::iterator end = activeThreads->end(); + list::iterator threads = activeThreads->begin(); + list::iterator end = activeThreads->end(); sortInsts(); //Check stall and squash signals. while (threads != end) { - unsigned tid = *threads++; + ThreadID tid = *threads++; DPRINTF(Decode,"Processing [tid:%i]\n",tid); status_change = checkSignalsAndUpdate(tid) || status_change; @@ -597,7 +598,7 @@ DefaultDecode::tick() template void -DefaultDecode::decode(bool &status_change, unsigned tid) +DefaultDecode::decode(bool &status_change, ThreadID tid) { // If status is Running or idle, // call decodeInsts() @@ -642,7 +643,7 @@ DefaultDecode::decode(bool &status_change, unsigned tid) template void -DefaultDecode::decodeInsts(unsigned tid) +DefaultDecode::decodeInsts(ThreadID tid) { // Instructions can come either from the skid buffer or the list of // instructions coming from fetch, depending on decode's status. -- cgit v1.2.3