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