SCons: Support building without an ISA
[gem5.git] / src / mem / cache / tags / iic.cc
index 7bc2543c539fda575835e682a3d76ebe29b541e3..1315a17eebdb3ec20aafee8e85e78a259670ef04 100644 (file)
  */
 
 #include <algorithm>
+#include <cmath>
 #include <string>
 #include <vector>
 
-#include <math.h>
-
+#include "base/intmath.hh"
+#include "base/trace.hh"
 #include "mem/cache/base.hh"
 #include "mem/cache/tags/iic.hh"
-#include "base/intmath.hh"
-#include "sim/core.hh" // for curTick
-
-#include "base/trace.hh" // for DPRINTF
-
+#include "sim/core.hh"
 
 using namespace std;
 
@@ -60,14 +57,11 @@ IIC::IIC(IIC::Params &params) :
     tagShift(floorLog2(blkSize)), blkMask(blkSize - 1),
     subShift(floorLog2(subSize)), subMask(numSub - 1),
     hashDelay(params.hashDelay),
-    numBlocks(params.size/subSize),
     numTags(hashSets * assoc + params.size/blkSize -1),
     numSecondary(params.size/blkSize),
     tagNull(numTags),
     primaryBound(hashSets * assoc)
 {
-    int i;
-
     // Check parameters
     if (blkSize < 4 || !isPowerOf2(blkSize)) {
         fatal("Block size must be at least 4 and a power of 2");
@@ -90,6 +84,7 @@ IIC::IIC(IIC::Params &params) :
 
     warmedUp = false;
     warmupBound = params.size/blkSize;
+    numBlocks = params.size/subSize;
 
     // Replacement Policy Initialization
     repl = params.rp;
@@ -104,10 +99,10 @@ IIC::IIC(IIC::Params &params) :
     // Allocate storage for both internal data and block fast access data.
     // We allocate it as one large chunk to reduce overhead and to make
     // deletion easier.
-    int data_index = 0;
+    unsigned data_index = 0;
     dataStore = new uint8_t[(numBlocks + numTags) * blkSize];
     dataBlks = new uint8_t*[numBlocks];
-    for (i = 0; i < numBlocks; ++i) {
+    for (unsigned i = 0; i < numBlocks; ++i) {
         dataBlks[i] = &dataStore[data_index];
         freeDataBlock(i);
         data_index += subSize;
@@ -118,15 +113,15 @@ IIC::IIC(IIC::Params &params) :
     // allocate and init tag store
     tagStore = new IICTag[numTags];
 
-    int blkIndex = 0;
+    unsigned blkIndex = 0;
     // allocate and init sets
     sets = new IICSet[hashSets];
-    for (i = 0; i < hashSets; ++i) {
+    for (unsigned i = 0; i < hashSets; ++i) {
         sets[i].assoc = assoc;
         sets[i].tags = new IICTag*[assoc];
         sets[i].chain_ptr = tagNull;
 
-        for (int j = 0; j < assoc; ++j) {
+        for (unsigned j = 0; j < assoc; ++j) {
             IICTag *tag = &tagStore[blkIndex++];
             tag->chain_ptr = tagNull;
             tag->data_ptr.resize(numSub);
@@ -142,7 +137,7 @@ IIC::IIC(IIC::Params &params) :
 
     assert(blkIndex == primaryBound);
 
-    for (i = primaryBound; i < tagNull; i++) {
+    for (unsigned i = primaryBound; i < tagNull; i++) {
         tagStore[i].chain_ptr = i+1;
         //setup data ptrs to subblocks
         tagStore[i].data_ptr.resize(numSub);
@@ -221,7 +216,7 @@ IIC::regStats(const string &name)
 
 
 IICTag*
-IIC::accessBlock(Addr addr, int &lat)
+IIC::accessBlock(Addr addr, int &lat, int context_src)
 {
     Addr tag = extractTag(addr);
     unsigned set = hash(addr);
@@ -305,7 +300,7 @@ IIC::findVictim(Addr addr, PacketList &writebacks)
     unsigned long *tmp_data = new unsigned long[numSub];
 
     // Get a enough subblocks for a full cache line
-    for (int i = 0; i < numSub; ++i){
+    for (unsigned i = 0; i < numSub; ++i){
         tmp_data[i] = getFreeDataBlock(writebacks);
         assert(dataReferenceCount[tmp_data[i]]==0);
     }
@@ -313,7 +308,7 @@ IIC::findVictim(Addr addr, PacketList &writebacks)
     tag_ptr = getFreeTag(set, writebacks);
 
     tag_ptr->set = set;
-    for (int i=0; i< numSub; ++i) {
+    for (unsigned i = 0; i < numSub; ++i) {
         tag_ptr->data_ptr[i] = tmp_data[i];
         dataReferenceCount[tag_ptr->data_ptr[i]]++;
     }
@@ -340,7 +335,7 @@ IIC::findVictim(Addr addr, PacketList &writebacks)
 }
 
 void
-IIC::insertBlock(Addr addr, BlkType* blk)
+IIC::insertBlock(Addr addr, BlkType* blk, int context_src)
 {
 }
 
@@ -633,10 +628,18 @@ IIC::invalidateBlk(IIC::BlkType *tag_ptr)
     }
 }
 
+void
+IIC::clearLocks()
+{
+    for (int i = 0; i < numTags; i++){
+        tagStore[i].clearLoadLocks();
+    }
+}
+
 void
 IIC::cleanupRefs()
 {
-    for (int i = 0; i < numTags; ++i) {
+    for (unsigned i = 0; i < numTags; ++i) {
         if (tagStore[i].isValid()) {
             totalRefs += tagStore[i].refCount;
             ++sampledRefs;