Chris Lattner | b26bcc5 | 2001-09-14 05:34:53 +0000 | [diff] [blame] | 1 | //===-- TargetMachine.cpp - General Target Information ---------------------==// |
| 2 | // |
| 3 | // This file describes the general parts of a Target machine. |
Chris Lattner | 93fa705 | 2002-10-28 23:55:33 +0000 | [diff] [blame] | 4 | // This file also implements MachineCacheInfo. |
Chris Lattner | b26bcc5 | 2001-09-14 05:34:53 +0000 | [diff] [blame] | 5 | // |
| 6 | //===----------------------------------------------------------------------===// |
Vikram S. Adve | daae699 | 2001-07-21 12:42:08 +0000 | [diff] [blame] | 7 | |
Vikram S. Adve | 4a48c33 | 2001-11-09 02:20:18 +0000 | [diff] [blame] | 8 | #include "llvm/Target/TargetMachine.h" |
Vikram S. Adve | 4a48c33 | 2001-11-09 02:20:18 +0000 | [diff] [blame] | 9 | #include "llvm/Target/MachineCacheInfo.h" |
Chris Lattner | 93fa705 | 2002-10-28 23:55:33 +0000 | [diff] [blame] | 10 | #include "llvm/Type.h" |
Vikram S. Adve | e5b2565 | 2002-09-20 00:52:43 +0000 | [diff] [blame] | 11 | |
Vikram S. Adve | e1f7280 | 2002-09-16 15:39:26 +0000 | [diff] [blame] | 12 | //--------------------------------------------------------------------------- |
Vikram S. Adve | 44a853c | 2001-07-28 04:09:37 +0000 | [diff] [blame] | 13 | // class TargetMachine |
Vikram S. Adve | daae699 | 2001-07-21 12:42:08 +0000 | [diff] [blame] | 14 | // |
| 15 | // Purpose: |
Vikram S. Adve | 44a853c | 2001-07-28 04:09:37 +0000 | [diff] [blame] | 16 | // Machine description. |
| 17 | // |
Vikram S. Adve | daae699 | 2001-07-21 12:42:08 +0000 | [diff] [blame] | 18 | //--------------------------------------------------------------------------- |
| 19 | |
Vikram S. Adve | 0799fc4 | 2001-09-18 12:58:33 +0000 | [diff] [blame] | 20 | |
Vikram S. Adve | 44a853c | 2001-07-28 04:09:37 +0000 | [diff] [blame] | 21 | // function TargetMachine::findOptimalStorageSize |
| 22 | // |
| 23 | // Purpose: |
Vikram S. Adve | 44a853c | 2001-07-28 04:09:37 +0000 | [diff] [blame] | 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 | // |
Vikram S. Adve | 0799fc4 | 2001-09-18 12:58:33 +0000 | [diff] [blame] | 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; |
Vikram S. Adve | daae699 | 2001-07-21 12:42:08 +0000 | [diff] [blame] | 39 | |
Vikram S. Adve | 0799fc4 | 2001-09-18 12:58:33 +0000 | [diff] [blame] | 40 | default: |
| 41 | return DataLayout.getTypeSize(ty); |
| 42 | } |
Vikram S. Adve | daae699 | 2001-07-21 12:42:08 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Vikram S. Adve | 44a853c | 2001-07-28 04:09:37 +0000 | [diff] [blame] | 45 | |
| 46 | //--------------------------------------------------------------------------- |
Vikram S. Adve | 4a48c33 | 2001-11-09 02:20:18 +0000 | [diff] [blame] | 47 | // class MachineCacheInfo |
| 48 | // |
| 49 | // Purpose: |
| 50 | // Describes properties of the target cache architecture. |
| 51 | //--------------------------------------------------------------------------- |
| 52 | |
Chris Lattner | 93fa705 | 2002-10-28 23:55:33 +0000 | [diff] [blame] | 53 | void MachineCacheInfo::Initialize() { |
Vikram S. Adve | 4a48c33 | 2001-11-09 02:20:18 +0000 | [diff] [blame] | 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 | } |