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/TargetAsmInfo.h"
15 #include "llvm/Target/TargetMachine.h"
16 #include "llvm/Target/TargetOptions.h"
17 #include "llvm/Support/CommandLine.h"
20 //---------------------------------------------------------------------------
21 // Command-line options that tend to be useful on more than one back-end.
25 bool PrintMachineCode
;
26 bool NoFramePointerElim
;
27 bool NoExcessFPPrecision
;
29 bool FiniteOnlyFPMathOption
;
30 bool HonorSignDependentRoundingFPMathOption
;
33 bool ExceptionHandling
;
35 Reloc::Model RelocationModel
;
36 CodeModel::Model CMModel
;
39 cl::opt
<bool, true> PrintCode("print-machineinstrs",
40 cl::desc("Print generated machine code"),
41 cl::location(PrintMachineCode
), cl::init(false));
44 DisableFPElim("disable-fp-elim",
45 cl::desc("Disable frame pointer elimination optimization"),
46 cl::location(NoFramePointerElim
),
49 DisableExcessPrecision("disable-excess-fp-precision",
50 cl::desc("Disable optimizations that may increase FP precision"),
51 cl::location(NoExcessFPPrecision
),
54 EnableUnsafeFPMath("enable-unsafe-fp-math",
55 cl::desc("Enable optimizations that may decrease FP precision"),
56 cl::location(UnsafeFPMath
),
59 EnableFiniteOnlyFPMath("enable-finite-only-fp-math",
60 cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"),
61 cl::location(FiniteOnlyFPMathOption
),
64 EnableHonorSignDependentRoundingFPMath(cl::Hidden
,
65 "enable-sign-dependent-rounding-fp-math",
66 cl::desc("Force codegen to assume rounding mode can change dynamically"),
67 cl::location(HonorSignDependentRoundingFPMathOption
),
71 GenerateSoftFloatCalls("soft-float",
72 cl::desc("Generate software floating point library calls"),
73 cl::location(UseSoftFloat
),
76 DontPlaceZerosInBSS("nozero-initialized-in-bss",
77 cl::desc("Don't place zero-initialized symbols into bss section"),
78 cl::location(NoZerosInBSS
),
81 EnableExceptionHandling("enable-eh",
82 cl::desc("Exception handling should be emitted."),
83 cl::location(ExceptionHandling
),
86 cl::opt
<llvm::Reloc::Model
, true>
89 cl::desc("Choose relocation model"),
90 cl::location(RelocationModel
),
91 cl::init(Reloc::Default
),
93 clEnumValN(Reloc::Default
, "default",
94 " Target default relocation model"),
95 clEnumValN(Reloc::Static
, "static",
96 " Non-relocatable code"),
97 clEnumValN(Reloc::PIC_
, "pic",
98 " Fully relocatable, position independent code"),
99 clEnumValN(Reloc::DynamicNoPIC
, "dynamic-no-pic",
100 " Relocatable external references, non-relocatable code"),
102 cl::opt
<llvm::CodeModel::Model
, true>
105 cl::desc("Choose code model"),
106 cl::location(CMModel
),
107 cl::init(CodeModel::Default
),
109 clEnumValN(CodeModel::Default
, "default",
110 " Target default code model"),
111 clEnumValN(CodeModel::Small
, "small",
112 " Small code model"),
113 clEnumValN(CodeModel::Kernel
, "kernel",
114 " Kernel code model"),
115 clEnumValN(CodeModel::Medium
, "medium",
116 " Medium code model"),
117 clEnumValN(CodeModel::Large
, "large",
118 " Large code model"),
121 EnableNewCCModeling("new-cc-modeling-scheme",
122 cl::desc("New CC modeling scheme."),
123 cl::location(NewCCModeling
),
127 //---------------------------------------------------------------------------
128 // TargetMachine Class
131 TargetMachine::~TargetMachine() {
135 /// getRelocationModel - Returns the code generation relocation model. The
136 /// choices are static, PIC, and dynamic-no-pic, and target default.
137 Reloc::Model
TargetMachine::getRelocationModel() {
138 return RelocationModel
;
141 /// setRelocationModel - Sets the code generation relocation model.
142 void TargetMachine::setRelocationModel(Reloc::Model Model
) {
143 RelocationModel
= Model
;
146 /// getCodeModel - Returns the code model. The choices are small, kernel,
147 /// medium, large, and target default.
148 CodeModel::Model
TargetMachine::getCodeModel() {
152 /// setCodeModel - Sets the code model.
153 void TargetMachine::setCodeModel(CodeModel::Model Model
) {
158 /// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math
159 /// option is specified on the command line. If this returns false (default),
160 /// the code generator is not allowed to assume that FP arithmetic arguments
161 /// and results are never NaNs or +-Infs.
162 bool FiniteOnlyFPMath() { return UnsafeFPMath
|| FiniteOnlyFPMathOption
; }
164 /// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
165 /// that the rounding mode of the FPU can change from its default.
166 bool HonorSignDependentRoundingFPMath() {
167 return !UnsafeFPMath
&& HonorSignDependentRoundingFPMathOption
;