LLVM  4.0.0
TargetOptions.h
Go to the documentation of this file.
1 //===-- llvm/Target/TargetOptions.h - Target Options ------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines command line option flags that are shared across various
11 // targets.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_TARGET_TARGETOPTIONS_H
16 #define LLVM_TARGET_TARGETOPTIONS_H
17 
19 
20 namespace llvm {
21  class MachineFunction;
22  class Module;
23 
24  namespace FloatABI {
25  enum ABIType {
26  Default, // Target-specific (either soft or hard depending on triple, etc).
27  Soft, // Soft float.
28  Hard // Hard float.
29  };
30  }
31 
32  namespace FPOpFusion {
34  Fast, // Enable fusion of FP ops wherever it's profitable.
35  Standard, // Only allow fusion of 'blessed' ops (currently just fmuladd).
36  Strict // Never fuse FP-ops.
37  };
38  }
39 
40  namespace JumpTable {
42  Single, // Use a single table for all indirect jumptable calls.
43  Arity, // Use one table per number of function parameters.
44  Simplified, // Use one table per function type, with types projected
45  // into 4 types: pointer to non-function, struct,
46  // primitive, and function pointer.
47  Full // Use one table per unique function type
48  };
49  }
50 
51  namespace ThreadModel {
52  enum Model {
53  POSIX, // POSIX Threads
54  Single // Single Threaded Environment
55  };
56  }
57 
58  namespace FPDenormal {
59  enum DenormalMode {
60  IEEE, // IEEE 754 denormal numbers
61  PreserveSign, // the sign of a flushed-to-zero number is preserved in
62  // the sign of 0
63  PositiveZero // denormals are flushed to positive zero
64  };
65  }
66 
67  enum class EABI {
68  Unknown,
69  Default, // Default means not specified
70  EABI4, // Target-specific (either 4, 5 or gnu depending on triple).
71  EABI5,
72  GNU
73  };
74 
75  /// Identify a debugger for "tuning" the debug info.
76  ///
77  /// The "debugger tuning" concept allows us to present a more intuitive
78  /// interface that unpacks into different sets of defaults for the various
79  /// individual feature-flag settings, that suit the preferences of the
80  /// various debuggers. However, it's worth remembering that debuggers are
81  /// not the only consumers of debug info, and some variations in DWARF might
82  /// better be treated as target/platform issues. Fundamentally,
83  /// o if the feature is useful (or not) to a particular debugger, regardless
84  /// of the target, that's a tuning decision;
85  /// o if the feature is useful (or not) on a particular platform, regardless
86  /// of the debugger, that's a target decision.
87  /// It's not impossible to see both factors in some specific case.
88  ///
89  /// The "tuning" should be used to set defaults for individual feature flags
90  /// in DwarfDebug; if a given feature has a more specific command-line option,
91  /// that option should take precedence over the tuning.
92  enum class DebuggerKind {
93  Default, // No specific tuning requested.
94  GDB, // Tune debug info for gdb.
95  LLDB, // Tune debug info for lldb.
96  SCE // Tune debug info for SCE targets (e.g. PS4).
97  };
98 
99  class TargetOptions {
100  public:
112  FloatABIType(FloatABI::Default),
113  AllowFPOpFusion(FPOpFusion::Standard),
116  FPDenormalMode(FPDenormal::IEEE),
118 
119  /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
120  /// option is specified on the command line, and should enable debugging
121  /// output from the code generator.
122  unsigned PrintMachineCode : 1;
123 
124  /// DisableFramePointerElim - This returns true if frame pointer elimination
125  /// optimization should be disabled for the given machine function.
126  bool DisableFramePointerElim(const MachineFunction &MF) const;
127 
128  /// LessPreciseFPMAD - This flag is enabled when the
129  /// -enable-fp-mad is specified on the command line. When this flag is off
130  /// (the default), the code generator is not allowed to generate mad
131  /// (multiply add) if the result is "less precise" than doing those
132  /// operations individually.
134  bool LessPreciseFPMAD() const;
135 
136  /// UnsafeFPMath - This flag is enabled when the
137  /// -enable-unsafe-fp-math flag is specified on the command line. When
138  /// this flag is off (the default), the code generator is not allowed to
139  /// produce results that are "less precise" than IEEE allows. This includes
140  /// use of X86 instructions like FSIN and FCOS instead of libcalls.
141  /// UnsafeFPMath implies LessPreciseFPMAD.
142  unsigned UnsafeFPMath : 1;
143 
144  /// NoInfsFPMath - This flag is enabled when the
145  /// -enable-no-infs-fp-math flag is specified on the command line. When
146  /// this flag is off (the default), the code generator is not allowed to
147  /// assume the FP arithmetic arguments and results are never +-Infs.
148  unsigned NoInfsFPMath : 1;
149 
150  /// NoNaNsFPMath - This flag is enabled when the
151  /// -enable-no-nans-fp-math flag is specified on the command line. When
152  /// this flag is off (the default), the code generator is not allowed to
153  /// assume the FP arithmetic arguments and results are never NaNs.
154  unsigned NoNaNsFPMath : 1;
155 
156  /// NoTrappingFPMath - This flag is enabled when the
157  /// -enable-no-trapping-fp-math is specified on the command line. This
158  /// specifies that there are no trap handlers to handle exceptions.
159  unsigned NoTrappingFPMath : 1;
160 
161  /// HonorSignDependentRoundingFPMath - This returns true when the
162  /// -enable-sign-dependent-rounding-fp-math is specified. If this returns
163  /// false (the default), the code generator is allowed to assume that the
164  /// rounding behavior is the default (round-to-zero for all floating point
165  /// to integer conversions, and round-to-nearest for all other arithmetic
166  /// truncations). If this is enabled (set to true), the code generator must
167  /// assume that the rounding mode may dynamically change.
170 
171  /// NoZerosInBSS - By default some codegens place zero-initialized data to
172  /// .bss section. This flag disables such behaviour (necessary, e.g. for
173  /// crt*.o compiling).
174  unsigned NoZerosInBSS : 1;
175 
176  /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is
177  /// specified on the commandline. When the flag is on, participating targets
178  /// will perform tail call optimization on all calls which use the fastcc
179  /// calling convention and which satisfy certain target-independent
180  /// criteria (being at the end of a function, having the same return type
181  /// as their parent function, etc.), using an alternate ABI if necessary.
182  unsigned GuaranteedTailCallOpt : 1;
183 
184  /// StackAlignmentOverride - Override default stack alignment for target.
186 
187  /// StackSymbolOrdering - When true, this will allow CodeGen to order
188  /// the local stack symbols (for code size, code locality, or any other
189  /// heuristics). When false, the local symbols are left in whatever order
190  /// they were generated. Default is true.
191  unsigned StackSymbolOrdering : 1;
192 
193  /// EnableFastISel - This flag enables fast-path instruction selection
194  /// which trades away generated code quality in favor of reducing
195  /// compile time.
196  unsigned EnableFastISel : 1;
197 
198  /// UseInitArray - Use .init_array instead of .ctors for static
199  /// constructors.
200  unsigned UseInitArray : 1;
201 
202  /// Disable the integrated assembler.
203  unsigned DisableIntegratedAS : 1;
204 
205  /// Compress DWARF debug sections.
206  unsigned CompressDebugSections : 1;
207 
208  unsigned RelaxELFRelocations : 1;
209 
210  /// Emit functions into separate sections.
211  unsigned FunctionSections : 1;
212 
213  /// Emit data into separate sections.
214  unsigned DataSections : 1;
215 
216  unsigned UniqueSectionNames : 1;
217 
218  /// Emit target-specific trap instruction for 'unreachable' IR instructions.
219  unsigned TrapUnreachable : 1;
220 
221  /// EmulatedTLS - This flag enables emulated TLS model, using emutls
222  /// function in the runtime library..
223  unsigned EmulatedTLS : 1;
224 
225  /// This flag enables InterProcedural Register Allocation (IPRA).
226  unsigned EnableIPRA : 1;
227 
228  /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
229  /// on the command line. This setting may either be Default, Soft, or Hard.
230  /// Default selects the target's default behavior. Soft selects the ABI for
231  /// software floating point, but does not indicate that FP hardware may not
232  /// be used. Such a combination is unfortunately popular (e.g.
233  /// arm-apple-darwin). Hard presumes that the normal FP ABI is used.
235 
236  /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
237  /// This controls the creation of fused FP ops that store intermediate
238  /// results in higher precision than IEEE allows (E.g. FMAs).
239  ///
240  /// Fast mode - allows formation of fused FP ops whenever they're
241  /// profitable.
242  /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
243  /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
244  /// may be added.
245  /// Strict mode - allow fusion only if/when it can be proven that the excess
246  /// precision won't effect the result.
247  ///
248  /// Note: This option only controls formation of fused ops by the
249  /// optimizers. Fused operations that are explicitly specified (e.g. FMA
250  /// via the llvm.fma.* intrinsic) will always be honored, regardless of
251  /// the value of this option.
253 
254  /// ThreadModel - This flag specifies the type of threading model to assume
255  /// for things like atomics
257 
258  /// EABIVersion - This flag specifies the EABI version
260 
261  /// Which debugger to tune for.
263 
264  /// FPDenormalMode - This flags specificies which denormal numbers the code
265  /// is permitted to require.
267 
268  /// What exception model to use
270 
271  /// Machine level options.
273  };
274 
275 // Comparison operators:
276 
277 
278 inline bool operator==(const TargetOptions &LHS,
279  const TargetOptions &RHS) {
280 #define ARE_EQUAL(X) LHS.X == RHS.X
281  return
282  ARE_EQUAL(UnsafeFPMath) &&
283  ARE_EQUAL(NoInfsFPMath) &&
284  ARE_EQUAL(NoNaNsFPMath) &&
285  ARE_EQUAL(NoTrappingFPMath) &&
286  ARE_EQUAL(HonorSignDependentRoundingFPMathOption) &&
287  ARE_EQUAL(NoZerosInBSS) &&
288  ARE_EQUAL(GuaranteedTailCallOpt) &&
289  ARE_EQUAL(StackAlignmentOverride) &&
290  ARE_EQUAL(EnableFastISel) &&
291  ARE_EQUAL(UseInitArray) &&
292  ARE_EQUAL(TrapUnreachable) &&
294  ARE_EQUAL(FloatABIType) &&
295  ARE_EQUAL(AllowFPOpFusion) &&
296  ARE_EQUAL(ThreadModel) &&
298  ARE_EQUAL(DebuggerTuning) &&
299  ARE_EQUAL(FPDenormalMode) &&
301  ARE_EQUAL(MCOptions) &&
303 #undef ARE_EQUAL
304 }
305 
306 inline bool operator!=(const TargetOptions &LHS,
307  const TargetOptions &RHS) {
308  return !(LHS == RHS);
309 }
310 
311 } // End llvm namespace
312 
313 #endif
unsigned StackSymbolOrdering
StackSymbolOrdering - When true, this will allow CodeGen to order the local stack symbols (for code s...
unsigned NoTrappingFPMath
NoTrappingFPMath - This flag is enabled when the -enable-no-trapping-fp-math is specified on the comm...
unsigned PrintMachineCode
PrintMachineCode - This flag is enabled when the -print-machineinstrs option is specified on the comm...
MCTargetOptions MCOptions
Machine level options.
unsigned EnableFastISel
EnableFastISel - This flag enables fast-path instruction selection which trades away generated code q...
EABI EABIVersion
EABIVersion - This flag specifies the EABI version.
unsigned DataSections
Emit data into separate sections.
ThreadModel::Model ThreadModel
ThreadModel - This flag specifies the type of threading model to assume for things like atomics...
DebuggerKind
Identify a debugger for "tuning" the debug info.
Definition: TargetOptions.h:92
unsigned DisableIntegratedAS
Disable the integrated assembler.
unsigned EnableIPRA
This flag enables InterProcedural Register Allocation (IPRA).
bool HonorSignDependentRoundingFPMath() const
HonorSignDependentRoundingFPMath - Return true if the codegen must assume that the rounding mode of t...
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
ExceptionHandling ExceptionModel
What exception model to use.
unsigned NoNaNsFPMath
NoNaNsFPMath - This flag is enabled when the -enable-no-nans-fp-math flag is specified on the command...
Function Alias Analysis false
unsigned FunctionSections
Emit functions into separate sections.
cl::opt< llvm::ExceptionHandling > ExceptionModel("exception-model", cl::desc("exception model"), cl::init(ExceptionHandling::None), cl::values(clEnumValN(ExceptionHandling::None,"default","default exception handling model"), clEnumValN(ExceptionHandling::DwarfCFI,"dwarf","DWARF-like CFI based exception handling"), clEnumValN(ExceptionHandling::SjLj,"sjlj","SjLj exception handling"), clEnumValN(ExceptionHandling::ARM,"arm","ARM EHABI exceptions"), clEnumValN(ExceptionHandling::WinEH,"wineh","Windows exception model")))
unsigned UniqueSectionNames
DebuggerKind DebuggerTuning
Which debugger to tune for.
unsigned UnsafeFPMath
UnsafeFPMath - This flag is enabled when the -enable-unsafe-fp-math flag is specified on the command ...
FPOpFusion::FPOpFusionMode AllowFPOpFusion
AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
unsigned GuaranteedTailCallOpt
GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is specified on the commandline...
unsigned NoInfsFPMath
NoInfsFPMath - This flag is enabled when the -enable-no-infs-fp-math flag is specified on the command...
FPDenormal::DenormalMode FPDenormalMode
FPDenormalMode - This flags specificies which denormal numbers the code is permitted to require...
unsigned NoZerosInBSS
NoZerosInBSS - By default some codegens place zero-initialized data to .bss section.
unsigned CompressDebugSections
Compress DWARF debug sections.
unsigned UseInitArray
UseInitArray - Use .init_array instead of .ctors for static constructors.
unsigned StackAlignmentOverride
StackAlignmentOverride - Override default stack alignment for target.
cl::opt< bool > EnableIPRA("enable-ipra", cl::init(false), cl::Hidden, cl::desc("Enable interprocedural register allocation ""to reduce load/store at procedure calls."))
unsigned EmulatedTLS
EmulatedTLS - This flag enables emulated TLS model, using emutls function in the runtime library...
cl::opt< llvm::EABI > EABIVersion("meabi", cl::desc("Set EABI type (default depends on triple):"), cl::init(EABI::Default), cl::values(clEnumValN(EABI::Default,"default","Triple default EABI version"), clEnumValN(EABI::EABI4,"4","EABI version 4"), clEnumValN(EABI::EABI5,"5","EABI version 5"), clEnumValN(EABI::GNU,"gnu","EABI GNU")))
unsigned RelaxELFRelocations
#define ARE_EQUAL(X)
bool operator!=(uint64_t V1, const APInt &V2)
Definition: APInt.h:1724
Basic Alias true
bool LessPreciseFPMAD() const
LessPreciseFPMAD - This flag return true when -enable-fp-mad option is specified on the command line...
unsigned HonorSignDependentRoundingFPMathOption
HonorSignDependentRoundingFPMath - This returns true when the -enable-sign-dependent-rounding-fp-math...
ExceptionHandling
unsigned TrapUnreachable
Emit target-specific trap instruction for 'unreachable' IR instructions.
unsigned LessPreciseFPMADOption
LessPreciseFPMAD - This flag is enabled when the -enable-fp-mad is specified on the command line...
bool operator==(uint64_t V1, const APInt &V2)
Definition: APInt.h:1722
cl::opt< bool > EmulatedTLS("emulated-tls", cl::desc("Use emulated TLS model"), cl::init(false))
FloatABI::ABIType FloatABIType
FloatABIType - This setting is set by -float-abi=xxx option is specfied on the command line...