summaryrefslogtreecommitdiff
path: root/src/mem/cache/tags
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2009-06-04 23:21:12 -0700
committerNathan Binkert <nate@binkert.org>2009-06-04 23:21:12 -0700
commit6faf377b5305f9dcc3c7b013c4d67f5accb92617 (patch)
tree0e437fb49a32dd3d2d2bec95a8dc3bdb4ddf05b0 /src/mem/cache/tags
parent4e3426624557b555c354035ee3961eab7554d81d (diff)
downloadgem5-6faf377b5305f9dcc3c7b013c4d67f5accb92617.tar.xz
types: clean up types, especially signed vs unsigned
Diffstat (limited to 'src/mem/cache/tags')
-rw-r--r--src/mem/cache/tags/fa_lru.cc16
-rw-r--r--src/mem/cache/tags/fa_lru.hh19
-rw-r--r--src/mem/cache/tags/iic.cc20
-rw-r--r--src/mem/cache/tags/iic.hh51
-rw-r--r--src/mem/cache/tags/lru.cc19
-rw-r--r--src/mem/cache/tags/lru.hh18
6 files changed, 75 insertions, 68 deletions
diff --git a/src/mem/cache/tags/fa_lru.cc b/src/mem/cache/tags/fa_lru.cc
index 0e0121f67..122e6e14b 100644
--- a/src/mem/cache/tags/fa_lru.cc
+++ b/src/mem/cache/tags/fa_lru.cc
@@ -42,7 +42,7 @@
using namespace std;
-FALRU::FALRU(int _blkSize, int _size, int hit_latency)
+FALRU::FALRU(unsigned _blkSize, unsigned _size, unsigned hit_latency)
: blkSize(_blkSize), size(_size),
numBlks(size/blkSize), hitLatency(hit_latency)
{
@@ -78,10 +78,10 @@ FALRU::FALRU(int _blkSize, int _size, int hit_latency)
tail->next = NULL;
tail->inCache = 0;
- int index = (1 << 17) / blkSize;
- int j = 0;
+ unsigned index = (1 << 17) / blkSize;
+ unsigned j = 0;
int flags = cacheMask;
- for (int i = 1; i < numBlks-1; i++) {
+ for (unsigned i = 1; i < numBlks - 1; i++) {
blks[i].inCache = flags;
if (i == index - 1){
cacheBoundaries[j] = &(blks[i]);
@@ -118,7 +118,7 @@ FALRU::regStats(const string &name)
.desc("The number of accesses to the FA LRU cache.")
;
- for (int i = 0; i < numCaches+1; ++i) {
+ for (unsigned i = 0; i <= numCaches; ++i) {
stringstream size_str;
if (i < 3){
size_str << (1<<(i+7)) <<"K";
@@ -164,7 +164,7 @@ FALRU::accessBlock(Addr addr, int &lat, int *inCache)
if (blk && blk->isValid()) {
assert(blk->tag == blkAddr);
tmp_in_cache = blk->inCache;
- for (int i = 0; i < numCaches; i++) {
+ for (unsigned i = 0; i < numCaches; i++) {
if (1<<i & blk->inCache) {
hits[i]++;
} else {
@@ -177,7 +177,7 @@ FALRU::accessBlock(Addr addr, int &lat, int *inCache)
}
} else {
blk = NULL;
- for (int i = 0; i < numCaches+1; ++i) {
+ for (unsigned i = 0; i <= numCaches; ++i) {
misses[i]++;
}
}
@@ -236,7 +236,7 @@ void
FALRU::moveToHead(FALRUBlk *blk)
{
int updateMask = blk->inCache ^ cacheMask;
- for (int i = 0; i < numCaches; i++){
+ for (unsigned i = 0; i < numCaches; i++){
if ((1<<i) & updateMask) {
cacheBoundaries[i]->inCache &= ~(1<<i);
cacheBoundaries[i] = cacheBoundaries[i]->prev;
diff --git a/src/mem/cache/tags/fa_lru.hh b/src/mem/cache/tags/fa_lru.hh
index 23d09d709..4e6bccc1d 100644
--- a/src/mem/cache/tags/fa_lru.hh
+++ b/src/mem/cache/tags/fa_lru.hh
@@ -78,22 +78,23 @@ class FALRU : public BaseTags
typedef FALRUBlk BlkType;
/** Typedef a list of pointers to the local block type. */
typedef std::list<FALRUBlk*> BlkList;
+
protected:
/** The block size of the cache. */
- const int blkSize;
+ const unsigned blkSize;
/** The size of the cache. */
- const int size;
+ const unsigned size;
/** The number of blocks in the cache. */
- const int numBlks; // calculated internally
+ const unsigned numBlks; // calculated internally
/** The hit latency of the cache. */
- const int hitLatency;
+ const unsigned hitLatency;
/** Array of pointers to blocks at the cache size boundaries. */
FALRUBlk **cacheBoundaries;
/** A mask for the FALRUBlk::inCache bits. */
int cacheMask;
/** The number of different size caches being tracked. */
- int numCaches;
+ unsigned numCaches;
/** The cache blocks. */
FALRUBlk *blks;
@@ -156,7 +157,7 @@ public:
* @param size The size of the cache.
* @param hit_latency The hit latency of the cache.
*/
- FALRU(int blkSize, int size, int hit_latency);
+ FALRU(unsigned blkSize, unsigned size, unsigned hit_latency);
/**
* Register the stats for this object.
@@ -214,7 +215,8 @@ public:
* Return the block size of this cache.
* @return The block size.
*/
- int getBlockSize()
+ unsigned
+ getBlockSize() const
{
return blkSize;
}
@@ -223,7 +225,8 @@ public:
* Return the subblock size of this cache, always the block size.
* @return The block size.
*/
- int getSubBlockSize()
+ unsigned
+ getSubBlockSize() const
{
return blkSize;
}
diff --git a/src/mem/cache/tags/iic.cc b/src/mem/cache/tags/iic.cc
index 7bc2543c5..b9ba5256b 100644
--- a/src/mem/cache/tags/iic.cc
+++ b/src/mem/cache/tags/iic.cc
@@ -66,8 +66,6 @@ IIC::IIC(IIC::Params &params) :
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");
@@ -104,10 +102,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 +116,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 +140,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);
@@ -305,7 +303,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 +311,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]]++;
}
@@ -636,7 +634,7 @@ IIC::invalidateBlk(IIC::BlkType *tag_ptr)
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;
diff --git a/src/mem/cache/tags/iic.hh b/src/mem/cache/tags/iic.hh
index 45c8ee801..994f7b8f7 100644
--- a/src/mem/cache/tags/iic.hh
+++ b/src/mem/cache/tags/iic.hh
@@ -167,46 +167,47 @@ class IIC : public BaseTags
typedef IICTag BlkType;
/** Typedef for list of pointers to the local block type. */
typedef std::list<IICTag*> BlkList;
+
protected:
/** The number of set in the primary table. */
- const int hashSets;
+ const unsigned hashSets;
/** The block size in bytes. */
- const int blkSize;
+ const unsigned blkSize;
/** The associativity of the primary table. */
- const int assoc;
+ const unsigned assoc;
/** The base hit latency. */
- const int hitLatency;
+ const unsigned hitLatency;
/** The subblock size, used for compression. */
- const int subSize;
+ const unsigned subSize;
/** The number of subblocks */
- const int numSub;
+ const unsigned numSub;
/** The number of bytes used by data pointers */
- const int trivialSize;
+ const unsigned trivialSize;
/** The amount to shift address to get the tag. */
- const int tagShift;
+ const unsigned tagShift;
/** The mask to get block offset bits. */
const unsigned blkMask;
/** The amount to shift to get the subblock number. */
- const int subShift;
+ const unsigned subShift;
/** The mask to get the correct subblock number. */
const unsigned subMask;
/** The latency of a hash lookup. */
- const int hashDelay;
+ const unsigned hashDelay;
/** The number of data blocks. */
- const int numBlocks;
+ const unsigned numBlocks;
/** The total number of tags in primary and secondary. */
- const int numTags;
+ const unsigned numTags;
/** The number of tags in the secondary tag store. */
- const int numSecondary;
+ const unsigned numSecondary;
/** The Null tag pointer. */
- const int tagNull;
+ const unsigned tagNull;
/** The last tag in the primary table. */
- const int primaryBound;
+ const unsigned primaryBound;
/** All of the tags */
IICTag *tagStore;
@@ -271,21 +272,21 @@ class IIC : public BaseTags
class Params {
public:
/** The size in bytes of the cache. */
- int size;
+ unsigned size;
/** The number of sets in the primary table. */
- int numSets;
+ unsigned numSets;
/** The block size in bytes. */
- int blkSize;
+ unsigned blkSize;
/** The associativity of the primary table. */
- int assoc;
+ unsigned assoc;
/** The number of cycles for each hash lookup. */
- int hashDelay;
+ unsigned hashDelay;
/** The number of cycles to read the data. */
- int hitLatency;
+ unsigned hitLatency;
/** The replacement policy. */
Repl *rp;
/** The subblock size in bytes. */
- int subblockSize;
+ unsigned subblockSize;
};
/**
@@ -322,7 +323,8 @@ class IIC : public BaseTags
* Return the block size.
* @return The block size.
*/
- int getBlockSize()
+ unsigned
+ getBlockSize() const
{
return blkSize;
}
@@ -331,7 +333,8 @@ class IIC : public BaseTags
* Return the subblock size.
* @return The subblock size.
*/
- int getSubBlockSize()
+ unsigned
+ getSubBlockSize() const
{
return subSize;
}
diff --git a/src/mem/cache/tags/lru.cc b/src/mem/cache/tags/lru.cc
index ff353ff6a..9371f193a 100644
--- a/src/mem/cache/tags/lru.cc
+++ b/src/mem/cache/tags/lru.cc
@@ -80,8 +80,10 @@ CacheSet::moveToHead(LRUBlk *blk)
// create and initialize a LRU/MRU cache structure
-LRU::LRU(int _numSets, int _blkSize, int _assoc, int _hit_latency) :
- numSets(_numSets), blkSize(_blkSize), assoc(_assoc), hitLatency(_hit_latency)
+LRU::LRU(unsigned _numSets, unsigned _blkSize, unsigned _assoc,
+ unsigned _hit_latency)
+ : numSets(_numSets), blkSize(_blkSize), assoc(_assoc),
+ hitLatency(_hit_latency)
{
// Check parameters
if (blkSize < 4 || !isPowerOf2(blkSize)) {
@@ -97,9 +99,6 @@ LRU::LRU(int _numSets, int _blkSize, int _assoc, int _hit_latency) :
fatal("access latency must be greater than zero");
}
- LRUBlk *blk;
- int i, j, blkIndex;
-
blkMask = blkSize - 1;
setShift = floorLog2(blkSize);
setMask = numSets - 1;
@@ -113,16 +112,16 @@ LRU::LRU(int _numSets, int _blkSize, int _assoc, int _hit_latency) :
// allocate data storage in one big chunk
dataBlks = new uint8_t[numSets*assoc*blkSize];
- blkIndex = 0; // index into blks array
- for (i = 0; i < numSets; ++i) {
+ unsigned blkIndex = 0; // index into blks array
+ for (unsigned i = 0; i < numSets; ++i) {
sets[i].assoc = assoc;
sets[i].blks = new LRUBlk*[assoc];
// link in the data blocks
- for (j = 0; j < assoc; ++j) {
+ for (unsigned j = 0; j < assoc; ++j) {
// locate next cache block
- blk = &blks[blkIndex];
+ LRUBlk *blk = &blks[blkIndex];
blk->data = &dataBlks[blkSize*blkIndex];
++blkIndex;
@@ -233,7 +232,7 @@ LRU::invalidateBlk(LRU::BlkType *blk)
void
LRU::cleanupRefs()
{
- for (int i = 0; i < numSets*assoc; ++i) {
+ for (unsigned i = 0; i < numSets*assoc; ++i) {
if (blks[i].isValid()) {
totalRefs += blks[i].refCount;
++sampledRefs;
diff --git a/src/mem/cache/tags/lru.hh b/src/mem/cache/tags/lru.hh
index 466095ec9..2874d8f1f 100644
--- a/src/mem/cache/tags/lru.hh
+++ b/src/mem/cache/tags/lru.hh
@@ -92,15 +92,16 @@ class LRU : public BaseTags
typedef LRUBlk BlkType;
/** Typedef for a list of pointers to the local block class. */
typedef std::list<LRUBlk*> BlkList;
+
protected:
/** The number of sets in the cache. */
- const int numSets;
+ const unsigned numSets;
/** The number of bytes in a block. */
- const int blkSize;
+ const unsigned blkSize;
/** The associativity of the cache. */
- const int assoc;
+ const unsigned assoc;
/** The hit latency. */
- const int hitLatency;
+ const unsigned hitLatency;
/** The cache sets. */
CacheSet *sets;
@@ -127,7 +128,8 @@ public:
* @param _assoc The associativity of the cache.
* @param _hit_latency The latency in cycles for a hit.
*/
- LRU(int _numSets, int _blkSize, int _assoc, int _hit_latency);
+ LRU(unsigned _numSets, unsigned _blkSize, unsigned _assoc,
+ unsigned _hit_latency);
/**
* Destructor
@@ -138,7 +140,8 @@ public:
* Return the block size.
* @return the block size.
*/
- int getBlockSize()
+ unsigned
+ getBlockSize() const
{
return blkSize;
}
@@ -148,7 +151,8 @@ public:
* size.
* @return The block size.
*/
- int getSubBlockSize()
+ unsigned
+ getSubBlockSize() const
{
return blkSize;
}