blob: dc722fc7e5c72eeade9a21c46985708372ee23a8 [file] [log] [blame]
Chris Lattnerb26bcc52001-09-14 05:34:53 +00001//===-- TargetMachine.cpp - General Target Information ---------------------==//
2//
3// This file describes the general parts of a Target machine.
Chris Lattnerf27eeea2002-12-29 02:50:35 +00004// This file also implements TargetCacheInfo.
Chris Lattnerb26bcc52001-09-14 05:34:53 +00005//
6//===----------------------------------------------------------------------===//
Vikram S. Advedaae6992001-07-21 12:42:08 +00007
Vikram S. Adve4a48c332001-11-09 02:20:18 +00008#include "llvm/Target/TargetMachine.h"
Chris Lattnerf27eeea2002-12-29 02:50:35 +00009#include "llvm/Target/TargetCacheInfo.h"
Chris Lattner93fa7052002-10-28 23:55:33 +000010#include "llvm/Type.h"
Vikram S. Advee5b25652002-09-20 00:52:43 +000011
Vikram S. Advee1f72802002-09-16 15:39:26 +000012//---------------------------------------------------------------------------
Vikram S. Adve44a853c2001-07-28 04:09:37 +000013// class TargetMachine
Vikram S. Advedaae6992001-07-21 12:42:08 +000014//
15// Purpose:
Vikram S. Adve44a853c2001-07-28 04:09:37 +000016// Machine description.
17//
Vikram S. Advedaae6992001-07-21 12:42:08 +000018//---------------------------------------------------------------------------
19
Vikram S. Adve0799fc42001-09-18 12:58:33 +000020
Vikram S. Adve44a853c2001-07-28 04:09:37 +000021// function TargetMachine::findOptimalStorageSize
22//
23// Purpose:
Vikram S. Adve44a853c2001-07-28 04:09:37 +000024// 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//
Chris Lattner62eaf7e2002-10-29 21:47:50 +000028unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const {
29 // Round integral values smaller than SubWordDataSize up to SubWordDataSize
30 if (Ty->isIntegral() &&
31 Ty->getPrimitiveSize() < DataLayout.getSubWordDataSize())
32 return DataLayout.getSubWordDataSize();
33
34 return DataLayout.getTypeSize(Ty);
Vikram S. Advedaae6992001-07-21 12:42:08 +000035}
36
Vikram S. Adve44a853c2001-07-28 04:09:37 +000037
38//---------------------------------------------------------------------------
Chris Lattnerf27eeea2002-12-29 02:50:35 +000039// class TargetCacheInfo
Vikram S. Adve4a48c332001-11-09 02:20:18 +000040//
41// Purpose:
42// Describes properties of the target cache architecture.
43//---------------------------------------------------------------------------
44
Chris Lattnerf27eeea2002-12-29 02:50:35 +000045void TargetCacheInfo::Initialize() {
Vikram S. Adve4a48c332001-11-09 02:20:18 +000046 numLevels = 2;
47 cacheLineSizes.push_back(16); cacheLineSizes.push_back(32);
48 cacheSizes.push_back(1 << 15); cacheSizes.push_back(1 << 20);
49 cacheAssoc.push_back(1); cacheAssoc.push_back(4);
50}