2002-12-29 02:50:35 +00:00
|
|
|
//===-- llvm/Target/TargetCacheInfo.h ---------------------------*- C++ -*-===//
|
2002-02-04 05:55:10 +00:00
|
|
|
//
|
|
|
|
// Describes properties of the target cache architecture.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-11-09 02:11:25 +00:00
|
|
|
|
2002-12-29 02:50:35 +00:00
|
|
|
#ifndef LLVM_TARGET_TARGETCACHEINFO_H
|
|
|
|
#define LLVM_TARGET_TARGETCACHEINFO_H
|
2001-11-09 02:11:25 +00:00
|
|
|
|
2001-11-26 23:04:08 +00:00
|
|
|
#include "Support/DataTypes.h"
|
2002-02-04 05:55:10 +00:00
|
|
|
class TargetMachine;
|
2001-11-09 02:11:25 +00:00
|
|
|
|
2002-12-29 02:50:35 +00:00
|
|
|
struct TargetCacheInfo : public NonCopyableV {
|
2002-02-04 05:55:10 +00:00
|
|
|
const TargetMachine ⌖
|
2001-11-09 02:11:25 +00:00
|
|
|
protected:
|
|
|
|
unsigned int numLevels;
|
2002-01-20 22:54:45 +00:00
|
|
|
std::vector<unsigned short> cacheLineSizes;
|
|
|
|
std::vector<unsigned int> cacheSizes;
|
|
|
|
std::vector<unsigned short> cacheAssoc;
|
2001-11-09 02:11:25 +00:00
|
|
|
|
|
|
|
public:
|
2002-12-29 02:50:35 +00:00
|
|
|
TargetCacheInfo(const TargetMachine& tgt) : target(tgt) {
|
2002-10-28 23:53:32 +00:00
|
|
|
Initialize();
|
|
|
|
}
|
2001-11-09 02:11:25 +00:00
|
|
|
|
|
|
|
// Default parameters are:
|
|
|
|
// NumLevels = 2
|
|
|
|
// L1: LineSize 16, Cache Size 32KB, Direct-mapped (assoc = 1)
|
|
|
|
// L2: LineSize 32, Cache Size 1 MB, 4-way associative
|
|
|
|
// NOTE: Cache levels are numbered from 1 as above, not from 0.
|
|
|
|
//
|
|
|
|
virtual void Initialize (); // subclass to override defaults
|
|
|
|
|
|
|
|
unsigned int getNumCacheLevels () const {
|
|
|
|
return numLevels;
|
|
|
|
}
|
|
|
|
unsigned short getCacheLineSize (unsigned level) const {
|
|
|
|
assert(level <= cacheLineSizes.size() && "Invalid cache level");
|
|
|
|
return cacheLineSizes[level-1];
|
|
|
|
}
|
|
|
|
unsigned int getCacheSize (unsigned level) const {
|
|
|
|
assert(level <= cacheSizes.size() && "Invalid cache level");
|
|
|
|
return cacheSizes[level-1];
|
|
|
|
}
|
|
|
|
unsigned short getCacheAssoc (unsigned level) const {
|
|
|
|
assert(level <= cacheAssoc.size() && "Invalid cache level");
|
|
|
|
return cacheAssoc[level];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|