style
[gem5.git] / src / cpu / o3 / lsq_impl.hh
index 317e23b140d8610d59cacb44aac03c3cdc8bda00..fb738f7c9f64a8d6d93ba5fdba4ab9f8d9c7a205 100644 (file)
@@ -46,16 +46,20 @@ template <class Impl>
 void
 LSQ<Impl>::DcachePort::recvFunctional(PacketPtr pkt)
 {
-    warn("O3CPU doesn't update things on a recvFunctional.");
+    DPRINTF(LSQ, "LSQ doesn't update things on a recvFunctional.");
 }
 
 template <class Impl>
 void
 LSQ<Impl>::DcachePort::recvStatusChange(Status status)
 {
-    if (status == RangeChange)
+    if (status == RangeChange) {
+        if (!snoopRangeSent) {
+            snoopRangeSent = true;
+            sendStatusChange(Port::RangeChange);
+        }
         return;
-
+    }
     panic("O3CPU doesn't expect recvStatusChange callback!");
 }
 
@@ -97,6 +101,8 @@ LSQ<Impl>::LSQ(Params *params)
 {
     DPRINTF(LSQ, "Creating LSQ object.\n");
 
+    dcachePort.snoopRangeSent = false;
+
     //**********************************************/
     //************ Handle SMT Parameters ***********/
     //**********************************************/
@@ -238,10 +244,7 @@ void
 LSQ<Impl>::resetEntries()
 {
     if (lsqPolicy != Dynamic || numThreads > 1) {
-        int active_threads = (*activeThreads).size();
-
-        std::list<unsigned>::iterator threads  = (*activeThreads).begin();
-        std::list<unsigned>::iterator list_end = (*activeThreads).end();
+        int active_threads = activeThreads->size();
 
         int maxEntries;
 
@@ -253,8 +256,13 @@ LSQ<Impl>::resetEntries()
             maxEntries = LQEntries;
         }
 
-        while (threads != list_end) {
-            resizeEntries(maxEntries,*threads++);
+        std::list<unsigned>::iterator threads  = activeThreads->begin();
+        std::list<unsigned>::iterator end = activeThreads->end();
+
+        while (threads != end) {
+            unsigned tid = *threads++;
+
+            resizeEntries(maxEntries, tid);
         }
     }
 }
@@ -279,10 +287,11 @@ template<class Impl>
 void
 LSQ<Impl>::tick()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
+    while (threads != end) {
+        unsigned tid = *threads++;
 
         thread[tid].tick();
     }
@@ -328,10 +337,11 @@ template<class Impl>
 void
 LSQ<Impl>::writebackStores()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
+    while (threads != end) {
+        unsigned tid = *threads++;
 
         if (numStoresToWB(tid) > 0) {
             DPRINTF(Writeback,"[tid:%i] Writing back stores. %i stores "
@@ -347,10 +357,12 @@ bool
 LSQ<Impl>::violation()
 {
     /* Answers: Does Anybody Have a Violation?*/
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         if (thread[tid].violation())
             return true;
     }
@@ -364,10 +376,12 @@ LSQ<Impl>::getCount()
 {
     unsigned total = 0;
 
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         total += getCount(tid);
     }
 
@@ -380,10 +394,12 @@ LSQ<Impl>::numLoads()
 {
     unsigned total = 0;
 
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         total += numLoads(tid);
     }
 
@@ -396,10 +412,12 @@ LSQ<Impl>::numStores()
 {
     unsigned total = 0;
 
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         total += thread[tid].numStores();
     }
 
@@ -412,10 +430,12 @@ LSQ<Impl>::numLoadsReady()
 {
     unsigned total = 0;
 
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         total += thread[tid].numLoadsReady();
     }
 
@@ -428,10 +448,12 @@ LSQ<Impl>::numFreeEntries()
 {
     unsigned total = 0;
 
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         total += thread[tid].numFreeEntries();
     }
 
@@ -442,7 +464,7 @@ template<class Impl>
 unsigned
 LSQ<Impl>::numFreeEntries(unsigned tid)
 {
-    //if( lsqPolicy == Dynamic )
+    //if (lsqPolicy == Dynamic)
     //return numFreeEntries();
     //else
         return thread[tid].numFreeEntries();
@@ -452,11 +474,13 @@ template<class Impl>
 bool
 LSQ<Impl>::isFull()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
-        if (! (thread[tid].lqFull() || thread[tid].sqFull()) )
+    while (threads != end) {
+        unsigned tid = *threads++;
+
+        if (!(thread[tid].lqFull() || thread[tid].sqFull()))
             return false;
     }
 
@@ -469,7 +493,7 @@ LSQ<Impl>::isFull(unsigned tid)
 {
     //@todo: Change to Calculate All Entries for
     //Dynamic Policy
-    if( lsqPolicy == Dynamic )
+    if (lsqPolicy == Dynamic)
         return isFull();
     else
         return thread[tid].lqFull() || thread[tid].sqFull();
@@ -479,10 +503,12 @@ template<class Impl>
 bool
 LSQ<Impl>::lqFull()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         if (!thread[tid].lqFull())
             return false;
     }
@@ -496,7 +522,7 @@ LSQ<Impl>::lqFull(unsigned tid)
 {
     //@todo: Change to Calculate All Entries for
     //Dynamic Policy
-    if( lsqPolicy == Dynamic )
+    if (lsqPolicy == Dynamic)
         return lqFull();
     else
         return thread[tid].lqFull();
@@ -506,10 +532,12 @@ template<class Impl>
 bool
 LSQ<Impl>::sqFull()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         if (!sqFull(tid))
             return false;
     }
@@ -523,7 +551,7 @@ LSQ<Impl>::sqFull(unsigned tid)
 {
      //@todo: Change to Calculate All Entries for
     //Dynamic Policy
-    if( lsqPolicy == Dynamic )
+    if (lsqPolicy == Dynamic)
         return sqFull();
     else
         return thread[tid].sqFull();
@@ -533,10 +561,12 @@ template<class Impl>
 bool
 LSQ<Impl>::isStalled()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         if (!thread[tid].isStalled())
             return false;
     }
@@ -548,7 +578,7 @@ template<class Impl>
 bool
 LSQ<Impl>::isStalled(unsigned tid)
 {
-    if( lsqPolicy == Dynamic )
+    if (lsqPolicy == Dynamic)
         return isStalled();
     else
         return thread[tid].isStalled();
@@ -558,13 +588,15 @@ template<class Impl>
 bool
 LSQ<Impl>::hasStoresToWB()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    if ((*activeThreads).empty())
+    if (threads == end)
         return false;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
+    while (threads != end) {
+        unsigned tid = *threads++;
+
         if (!hasStoresToWB(tid))
             return false;
     }
@@ -576,10 +608,12 @@ template<class Impl>
 bool
 LSQ<Impl>::willWB()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         if (!willWB(tid))
             return false;
     }
@@ -591,10 +625,12 @@ template<class Impl>
 void
 LSQ<Impl>::dumpInsts()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         thread[tid].dumpInsts();
     }
 }