Chris Lattner | b26bcc5 | 2001-09-14 05:34:53 +0000 | [diff] [blame] | 1 | //===-- TargetMachine.cpp - General Target Information ---------------------==// |
John Criswell | b576c94 | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 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 | //===----------------------------------------------------------------------===// |
Chris Lattner | b26bcc5 | 2001-09-14 05:34:53 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file describes the general parts of a Target machine. |
Chris Lattner | f27eeea | 2002-12-29 02:50:35 +0000 | [diff] [blame] | 11 | // This file also implements TargetCacheInfo. |
Chris Lattner | b26bcc5 | 2001-09-14 05:34:53 +0000 | [diff] [blame] | 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
Vikram S. Adve | daae699 | 2001-07-21 12:42:08 +0000 | [diff] [blame] | 14 | |
Vikram S. Adve | 4a48c33 | 2001-11-09 02:20:18 +0000 | [diff] [blame] | 15 | #include "llvm/Target/TargetMachine.h" |
Chris Lattner | f27eeea | 2002-12-29 02:50:35 +0000 | [diff] [blame] | 16 | #include "llvm/Target/TargetCacheInfo.h" |
Chris Lattner | 93fa705 | 2002-10-28 23:55:33 +0000 | [diff] [blame] | 17 | #include "llvm/Type.h" |
Chris Lattner | f70e0c2 | 2003-12-28 21:23:38 +0000 | [diff] [blame] | 18 | #include "llvm/IntrinsicLowering.h" |
| 19 | using namespace llvm; |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 20 | |
Vikram S. Adve | e1f7280 | 2002-09-16 15:39:26 +0000 | [diff] [blame] | 21 | //--------------------------------------------------------------------------- |
Chris Lattner | f70e0c2 | 2003-12-28 21:23:38 +0000 | [diff] [blame] | 22 | // TargetMachine Class |
| 23 | // |
| 24 | TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il, |
| 25 | bool LittleEndian, |
| 26 | unsigned char PtrSize, unsigned char PtrAl, |
| 27 | unsigned char DoubleAl, unsigned char FloatAl, |
| 28 | unsigned char LongAl, unsigned char IntAl, |
| 29 | unsigned char ShortAl, unsigned char ByteAl) |
| 30 | : Name(name), DataLayout(name, LittleEndian, |
| 31 | PtrSize, PtrAl, DoubleAl, FloatAl, LongAl, |
| 32 | IntAl, ShortAl, ByteAl) { |
| 33 | IL = il ? il : new DefaultIntrinsicLowering(); |
| 34 | } |
Vikram S. Adve | daae699 | 2001-07-21 12:42:08 +0000 | [diff] [blame] | 35 | |
Vikram S. Adve | 0799fc4 | 2001-09-18 12:58:33 +0000 | [diff] [blame] | 36 | |
Chris Lattner | f70e0c2 | 2003-12-28 21:23:38 +0000 | [diff] [blame] | 37 | |
| 38 | TargetMachine::~TargetMachine() { |
| 39 | delete IL; |
| 40 | } |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
Chris Lattner | 62eaf7e | 2002-10-29 21:47:50 +0000 | [diff] [blame] | 45 | unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const { |
Chris Lattner | 37ec811 | 2003-04-26 19:47:36 +0000 | [diff] [blame] | 46 | // All integer types smaller than ints promote to 4 byte integers. |
| 47 | if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4) |
| 48 | return 4; |
Chris Lattner | 62eaf7e | 2002-10-29 21:47:50 +0000 | [diff] [blame] | 49 | |
| 50 | return DataLayout.getTypeSize(Ty); |
Vikram S. Adve | daae699 | 2001-07-21 12:42:08 +0000 | [diff] [blame] | 51 | } |
| 52 | |
Vikram S. Adve | 44a853c | 2001-07-28 04:09:37 +0000 | [diff] [blame] | 53 | |
| 54 | //--------------------------------------------------------------------------- |
Chris Lattner | f70e0c2 | 2003-12-28 21:23:38 +0000 | [diff] [blame] | 55 | // TargetCacheInfo Class |
| 56 | // |
Vikram S. Adve | 4a48c33 | 2001-11-09 02:20:18 +0000 | [diff] [blame] | 57 | |
Chris Lattner | f27eeea | 2002-12-29 02:50:35 +0000 | [diff] [blame] | 58 | void TargetCacheInfo::Initialize() { |
Vikram S. Adve | 4a48c33 | 2001-11-09 02:20:18 +0000 | [diff] [blame] | 59 | numLevels = 2; |
| 60 | cacheLineSizes.push_back(16); cacheLineSizes.push_back(32); |
| 61 | cacheSizes.push_back(1 << 15); cacheSizes.push_back(1 << 20); |
| 62 | cacheAssoc.push_back(1); cacheAssoc.push_back(4); |
| 63 | } |