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/Target/TargetOptions.h"
16 #include "llvm/Type.h"
17 #include "llvm/CodeGen/IntrinsicLowering.h"
18 #include "llvm/Support/CommandLine.h"
21 //---------------------------------------------------------------------------
22 // Command-line options that tend to be useful on more than one back-end.
26 bool PrintMachineCode;
27 bool NoFramePointerElim;
28 bool NoExcessFPPrecision;
30 Reloc::Model RelocationModel;
33 cl::opt<bool, true> PrintCode("print-machineinstrs",
34 cl::desc("Print generated machine code"),
35 cl::location(PrintMachineCode), cl::init(false));
38 DisableFPElim("disable-fp-elim",
39 cl::desc("Disable frame pointer elimination optimization"),
40 cl::location(NoFramePointerElim),
43 DisableExcessPrecision("disable-excess-fp-precision",
44 cl::desc("Disable optimizations that may increase FP precision"),
45 cl::location(NoExcessFPPrecision),
48 EnableUnsafeFPMath("enable-unsafe-fp-math",
49 cl::desc("Enable optimizations that may decrease FP precision"),
50 cl::location(UnsafeFPMath),
52 cl::opt<llvm::Reloc::Model, true>
55 cl::desc("Choose relocation model"),
56 cl::location(RelocationModel),
57 cl::init(Reloc::Default),
59 clEnumValN(Reloc::Default, "default",
60 "Target default relocation model"),
61 clEnumValN(Reloc::Static, "static",
62 "Non-relocatable code"),
63 clEnumValN(Reloc::PIC, "pic",
64 "Fully relocatable, position independent code"),
65 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
66 "Relocatable external references, non-relocatable code"),
70 //---------------------------------------------------------------------------
71 // TargetMachine Class
73 TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
75 unsigned char PtrSize, unsigned char PtrAl,
76 unsigned char DoubleAl, unsigned char FloatAl,
77 unsigned char LongAl, unsigned char IntAl,
78 unsigned char ShortAl, unsigned char ByteAl,
80 : Name(name), DataLayout(name, LittleEndian,
81 PtrSize, PtrAl, DoubleAl, FloatAl, LongAl,
82 IntAl, ShortAl, ByteAl, BoolAl) {
83 IL = il ? il : new DefaultIntrinsicLowering();
86 TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
88 : Name(name), DataLayout(TD) {
89 IL = il ? il : new DefaultIntrinsicLowering();
92 TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
94 : Name(name), DataLayout(name, &M) {
95 IL = il ? il : new DefaultIntrinsicLowering();
98 TargetMachine::~TargetMachine() {
102 /// getRelocationModel - Returns the code generation relocation model. The
103 /// choices are static, PIC, and dynamic-no-pic, and target default.
104 Reloc::Model TargetMachine::getRelocationModel() {
105 return RelocationModel;
108 /// setRelocationModel - Sets the code generation relocation model.
109 void TargetMachine::setRelocationModel(Reloc::Model Model) {
110 RelocationModel = Model;