Added LLVM copyright header (for lack of a better term).
[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 class TargetMachine;
20
21 struct TargetCacheInfo {
22   const TargetMachine ⌖
23   TargetCacheInfo(const TargetCacheInfo&); // DO NOT IMPLEMENT
24   void operator=(const TargetCacheInfo&);  // DO NOT IMPLEMENT
25 protected:
26   unsigned int           numLevels;
27   std::vector<unsigned short> cacheLineSizes;
28   std::vector<unsigned int>   cacheSizes;
29   std::vector<unsigned short> cacheAssoc;
30   
31 public:
32   TargetCacheInfo(const TargetMachine& tgt) : target(tgt) {
33     Initialize();
34   }
35   virtual ~TargetCacheInfo() {}
36   
37   // Default parameters are:
38   //    NumLevels    = 2
39   //    L1: LineSize 16, Cache Size 32KB, Direct-mapped (assoc = 1)
40   //    L2: LineSize 32, Cache Size 1 MB, 4-way associative
41   // NOTE: Cache levels are numbered from 1 as above, not from 0.
42   // 
43   virtual  void     Initialize          (); // subclass to override defaults
44   
45   unsigned int      getNumCacheLevels   () const {
46     return numLevels;
47   }
48   unsigned short    getCacheLineSize    (unsigned level)  const {
49     assert(level <= cacheLineSizes.size() && "Invalid cache level");
50     return cacheLineSizes[level-1];
51   }
52   unsigned int      getCacheSize        (unsigned level)  const {
53     assert(level <= cacheSizes.size() && "Invalid cache level");
54     return cacheSizes[level-1];
55   }
56   unsigned short    getCacheAssoc       (unsigned level)  const {
57     assert(level <= cacheAssoc.size() && "Invalid cache level");
58     return cacheAssoc[level];
59   }
60 };
61
62 #endif