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"
17 #include "Support/CommandLine.h"
20 //---------------------------------------------------------------------------
21 // Command-line options that tend to be useful on more than one back-end.
25 bool PrintMachineCode;
28 cl::opt<bool, true> PrintCode("print-machineinstrs",
29 cl::desc("Print generated machine code"),
30 cl::location(PrintMachineCode), cl::init(false));
33 //---------------------------------------------------------------------------
34 // TargetMachine Class
36 TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
38 unsigned char PtrSize, unsigned char PtrAl,
39 unsigned char DoubleAl, unsigned char FloatAl,
40 unsigned char LongAl, unsigned char IntAl,
41 unsigned char ShortAl, unsigned char ByteAl)
42 : Name(name), DataLayout(name, LittleEndian,
43 PtrSize, PtrAl, DoubleAl, FloatAl, LongAl,
44 IntAl, ShortAl, ByteAl) {
45 IL = il ? il : new DefaultIntrinsicLowering();
47 TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
49 : Name(name), DataLayout(name, &M) {
50 IL = il ? il : new DefaultIntrinsicLowering();
53 TargetMachine::~TargetMachine() {
57 unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const {
58 // All integer types smaller than ints promote to 4 byte integers.
59 if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4)
62 return DataLayout.getTypeSize(Ty);