blob: e7630b4ab34660320601ba92ad2a373c8f397730 [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
Brian Gaeked0fde302003-11-11 22:41:34 +000019namespace llvm {
20
Vikram S. Advee1f72802002-09-16 15:39:26 +000021//---------------------------------------------------------------------------
Vikram S. Adve44a853c2001-07-28 04:09:37 +000022// class TargetMachine
Vikram S. Advedaae6992001-07-21 12:42:08 +000023//
24// Purpose:
Vikram S. Adve44a853c2001-07-28 04:09:37 +000025// Machine description.
26//
Vikram S. Advedaae6992001-07-21 12:42:08 +000027//---------------------------------------------------------------------------
28
Vikram S. Adve0799fc42001-09-18 12:58:33 +000029
Vikram S. Adve44a853c2001-07-28 04:09:37 +000030// function TargetMachine::findOptimalStorageSize
31//
Chris Lattner62eaf7e2002-10-29 21:47:50 +000032unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const {
Chris Lattner37ec8112003-04-26 19:47:36 +000033 // All integer types smaller than ints promote to 4 byte integers.
34 if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4)
35 return 4;
Chris Lattner62eaf7e2002-10-29 21:47:50 +000036
37 return DataLayout.getTypeSize(Ty);
Vikram S. Advedaae6992001-07-21 12:42:08 +000038}
39
Vikram S. Adve44a853c2001-07-28 04:09:37 +000040
41//---------------------------------------------------------------------------
Chris Lattnerf27eeea2002-12-29 02:50:35 +000042// class TargetCacheInfo
Vikram S. Adve4a48c332001-11-09 02:20:18 +000043//
44// Purpose:
45// Describes properties of the target cache architecture.
46//---------------------------------------------------------------------------
47
Chris Lattnerf27eeea2002-12-29 02:50:35 +000048void TargetCacheInfo::Initialize() {
Vikram S. Adve4a48c332001-11-09 02:20:18 +000049 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 Gaeked0fde302003-11-11 22:41:34 +000054
55} // End llvm namespace