24788e3c4d9d153409cc92063ab408c36c154c0d
[oota-llvm.git] / lib / Target / TargetMachine.cpp
1 //===-- TargetMachine.cpp - General Target Information ---------------------==//
2 //
3 // This file describes the general parts of a Target machine.
4 // This file also implements TargetCacheInfo.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #include "llvm/Target/TargetMachine.h"
9 #include "llvm/Target/TargetCacheInfo.h"
10 #include "llvm/Type.h"
11
12 //---------------------------------------------------------------------------
13 // class TargetMachine
14 // 
15 // Purpose:
16 //   Machine description.
17 // 
18 //---------------------------------------------------------------------------
19
20
21 // function TargetMachine::findOptimalStorageSize 
22 // 
23 unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const {
24   // All integer types smaller than ints promote to 4 byte integers.
25   if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4)
26     return 4;
27
28   return DataLayout.getTypeSize(Ty);
29 }
30
31
32 //---------------------------------------------------------------------------
33 // class TargetCacheInfo 
34 // 
35 // Purpose:
36 //   Describes properties of the target cache architecture.
37 //---------------------------------------------------------------------------
38
39 void TargetCacheInfo::Initialize() {
40   numLevels = 2;
41   cacheLineSizes.push_back(16);  cacheLineSizes.push_back(32); 
42   cacheSizes.push_back(1 << 15); cacheSizes.push_back(1 << 20);
43   cacheAssoc.push_back(1);       cacheAssoc.push_back(4);
44 }