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.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Target/TargetMachine.h"
15 #include "llvm/Type.h"
16 #include "llvm/IntrinsicLowering.h"
19 //---------------------------------------------------------------------------
20 // TargetMachine Class
22 TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
24 unsigned char PtrSize, unsigned char PtrAl,
25 unsigned char DoubleAl, unsigned char FloatAl,
26 unsigned char LongAl, unsigned char IntAl,
27 unsigned char ShortAl, unsigned char ByteAl)
28 : Name(name), DataLayout(name, LittleEndian,
29 PtrSize, PtrAl, DoubleAl, FloatAl, LongAl,
30 IntAl, ShortAl, ByteAl) {
31 IL = il ? il : new DefaultIntrinsicLowering();
34 TargetMachine::~TargetMachine() {
38 unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const {
39 // All integer types smaller than ints promote to 4 byte integers.
40 if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4)
43 return DataLayout.getTypeSize(Ty);