12
12
//===----------------------------------------------------------------------===//
14
#include "llvm/CodeGen/MachineFunction.h"
15
#include "llvm/CodeGen/MachineFrameInfo.h"
14
16
#include "llvm/MC/MCAsmInfo.h"
15
17
#include "llvm/Target/TargetMachine.h"
16
18
#include "llvm/Target/TargetOptions.h"
25
27
bool LessPreciseFPMADOption;
26
28
bool PrintMachineCode;
27
29
bool NoFramePointerElim;
30
bool NoFramePointerElimNonLeaf;
28
31
bool NoExcessFPPrecision;
30
bool FiniteOnlyFPMathOption;
31
35
bool HonorSignDependentRoundingFPMathOption;
33
37
FloatABI::ABIType FloatABIType;
34
38
bool NoImplicitFloat;
36
bool DwarfExceptionHandling;
37
bool SjLjExceptionHandling;
40
bool JITExceptionHandling;
38
41
bool JITEmitDebugInfo;
39
42
bool JITEmitDebugInfoToDisk;
40
43
bool UnwindTablesMandatory;
58
61
cl::location(NoFramePointerElim),
60
63
static cl::opt<bool, true>
64
DisableFPElimNonLeaf("disable-non-leaf-fp-elim",
65
cl::desc("Disable frame pointer elimination optimization for non-leaf funcs"),
66
cl::location(NoFramePointerElimNonLeaf),
68
static cl::opt<bool, true>
61
69
DisableExcessPrecision("disable-excess-fp-precision",
62
70
cl::desc("Disable optimizations that may increase FP precision"),
63
71
cl::location(NoExcessFPPrecision),
73
81
cl::location(UnsafeFPMath),
75
83
static cl::opt<bool, true>
76
EnableFiniteOnlyFPMath("enable-finite-only-fp-math",
77
cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"),
78
cl::location(FiniteOnlyFPMathOption),
84
EnableNoInfsFPMath("enable-no-infs-fp-math",
85
cl::desc("Enable FP math optimizations that assume no +-Infs"),
86
cl::location(NoInfsFPMath),
88
static cl::opt<bool, true>
89
EnableNoNaNsFPMath("enable-no-nans-fp-math",
90
cl::desc("Enable FP math optimizations that assume no NaNs"),
91
cl::location(NoNaNsFPMath),
80
93
static cl::opt<bool, true>
81
94
EnableHonorSignDependentRoundingFPMath("enable-sign-dependent-rounding-fp-math",
107
120
cl::location(NoZerosInBSS),
108
121
cl::init(false));
109
122
static cl::opt<bool, true>
110
EnableDwarfExceptionHandling("enable-eh",
111
cl::desc("Emit DWARF exception handling (default if target supports)"),
112
cl::location(DwarfExceptionHandling),
114
static cl::opt<bool, true>
115
EnableSjLjExceptionHandling("enable-sjlj-eh",
116
cl::desc("Emit SJLJ exception handling (default if target supports)"),
117
cl::location(SjLjExceptionHandling),
123
EnableJITExceptionHandling("jit-enable-eh",
124
cl::desc("Emit exception handling information"),
125
cl::location(JITExceptionHandling),
118
126
cl::init(false));
119
127
// In debug builds, make this default to true.
197
205
cl::desc("Use strong PHI elimination."),
198
206
cl::location(StrongPHIElim),
199
207
cl::init(false));
209
DataSections("fdata-sections",
210
cl::desc("Emit data into separate sections"),
213
FunctionSections("ffunction-sections",
214
cl::desc("Emit functions into separate sections"),
201
216
//---------------------------------------------------------------------------
202
217
// TargetMachine Class
205
220
TargetMachine::TargetMachine(const Target &T)
206
: TheTarget(T), AsmInfo(0) {
221
: TheTarget(T), AsmInfo(0),
207
223
// Typically it will be subtargets that will adjust FloatABIType from Default
208
224
// to Soft or Hard.
209
225
if (UseSoftFloat)
244
260
AsmVerbosityDefault = V;
263
bool TargetMachine::getFunctionSections() {
264
return FunctionSections;
267
bool TargetMachine::getDataSections() {
271
void TargetMachine::setFunctionSections(bool V) {
272
FunctionSections = V;
275
void TargetMachine::setDataSections(bool V) {
280
/// DisableFramePointerElim - This returns true if frame pointer elimination
281
/// optimization should be disabled for the given machine function.
282
bool DisableFramePointerElim(const MachineFunction &MF) {
283
// Check to see if we should eliminate non-leaf frame pointers and then
284
// check to see if we should eliminate all frame pointers.
285
if (NoFramePointerElimNonLeaf && !NoFramePointerElim) {
286
const MachineFrameInfo *MFI = MF.getFrameInfo();
287
return MFI->hasCalls();
290
return NoFramePointerElim;
248
293
/// LessPreciseFPMAD - This flag return true when -enable-fp-mad option
249
294
/// is specified on the command line. When this flag is off(default), the
250
295
/// code generator is not allowed to generate mad (multiply add) if the
251
296
/// result is "less precise" than doing those operations individually.
252
297
bool LessPreciseFPMAD() { return UnsafeFPMath || LessPreciseFPMADOption; }
254
/// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math
255
/// option is specified on the command line. If this returns false (default),
256
/// the code generator is not allowed to assume that FP arithmetic arguments
257
/// and results are never NaNs or +-Infs.
258
bool FiniteOnlyFPMath() { return UnsafeFPMath || FiniteOnlyFPMathOption; }
260
299
/// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
261
300
/// that the rounding mode of the FPU can change from its default.
262
301
bool HonorSignDependentRoundingFPMath() {