1 //===-- TargetMachine.cpp - General Target Information ---------------------==//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // This file describes the general parts of a Target machine.
11 // This file also implements TargetCacheInfo.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/Target/TargetMachine.h"
16 #include "llvm/Target/TargetCacheInfo.h"
17 #include "llvm/Type.h"
18 #include "llvm/IntrinsicLowering.h"
21 //---------------------------------------------------------------------------
22 // TargetMachine Class
24 TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
26 unsigned char PtrSize, unsigned char PtrAl,
27 unsigned char DoubleAl, unsigned char FloatAl,
28 unsigned char LongAl, unsigned char IntAl,
29 unsigned char ShortAl, unsigned char ByteAl)
30 : Name(name), DataLayout(name, LittleEndian,
31 PtrSize, PtrAl, DoubleAl, FloatAl, LongAl,
32 IntAl, ShortAl, ByteAl) {
33 IL = il ? il : new DefaultIntrinsicLowering();
38 TargetMachine::~TargetMachine() {
45 unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const {
46 // All integer types smaller than ints promote to 4 byte integers.
47 if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4)
50 return DataLayout.getTypeSize(Ty);
54 //---------------------------------------------------------------------------
55 // TargetCacheInfo Class
58 void TargetCacheInfo::Initialize() {
60 cacheLineSizes.push_back(16); cacheLineSizes.push_back(32);
61 cacheSizes.push_back(1 << 15); cacheSizes.push_back(1 << 20);
62 cacheAssoc.push_back(1); cacheAssoc.push_back(4);