LLVM  9.0.0svn
TargetOptions.h
Go to the documentation of this file.
1 //===-- llvm/Target/TargetOptions.h - Target Options ------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines command line option flags that are shared across various
10 // targets.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_TARGET_TARGETOPTIONS_H
15 #define LLVM_TARGET_TARGETOPTIONS_H
16 
18 
19 namespace llvm {
20  class MachineFunction;
21  class Module;
22 
23  namespace FloatABI {
24  enum ABIType {
25  Default, // Target-specific (either soft or hard depending on triple, etc).
26  Soft, // Soft float.
27  Hard // Hard float.
28  };
29  }
30 
31  namespace FPOpFusion {
33  Fast, // Enable fusion of FP ops wherever it's profitable.
34  Standard, // Only allow fusion of 'blessed' ops (currently just fmuladd).
35  Strict // Never fuse FP-ops.
36  };
37  }
38 
39  namespace JumpTable {
41  Single, // Use a single table for all indirect jumptable calls.
42  Arity, // Use one table per number of function parameters.
43  Simplified, // Use one table per function type, with types projected
44  // into 4 types: pointer to non-function, struct,
45  // primitive, and function pointer.
46  Full // Use one table per unique function type
47  };
48  }
49 
50  namespace ThreadModel {
51  enum Model {
52  POSIX, // POSIX Threads
53  Single // Single Threaded Environment
54  };
55  }
56 
57  namespace FPDenormal {
58  enum DenormalMode {
59  IEEE, // IEEE 754 denormal numbers
60  PreserveSign, // the sign of a flushed-to-zero number is preserved in
61  // the sign of 0
62  PositiveZero // denormals are flushed to positive zero
63  };
64  }
65 
66  enum class EABI {
67  Unknown,
68  Default, // Default means not specified
69  EABI4, // Target-specific (either 4, 5 or gnu depending on triple).
70  EABI5,
71  GNU
72  };
73 
74  /// Identify a debugger for "tuning" the debug info.
75  ///
76  /// The "debugger tuning" concept allows us to present a more intuitive
77  /// interface that unpacks into different sets of defaults for the various
78  /// individual feature-flag settings, that suit the preferences of the
79  /// various debuggers. However, it's worth remembering that debuggers are
80  /// not the only consumers of debug info, and some variations in DWARF might
81  /// better be treated as target/platform issues. Fundamentally,
82  /// o if the feature is useful (or not) to a particular debugger, regardless
83  /// of the target, that's a tuning decision;
84  /// o if the feature is useful (or not) on a particular platform, regardless
85  /// of the debugger, that's a target decision.
86  /// It's not impossible to see both factors in some specific case.
87  ///
88  /// The "tuning" should be used to set defaults for individual feature flags
89  /// in DwarfDebug; if a given feature has a more specific command-line option,
90  /// that option should take precedence over the tuning.
91  enum class DebuggerKind {
92  Default, // No specific tuning requested.
93  GDB, // Tune debug info for gdb.
94  LLDB, // Tune debug info for lldb.
95  SCE // Tune debug info for SCE targets (e.g. PS4).
96  };
97 
98  /// Enable abort calls when global instruction selection fails to lower/select
99  /// an instruction.
100  enum class GlobalISelAbortMode {
101  Disable, // Disable the abort.
102  Enable, // Enable the abort.
103  DisableWithDiag // Disable the abort but emit a diagnostic on failure.
104  };
105 
107  public:
109  : PrintMachineCode(false), UnsafeFPMath(false), NoInfsFPMath(false),
110  NoNaNsFPMath(false), NoTrappingFPMath(false),
111  NoSignedZerosFPMath(false),
112  HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
113  GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
114  EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
115  DisableIntegratedAS(false), RelaxELFRelocations(false),
116  FunctionSections(false), DataSections(false),
117  UniqueSectionNames(true), TrapUnreachable(false),
118  NoTrapAfterNoreturn(false), EmulatedTLS(false),
119  ExplicitEmulatedTLS(false), EnableIPRA(false),
120  EmitStackSizeSection(false), EnableMachineOutliner(false),
121  SupportsDefaultOutlining(false), EmitAddrsig(false) {}
122 
123  /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
124  /// option is specified on the command line, and should enable debugging
125  /// output from the code generator.
126  unsigned PrintMachineCode : 1;
127 
128  /// DisableFramePointerElim - This returns true if frame pointer elimination
129  /// optimization should be disabled for the given machine function.
130  bool DisableFramePointerElim(const MachineFunction &MF) const;
131 
132  /// UnsafeFPMath - This flag is enabled when the
133  /// -enable-unsafe-fp-math flag is specified on the command line. When
134  /// this flag is off (the default), the code generator is not allowed to
135  /// produce results that are "less precise" than IEEE allows. This includes
136  /// use of X86 instructions like FSIN and FCOS instead of libcalls.
137  unsigned UnsafeFPMath : 1;
138 
139  /// NoInfsFPMath - This flag is enabled when the
140  /// -enable-no-infs-fp-math flag is specified on the command line. When
141  /// this flag is off (the default), the code generator is not allowed to
142  /// assume the FP arithmetic arguments and results are never +-Infs.
143  unsigned NoInfsFPMath : 1;
144 
145  /// NoNaNsFPMath - This flag is enabled when the
146  /// -enable-no-nans-fp-math flag is specified on the command line. When
147  /// this flag is off (the default), the code generator is not allowed to
148  /// assume the FP arithmetic arguments and results are never NaNs.
149  unsigned NoNaNsFPMath : 1;
150 
151  /// NoTrappingFPMath - This flag is enabled when the
152  /// -enable-no-trapping-fp-math is specified on the command line. This
153  /// specifies that there are no trap handlers to handle exceptions.
154  unsigned NoTrappingFPMath : 1;
155 
156  /// NoSignedZerosFPMath - This flag is enabled when the
157  /// -enable-no-signed-zeros-fp-math is specified on the command line. This
158  /// specifies that optimizations are allowed to treat the sign of a zero
159  /// argument or result as insignificant.
160  unsigned NoSignedZerosFPMath : 1;
161 
162  /// HonorSignDependentRoundingFPMath - This returns true when the
163  /// -enable-sign-dependent-rounding-fp-math is specified. If this returns
164  /// false (the default), the code generator is allowed to assume that the
165  /// rounding behavior is the default (round-to-zero for all floating point
166  /// to integer conversions, and round-to-nearest for all other arithmetic
167  /// truncations). If this is enabled (set to true), the code generator must
168  /// assume that the rounding mode may dynamically change.
170  bool HonorSignDependentRoundingFPMath() const;
171 
172  /// NoZerosInBSS - By default some codegens place zero-initialized data to
173  /// .bss section. This flag disables such behaviour (necessary, e.g. for
174  /// crt*.o compiling).
175  unsigned NoZerosInBSS : 1;
176 
177  /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is
178  /// specified on the commandline. When the flag is on, participating targets
179  /// will perform tail call optimization on all calls which use the fastcc
180  /// calling convention and which satisfy certain target-independent
181  /// criteria (being at the end of a function, having the same return type
182  /// as their parent function, etc.), using an alternate ABI if necessary.
183  unsigned GuaranteedTailCallOpt : 1;
184 
185  /// StackAlignmentOverride - Override default stack alignment for target.
186  unsigned StackAlignmentOverride = 0;
187 
188  /// StackSymbolOrdering - When true, this will allow CodeGen to order
189  /// the local stack symbols (for code size, code locality, or any other
190  /// heuristics). When false, the local symbols are left in whatever order
191  /// they were generated. Default is true.
192  unsigned StackSymbolOrdering : 1;
193 
194  /// EnableFastISel - This flag enables fast-path instruction selection
195  /// which trades away generated code quality in favor of reducing
196  /// compile time.
197  unsigned EnableFastISel : 1;
198 
199  /// EnableGlobalISel - This flag enables global instruction selection.
200  unsigned EnableGlobalISel : 1;
201 
202  /// EnableGlobalISelAbort - Control abort behaviour when global instruction
203  /// selection fails to lower/select an instruction.
205 
206  /// UseInitArray - Use .init_array instead of .ctors for static
207  /// constructors.
208  unsigned UseInitArray : 1;
209 
210  /// Disable the integrated assembler.
211  unsigned DisableIntegratedAS : 1;
212 
213  /// Compress DWARF debug sections.
215 
216  unsigned RelaxELFRelocations : 1;
217 
218  /// Emit functions into separate sections.
219  unsigned FunctionSections : 1;
220 
221  /// Emit data into separate sections.
222  unsigned DataSections : 1;
223 
224  unsigned UniqueSectionNames : 1;
225 
226  /// Emit target-specific trap instruction for 'unreachable' IR instructions.
227  unsigned TrapUnreachable : 1;
228 
229  /// Do not emit a trap instruction for 'unreachable' IR instructions behind
230  /// noreturn calls, even if TrapUnreachable is true.
231  unsigned NoTrapAfterNoreturn : 1;
232 
233  /// EmulatedTLS - This flag enables emulated TLS model, using emutls
234  /// function in the runtime library..
235  unsigned EmulatedTLS : 1;
236 
237  /// Whether -emulated-tls or -no-emulated-tls is set.
238  unsigned ExplicitEmulatedTLS : 1;
239 
240  /// This flag enables InterProcedural Register Allocation (IPRA).
241  unsigned EnableIPRA : 1;
242 
243  /// Emit section containing metadata on function stack sizes.
244  unsigned EmitStackSizeSection : 1;
245 
246  /// Enables the MachineOutliner pass.
247  unsigned EnableMachineOutliner : 1;
248 
249  /// Set if the target supports default outlining behaviour.
251 
252  /// Emit address-significance table.
253  unsigned EmitAddrsig : 1;
254 
255  /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
256  /// on the command line. This setting may either be Default, Soft, or Hard.
257  /// Default selects the target's default behavior. Soft selects the ABI for
258  /// software floating point, but does not indicate that FP hardware may not
259  /// be used. Such a combination is unfortunately popular (e.g.
260  /// arm-apple-darwin). Hard presumes that the normal FP ABI is used.
262 
263  /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
264  /// This controls the creation of fused FP ops that store intermediate
265  /// results in higher precision than IEEE allows (E.g. FMAs).
266  ///
267  /// Fast mode - allows formation of fused FP ops whenever they're
268  /// profitable.
269  /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
270  /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
271  /// may be added.
272  /// Strict mode - allow fusion only if/when it can be proven that the excess
273  /// precision won't effect the result.
274  ///
275  /// Note: This option only controls formation of fused ops by the
276  /// optimizers. Fused operations that are explicitly specified (e.g. FMA
277  /// via the llvm.fma.* intrinsic) will always be honored, regardless of
278  /// the value of this option.
280 
281  /// ThreadModel - This flag specifies the type of threading model to assume
282  /// for things like atomics
284 
285  /// EABIVersion - This flag specifies the EABI version
286  EABI EABIVersion = EABI::Default;
287 
288  /// Which debugger to tune for.
290 
291  /// FPDenormalMode - This flags specificies which denormal numbers the code
292  /// is permitted to require.
294 
295  /// What exception model to use
297 
298  /// Machine level options.
300  };
301 
302 } // End llvm namespace
303 
304 #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.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
unsigned EnableFastISel
EnableFastISel - This flag enables fast-path instruction selection which trades away generated code q...
unsigned DataSections
Emit data into separate sections.
unsigned EnableMachineOutliner
Enables the MachineOutliner pass.
block Block Frequency true
unsigned NoTrapAfterNoreturn
Do not emit a trap instruction for 'unreachable' IR instructions behind noreturn calls, even if TrapUnreachable is true.
DebuggerKind
Identify a debugger for "tuning" the debug info.
Definition: TargetOptions.h:91
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 DisableIntegratedAS
Disable the integrated assembler.
unsigned EnableIPRA
This flag enables InterProcedural Register Allocation (IPRA).
unsigned NoNaNsFPMath
NoNaNsFPMath - This flag is enabled when the -enable-no-nans-fp-math flag is specified on the command...
static cl::opt< RunOutliner > EnableMachineOutliner("enable-machine-outliner", cl::desc("Enable the machine outliner"), cl::Hidden, cl::ValueOptional, cl::init(TargetDefault), cl::values(clEnumValN(AlwaysOutline, "always", "Run on all functions guaranteed to be beneficial"), clEnumValN(NeverOutline, "never", "Disable all outlining"), clEnumValN(AlwaysOutline, "", "")))
unsigned FunctionSections
Emit functions into separate sections.
unsigned UniqueSectionNames
unsigned SupportsDefaultOutlining
Set if the target supports default outlining behaviour.
unsigned EnableGlobalISel
EnableGlobalISel - This flag enables global instruction selection.
unsigned UnsafeFPMath
UnsafeFPMath - This flag is enabled when the -enable-unsafe-fp-math flag is specified on the command ...
unsigned ExplicitEmulatedTLS
Whether -emulated-tls or -no-emulated-tls is set.
unsigned EmitStackSizeSection
Emit section containing metadata on function stack sizes.
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...
unsigned NoZerosInBSS
NoZerosInBSS - By default some codegens place zero-initialized data to .bss section.
unsigned UseInitArray
UseInitArray - Use .init_array instead of .ctors for static constructors.
unsigned EmitAddrsig
Emit address-significance table.
unsigned EmulatedTLS
EmulatedTLS - This flag enables emulated TLS model, using emutls function in the runtime library...
unsigned RelaxELFRelocations
GlobalISelAbortMode
Enable abort calls when global instruction selection fails to lower/select an instruction.
unsigned HonorSignDependentRoundingFPMathOption
HonorSignDependentRoundingFPMath - This returns true when the -enable-sign-dependent-rounding-fp-math...
ExceptionHandling
unsigned NoSignedZerosFPMath
NoSignedZerosFPMath - This flag is enabled when the -enable-no-signed-zeros-fp-math is specified on t...
unsigned TrapUnreachable
Emit target-specific trap instruction for &#39;unreachable&#39; IR instructions.
DebugCompressionType