Added LLVM project notice to the top of every C++ source file.
[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 //---------------------------------------------------------------------------
20 // class TargetMachine
21 // 
22 // Purpose:
23 //   Machine description.
24 // 
25 //---------------------------------------------------------------------------
26
27
28 // function TargetMachine::findOptimalStorageSize 
29 // 
30 unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const {
31   // All integer types smaller than ints promote to 4 byte integers.
32   if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4)
33     return 4;
34
35   return DataLayout.getTypeSize(Ty);
36 }
37
38
39 //---------------------------------------------------------------------------
40 // class TargetCacheInfo 
41 // 
42 // Purpose:
43 //   Describes properties of the target cache architecture.
44 //---------------------------------------------------------------------------
45
46 void TargetCacheInfo::Initialize() {
47   numLevels = 2;
48   cacheLineSizes.push_back(16);  cacheLineSizes.push_back(32); 
49   cacheSizes.push_back(1 << 15); cacheSizes.push_back(1 << 20);
50   cacheAssoc.push_back(1);       cacheAssoc.push_back(4);
51 }