Fixed minor typos.
[oota-llvm.git] / include / llvm / Target / TargetCacheInfo.h
1 //===-- llvm/Target/TargetCacheInfo.h ---------------------------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 //  Describes properties of the target cache architecture.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TARGET_TARGETCACHEINFO_H
15 #define LLVM_TARGET_TARGETCACHEINFO_H
16
17 #include "Support/DataTypes.h"
18
19 namespace llvm {
20
21 class TargetMachine;
22
23 struct TargetCacheInfo {
24   const TargetMachine ⌖
25   TargetCacheInfo(const TargetCacheInfo&); // DO NOT IMPLEMENT
26   void operator=(const TargetCacheInfo&);  // DO NOT IMPLEMENT
27 protected:
28   unsigned int           numLevels;
29   std::vector<unsigned short> cacheLineSizes;
30   std::vector<unsigned int>   cacheSizes;
31   std::vector<unsigned short> cacheAssoc;
32   
33 public:
34   TargetCacheInfo(const TargetMachine& tgt) : target(tgt) {
35     Initialize();
36   }
37   virtual ~TargetCacheInfo() {}
38   
39   // Default parameters are:
40   //    NumLevels    = 2
41   //    L1: LineSize 16, Cache Size 32KB, Direct-mapped (assoc = 1)
42   //    L2: LineSize 32, Cache Size 1 MB, 4-way associative
43   // NOTE: Cache levels are numbered from 1 as above, not from 0.
44   // 
45   virtual  void     Initialize          (); // subclass to override defaults
46   
47   unsigned int      getNumCacheLevels   () const {
48     return numLevels;
49   }
50   unsigned short    getCacheLineSize    (unsigned level)  const {
51     assert(level <= cacheLineSizes.size() && "Invalid cache level");
52     return cacheLineSizes[level-1];
53   }
54   unsigned int      getCacheSize        (unsigned level)  const {
55     assert(level <= cacheSizes.size() && "Invalid cache level");
56     return cacheSizes[level-1];
57   }
58   unsigned short    getCacheAssoc       (unsigned level)  const {
59     assert(level <= cacheAssoc.size() && "Invalid cache level");
60     return cacheAssoc[level];
61   }
62 };
63
64 } // End llvm namespace
65
66 #endif