blob: b7c1b342e1263c1c3f5f8d5073279dba5c6a607c [file] [log] [blame]
Chris Lattnerb26bcc52001-09-14 05:34:53 +00001//===-- TargetMachine.cpp - General Target Information ---------------------==//
John Criswellb576c942003-10-20 19:43:21 +00002//
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 Lattnerb26bcc52001-09-14 05:34:53 +00009//
10// This file describes the general parts of a Target machine.
Chris Lattnerf27eeea2002-12-29 02:50:35 +000011// This file also implements TargetCacheInfo.
Chris Lattnerb26bcc52001-09-14 05:34:53 +000012//
13//===----------------------------------------------------------------------===//
Vikram S. Advedaae6992001-07-21 12:42:08 +000014
Vikram S. Adve4a48c332001-11-09 02:20:18 +000015#include "llvm/Target/TargetMachine.h"
Chris Lattnerf27eeea2002-12-29 02:50:35 +000016#include "llvm/Target/TargetCacheInfo.h"
Chris Lattner93fa7052002-10-28 23:55:33 +000017#include "llvm/Type.h"
Vikram S. Advee5b25652002-09-20 00:52:43 +000018
Vikram S. Advee1f72802002-09-16 15:39:26 +000019//---------------------------------------------------------------------------
Vikram S. Adve44a853c2001-07-28 04:09:37 +000020// class TargetMachine
Vikram S. Advedaae6992001-07-21 12:42:08 +000021//
22// Purpose:
Vikram S. Adve44a853c2001-07-28 04:09:37 +000023// Machine description.
24//
Vikram S. Advedaae6992001-07-21 12:42:08 +000025//---------------------------------------------------------------------------
26
Vikram S. Adve0799fc42001-09-18 12:58:33 +000027
Vikram S. Adve44a853c2001-07-28 04:09:37 +000028// function TargetMachine::findOptimalStorageSize
29//
Chris Lattner62eaf7e2002-10-29 21:47:50 +000030unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const {
Chris Lattner37ec8112003-04-26 19:47:36 +000031 // All integer types smaller than ints promote to 4 byte integers.
32 if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4)
33 return 4;
Chris Lattner62eaf7e2002-10-29 21:47:50 +000034
35 return DataLayout.getTypeSize(Ty);
Vikram S. Advedaae6992001-07-21 12:42:08 +000036}
37
Vikram S. Adve44a853c2001-07-28 04:09:37 +000038
39//---------------------------------------------------------------------------
Chris Lattnerf27eeea2002-12-29 02:50:35 +000040// class TargetCacheInfo
Vikram S. Adve4a48c332001-11-09 02:20:18 +000041//
42// Purpose:
43// Describes properties of the target cache architecture.
44//---------------------------------------------------------------------------
45
Chris Lattnerf27eeea2002-12-29 02:50:35 +000046void TargetCacheInfo::Initialize() {
Vikram S. Adve4a48c332001-11-09 02:20:18 +000047 numLevels = 2;
48 cacheLineSizes.push_back(16); cacheLineSizes.push_back(32);
49 cacheSizes.push_back(1 << 15); cacheSizes.push_back(1 << 20);
50 cacheAssoc.push_back(1); cacheAssoc.push_back(4);
51}