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" |
Vikram S. Adve | e5b2565 | 2002-09-20 00:52:43 +0000 | [diff] [blame] | 18 | |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 19 | namespace llvm { |
| 20 | |
Vikram S. Adve | e1f7280 | 2002-09-16 15:39:26 +0000 | [diff] [blame] | 21 | //--------------------------------------------------------------------------- |
Vikram S. Adve | 44a853c | 2001-07-28 04:09:37 +0000 | [diff] [blame] | 22 | // class TargetMachine |
Vikram S. Adve | daae699 | 2001-07-21 12:42:08 +0000 | [diff] [blame] | 23 | // |
| 24 | // Purpose: |
Vikram S. Adve | 44a853c | 2001-07-28 04:09:37 +0000 | [diff] [blame] | 25 | // Machine description. |
| 26 | // |
Vikram S. Adve | daae699 | 2001-07-21 12:42:08 +0000 | [diff] [blame] | 27 | //--------------------------------------------------------------------------- |
| 28 | |
Vikram S. Adve | 0799fc4 | 2001-09-18 12:58:33 +0000 | [diff] [blame] | 29 | |
Vikram S. Adve | 44a853c | 2001-07-28 04:09:37 +0000 | [diff] [blame] | 30 | // function TargetMachine::findOptimalStorageSize |
| 31 | // |
Chris Lattner | 62eaf7e | 2002-10-29 21:47:50 +0000 | [diff] [blame] | 32 | unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const { |
Chris Lattner | 37ec811 | 2003-04-26 19:47:36 +0000 | [diff] [blame] | 33 | // All integer types smaller than ints promote to 4 byte integers. |
| 34 | if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4) |
| 35 | return 4; |
Chris Lattner | 62eaf7e | 2002-10-29 21:47:50 +0000 | [diff] [blame] | 36 | |
| 37 | return DataLayout.getTypeSize(Ty); |
Vikram S. Adve | daae699 | 2001-07-21 12:42:08 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Vikram S. Adve | 44a853c | 2001-07-28 04:09:37 +0000 | [diff] [blame] | 40 | |
| 41 | //--------------------------------------------------------------------------- |
Chris Lattner | f27eeea | 2002-12-29 02:50:35 +0000 | [diff] [blame] | 42 | // class TargetCacheInfo |
Vikram S. Adve | 4a48c33 | 2001-11-09 02:20:18 +0000 | [diff] [blame] | 43 | // |
| 44 | // Purpose: |
| 45 | // Describes properties of the target cache architecture. |
| 46 | //--------------------------------------------------------------------------- |
| 47 | |
Chris Lattner | f27eeea | 2002-12-29 02:50:35 +0000 | [diff] [blame] | 48 | void TargetCacheInfo::Initialize() { |
Vikram S. Adve | 4a48c33 | 2001-11-09 02:20:18 +0000 | [diff] [blame] | 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 | } |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 54 | |
| 55 | } // End llvm namespace |