Seperate code out of TargetMachine into MachineInstrInfo
[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 MachineCacheInfo.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #include "llvm/Target/TargetMachine.h"
9 #include "llvm/Target/MachineCacheInfo.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 // Purpose:
24 //   This default implementation assumes that all sub-word data items use
25 //   space equal to optSizeForSubWordData, and all other primitive data
26 //   items use space according to the type.
27 //   
28 unsigned int
29 TargetMachine::findOptimalStorageSize(const Type* ty) const
30 {
31   switch(ty->getPrimitiveID())
32     {
33     case Type::BoolTyID:
34     case Type::UByteTyID:
35     case Type::SByteTyID:     
36     case Type::UShortTyID:
37     case Type::ShortTyID:     
38       return optSizeForSubWordData;
39     
40     default:
41       return DataLayout.getTypeSize(ty);
42     }
43 }
44
45
46 //---------------------------------------------------------------------------
47 // class MachineCacheInfo 
48 // 
49 // Purpose:
50 //   Describes properties of the target cache architecture.
51 //---------------------------------------------------------------------------
52
53 void MachineCacheInfo::Initialize() {
54   numLevels = 2;
55   cacheLineSizes.push_back(16);  cacheLineSizes.push_back(32); 
56   cacheSizes.push_back(1 << 15); cacheSizes.push_back(1 << 20);
57   cacheAssoc.push_back(1);       cacheAssoc.push_back(4);
58 }