blob: 2d0d330d8db38c4e0259ea7a3ee11ab6264ae4e3 [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 Lattner93fa7052002-10-28 23:55:33 +00004// This file also implements MachineCacheInfo.
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"
Vikram S. Adve4a48c332001-11-09 02:20:18 +00009#include "llvm/Target/MachineCacheInfo.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//
Vikram S. Adve0799fc42001-09-18 12:58:33 +000028unsigned int
29TargetMachine::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. Advedaae6992001-07-21 12:42:08 +000039
Vikram S. Adve0799fc42001-09-18 12:58:33 +000040 default:
41 return DataLayout.getTypeSize(ty);
42 }
Vikram S. Advedaae6992001-07-21 12:42:08 +000043}
44
Vikram S. Adve44a853c2001-07-28 04:09:37 +000045
46//---------------------------------------------------------------------------
Vikram S. Adve4a48c332001-11-09 02:20:18 +000047// class MachineCacheInfo
48//
49// Purpose:
50// Describes properties of the target cache architecture.
51//---------------------------------------------------------------------------
52
Chris Lattner93fa7052002-10-28 23:55:33 +000053void MachineCacheInfo::Initialize() {
Vikram S. Adve4a48c332001-11-09 02:20:18 +000054 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}