LLVM 20.0.0git
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
19
20#include <memory>
21
22namespace llvm {
23 struct fltSemantics;
24 class MachineFunction;
25 class MemoryBuffer;
26
27 namespace FloatABI {
28 enum ABIType {
29 Default, // Target-specific (either soft or hard depending on triple, etc).
30 Soft, // Soft float.
31 Hard // Hard float.
32 };
33 }
34
35 namespace FPOpFusion {
37 Fast, // Enable fusion of FP ops wherever it's profitable.
38 Standard, // Only allow fusion of 'blessed' ops (currently just fmuladd).
39 Strict // Never fuse FP-ops.
40 };
41 }
42
43 namespace JumpTable {
45 Single, // Use a single table for all indirect jumptable calls.
46 Arity, // Use one table per number of function parameters.
47 Simplified, // Use one table per function type, with types projected
48 // into 4 types: pointer to non-function, struct,
49 // primitive, and function pointer.
50 Full // Use one table per unique function type
51 };
52 }
53
54 namespace ThreadModel {
55 enum Model {
56 POSIX, // POSIX Threads
57 Single // Single Threaded Environment
58 };
59 }
60
61 enum class BasicBlockSection {
62 All, // Use Basic Block Sections for all basic blocks. A section
63 // for every basic block can significantly bloat object file sizes.
64 List, // Get list of functions & BBs from a file. Selectively enables
65 // basic block sections for a subset of basic blocks which can be
66 // used to control object size bloats from creating sections.
67 Preset, // Similar to list but the blocks are identified by passes which
68 // seek to use Basic Block Sections, e.g. MachineFunctionSplitter.
69 // This option cannot be set via the command line.
70 None // Do not use Basic Block Sections.
71 };
72
73 enum class EABI {
74 Unknown,
75 Default, // Default means not specified
76 EABI4, // Target-specific (either 4, 5 or gnu depending on triple).
77 EABI5,
78 GNU
79 };
80
81 /// Identify a debugger for "tuning" the debug info.
82 ///
83 /// The "debugger tuning" concept allows us to present a more intuitive
84 /// interface that unpacks into different sets of defaults for the various
85 /// individual feature-flag settings, that suit the preferences of the
86 /// various debuggers. However, it's worth remembering that debuggers are
87 /// not the only consumers of debug info, and some variations in DWARF might
88 /// better be treated as target/platform issues. Fundamentally,
89 /// o if the feature is useful (or not) to a particular debugger, regardless
90 /// of the target, that's a tuning decision;
91 /// o if the feature is useful (or not) on a particular platform, regardless
92 /// of the debugger, that's a target decision.
93 /// It's not impossible to see both factors in some specific case.
94 enum class DebuggerKind {
95 Default, ///< No specific tuning requested.
96 GDB, ///< Tune debug info for gdb.
97 LLDB, ///< Tune debug info for lldb.
98 SCE, ///< Tune debug info for SCE targets (e.g. PS4).
99 DBX ///< Tune debug info for dbx.
100 };
101
102 /// Enable abort calls when global instruction selection fails to lower/select
103 /// an instruction.
105 Disable, // Disable the abort.
106 Enable, // Enable the abort.
107 DisableWithDiag // Disable the abort but emit a diagnostic on failure.
108 };
109
110 /// Indicates when and how the Swift async frame pointer bit should be set.
112 /// Determine whether to set the bit statically or dynamically based
113 /// on the deployment target.
115 /// Always set the bit.
116 Always,
117 /// Never set the bit.
118 Never,
119 };
120
121 /// \brief Enumeration value for AMDGPU code object version, which is the
122 /// code object version times 100.
125 COV_2 = 200, // Unsupported.
126 COV_3 = 300, // Unsupported.
127 COV_4 = 400,
128 COV_5 = 500,
129 COV_6 = 600,
130 };
131
133 public:
156 FPDenormalMode(DenormalMode::IEEE, DenormalMode::IEEE) {}
157
158 /// DisableFramePointerElim - This returns true if frame pointer elimination
159 /// optimization should be disabled for the given machine function.
160 bool DisableFramePointerElim(const MachineFunction &MF) const;
161
162 /// FramePointerIsReserved - This returns true if the frame pointer must
163 /// always either point to a new frame record or be un-modified in the given
164 /// function.
165 bool FramePointerIsReserved(const MachineFunction &MF) const;
166
167 /// If greater than 0, override the default value of
168 /// MCAsmInfo::BinutilsVersion.
169 std::pair<int, int> BinutilsVersion{0, 0};
170
171 /// UnsafeFPMath - This flag is enabled when the
172 /// -enable-unsafe-fp-math flag is specified on the command line. When
173 /// this flag is off (the default), the code generator is not allowed to
174 /// produce results that are "less precise" than IEEE allows. This includes
175 /// use of X86 instructions like FSIN and FCOS instead of libcalls.
176 unsigned UnsafeFPMath : 1;
177
178 /// NoInfsFPMath - This flag is enabled when the
179 /// -enable-no-infs-fp-math flag is specified on the command line. When
180 /// this flag is off (the default), the code generator is not allowed to
181 /// assume the FP arithmetic arguments and results are never +-Infs.
182 unsigned NoInfsFPMath : 1;
183
184 /// NoNaNsFPMath - This flag is enabled when the
185 /// -enable-no-nans-fp-math flag is specified on the command line. When
186 /// this flag is off (the default), the code generator is not allowed to
187 /// assume the FP arithmetic arguments and results are never NaNs.
188 unsigned NoNaNsFPMath : 1;
189
190 /// NoTrappingFPMath - This flag is enabled when the
191 /// -enable-no-trapping-fp-math is specified on the command line. This
192 /// specifies that there are no trap handlers to handle exceptions.
193 unsigned NoTrappingFPMath : 1;
194
195 /// NoSignedZerosFPMath - This flag is enabled when the
196 /// -enable-no-signed-zeros-fp-math is specified on the command line. This
197 /// specifies that optimizations are allowed to treat the sign of a zero
198 /// argument or result as insignificant.
200
201 /// ApproxFuncFPMath - This flag is enabled when the
202 /// -enable-approx-func-fp-math is specified on the command line. This
203 /// specifies that optimizations are allowed to substitute math functions
204 /// with approximate calculations
205 unsigned ApproxFuncFPMath : 1;
206
207 /// EnableAIXExtendedAltivecABI - This flag returns true when -vec-extabi is
208 /// specified. The code generator is then able to use both volatile and
209 /// nonvolitle vector registers. When false, the code generator only uses
210 /// volatile vector registers which is the default setting on AIX.
212
213 /// HonorSignDependentRoundingFPMath - This returns true when the
214 /// -enable-sign-dependent-rounding-fp-math is specified. If this returns
215 /// false (the default), the code generator is allowed to assume that the
216 /// rounding behavior is the default (round-to-zero for all floating point
217 /// to integer conversions, and round-to-nearest for all other arithmetic
218 /// truncations). If this is enabled (set to true), the code generator must
219 /// assume that the rounding mode may dynamically change.
222
223 /// NoZerosInBSS - By default some codegens place zero-initialized data to
224 /// .bss section. This flag disables such behaviour (necessary, e.g. for
225 /// crt*.o compiling).
226 unsigned NoZerosInBSS : 1;
227
228 /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is
229 /// specified on the commandline. When the flag is on, participating targets
230 /// will perform tail call optimization on all calls which use the fastcc
231 /// calling convention and which satisfy certain target-independent
232 /// criteria (being at the end of a function, having the same return type
233 /// as their parent function, etc.), using an alternate ABI if necessary.
235
236 /// StackSymbolOrdering - When true, this will allow CodeGen to order
237 /// the local stack symbols (for code size, code locality, or any other
238 /// heuristics). When false, the local symbols are left in whatever order
239 /// they were generated. Default is true.
241
242 /// EnableFastISel - This flag enables fast-path instruction selection
243 /// which trades away generated code quality in favor of reducing
244 /// compile time.
245 unsigned EnableFastISel : 1;
246
247 /// EnableGlobalISel - This flag enables global instruction selection.
248 unsigned EnableGlobalISel : 1;
249
250 /// EnableGlobalISelAbort - Control abort behaviour when global instruction
251 /// selection fails to lower/select an instruction.
253
254 /// Control when and how the Swift async frame pointer bit should
255 /// be set.
258
259 /// UseInitArray - Use .init_array instead of .ctors for static
260 /// constructors.
261 unsigned UseInitArray : 1;
262
263 /// Disable the integrated assembler.
265
266 /// Emit functions into separate sections.
267 unsigned FunctionSections : 1;
268
269 /// Emit data into separate sections.
270 unsigned DataSections : 1;
271
272 /// Do not emit visibility attribute for xcoff.
274
275 /// Emit XCOFF traceback table.
277
278 unsigned UniqueSectionNames : 1;
279
280 /// Use unique names for basic block sections.
282
283 /// Emit named sections with the same name into different sections.
285
286 /// Emit target-specific trap instruction for 'unreachable' IR instructions.
287 unsigned TrapUnreachable : 1;
288
289 /// Do not emit a trap instruction for 'unreachable' IR instructions behind
290 /// noreturn calls, even if TrapUnreachable is true.
292
293 /// Bit size of immediate TLS offsets (0 == use the default).
294 unsigned TLSSize : 8;
295
296 /// EmulatedTLS - This flag enables emulated TLS model, using emutls
297 /// function in the runtime library..
298 unsigned EmulatedTLS : 1;
299
300 /// EnableTLSDESC - This flag enables TLS Descriptors.
301 unsigned EnableTLSDESC : 1;
302
303 /// This flag enables InterProcedural Register Allocation (IPRA).
304 unsigned EnableIPRA : 1;
305
306 /// Emit section containing metadata on function stack sizes.
308
309 /// Enables the MachineOutliner pass.
311
312 /// Enables the MachineFunctionSplitter pass.
314
315 /// Set if the target supports default outlining behaviour.
317
318 /// Emit address-significance table.
319 unsigned EmitAddrsig : 1;
320
321 // Emit the SHT_LLVM_BB_ADDR_MAP section containing basic block address
322 // which can be used to map virtual addresses to machine basic blocks.
323 unsigned BBAddrMap : 1;
324
325 /// Emit basic blocks into separate sections.
327
328 /// Memory Buffer that contains information on sampled basic blocks and used
329 /// to selectively generate basic block sections.
330 std::shared_ptr<MemoryBuffer> BBSectionsFuncListBuf;
331
332 /// The flag enables call site info production. It is used only for debug
333 /// info, and it is restricted only to optimized code. This can be used for
334 /// something else, so that should be controlled in the frontend.
335 unsigned EmitCallSiteInfo : 1;
336 /// Set if the target supports the debug entry values by default.
338 /// When set to true, the EnableDebugEntryValues option forces production
339 /// of debug entry values even if the target does not officially support
340 /// it. Useful for testing purposes only. This flag should never be checked
341 /// directly, always use \ref ShouldEmitDebugEntryValues instead.
343 /// NOTE: There are targets that still do not support the debug entry values
344 /// production.
345 bool ShouldEmitDebugEntryValues() const;
346
347 // When set to true, use experimental new debug variable location tracking,
348 // which seeks to follow the values of variables rather than their location,
349 // post isel.
351
352 /// Emit DWARF debug frame section.
354
355 /// Emit XRay Function Index section
356 unsigned XRayFunctionIndex : 1;
357
358 /// When set to true, don't use DWARF extensions in later DWARF versions.
359 /// By default, it is set to false.
360 unsigned DebugStrictDwarf : 1;
361
362 /// Emit the hotpatch flag in CodeView debug.
363 unsigned Hotpatch : 1;
364
365 /// Enables scalar MASS conversions
367
368 /// Enable JustMyCode instrumentation.
369 unsigned JMCInstrument : 1;
370
371 /// Enable the CFIFixup pass.
372 unsigned EnableCFIFixup : 1;
373
374 /// When set to true, enable MisExpect Diagnostics
375 /// By default, it is set to false
376 unsigned MisExpect : 1;
377
378 /// When set to true, const objects with relocatable address values are put
379 /// into the RO data section.
381
382 /// When set to true, call/return argument extensions of narrow integers
383 /// are verified in the target backend if it cares about them. This is
384 /// not done with internal tools like llc that run many tests that ignore
385 /// (lack) these extensions.
387
388 /// Name of the stack usage file (i.e., .su file) if user passes
389 /// -fstack-usage. If empty, it can be implied that -fstack-usage is not
390 /// passed on the command line.
391 std::string StackUsageOutput;
392
393 /// If greater than 0, override TargetLoweringBase::PrefLoopAlignment.
394 unsigned LoopAlignment = 0;
395
396 /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
397 /// on the command line. This setting may either be Default, Soft, or Hard.
398 /// Default selects the target's default behavior. Soft selects the ABI for
399 /// software floating point, but does not indicate that FP hardware may not
400 /// be used. Such a combination is unfortunately popular (e.g.
401 /// arm-apple-darwin). Hard presumes that the normal FP ABI is used.
403
404 /// AllowFPOpFusion - This flag is set by the -fp-contract=xxx option.
405 /// This controls the creation of fused FP ops that store intermediate
406 /// results in higher precision than IEEE allows (E.g. FMAs).
407 ///
408 /// Fast mode - allows formation of fused FP ops whenever they're
409 /// profitable.
410 /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
411 /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
412 /// may be added.
413 /// Strict mode - allow fusion only if/when it can be proven that the excess
414 /// precision won't effect the result.
415 ///
416 /// Note: This option only controls formation of fused ops by the
417 /// optimizers. Fused operations that are explicitly specified (e.g. FMA
418 /// via the llvm.fma.* intrinsic) will always be honored, regardless of
419 /// the value of this option.
421
422 /// ThreadModel - This flag specifies the type of threading model to assume
423 /// for things like atomics
425
426 /// EABIVersion - This flag specifies the EABI version
428
429 /// Which debugger to tune for.
431
432 private:
433 /// Flushing mode to assume in default FP environment.
434 DenormalMode FPDenormalMode;
435
436 /// Flushing mode to assume in default FP environment, for float/vector of
437 /// float.
438 DenormalMode FP32DenormalMode;
439
440 public:
442 FPDenormalMode = Mode;
443 }
444
446 FP32DenormalMode = Mode;
447 }
448
450 return FPDenormalMode;
451 }
452
454 return FP32DenormalMode;
455 }
456
458
459 /// What exception model to use
461
462 /// Machine level options.
464
465 /// Stores the filename/path of the final .o/.obj file, to be written in the
466 /// debug information. This is used for emitting the CodeView S_OBJNAME
467 /// record.
469 };
470
471} // End llvm namespace
472
473#endif
basic Basic Alias true
Utilities for dealing with flags related to floating point properties and mode controls.
static cl::opt< RegAllocEvictionAdvisorAnalysis::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Development, "development", "for training")))
void setFP32DenormalMode(DenormalMode Mode)
DenormalMode getDenormalMode(const fltSemantics &FPType) const
unsigned UnsafeFPMath
UnsafeFPMath - This flag is enabled when the -enable-unsafe-fp-math flag is specified on the command ...
unsigned VerifyArgABICompliance
When set to true, call/return argument extensions of narrow integers are verified in the target backe...
unsigned EnableTLSDESC
EnableTLSDESC - This flag enables TLS Descriptors.
unsigned EmitStackSizeSection
Emit section containing metadata on function stack sizes.
unsigned XCOFFReadOnlyPointers
When set to true, const objects with relocatable address values are put into the RO data section.
unsigned EmitAddrsig
Emit address-significance table.
unsigned EnableAIXExtendedAltivecABI
EnableAIXExtendedAltivecABI - This flag returns true when -vec-extabi is specified.
unsigned UseInitArray
UseInitArray - Use .init_array instead of .ctors for static constructors.
DenormalMode getRawFPDenormalMode() const
bool HonorSignDependentRoundingFPMath() const
HonorSignDependentRoundingFPMath - Return true if the codegen must assume that the rounding mode of t...
unsigned StackSymbolOrdering
StackSymbolOrdering - When true, this will allow CodeGen to order the local stack symbols (for code s...
MCTargetOptions MCOptions
Machine level options.
FloatABI::ABIType FloatABIType
FloatABIType - This setting is set by -float-abi=xxx option is specfied on the command line.
std::pair< int, int > BinutilsVersion
If greater than 0, override the default value of MCAsmInfo::BinutilsVersion.
void setFPDenormalMode(DenormalMode Mode)
unsigned ForceDwarfFrameSection
Emit DWARF debug frame section.
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 EmitCallSiteInfo
The flag enables call site info production.
std::string ObjectFilenameForDebug
Stores the filename/path of the final .o/.obj file, to be written in the debug information.
unsigned MisExpect
When set to true, enable MisExpect Diagnostics By default, it is set to false.
unsigned EnableMachineOutliner
Enables the MachineOutliner pass.
unsigned SeparateNamedSections
Emit named sections with the same name into different sections.
SwiftAsyncFramePointerMode SwiftAsyncFramePointer
Control when and how the Swift async frame pointer bit should be set.
unsigned SupportsDebugEntryValues
Set if the target supports the debug entry values by default.
unsigned ApproxFuncFPMath
ApproxFuncFPMath - This flag is enabled when the -enable-approx-func-fp-math is specified on the comm...
EABI EABIVersion
EABIVersion - This flag specifies the EABI version.
DenormalMode getRawFP32DenormalMode() const
unsigned Hotpatch
Emit the hotpatch flag in CodeView debug.
BasicBlockSection BBSections
Emit basic blocks into separate sections.
unsigned HonorSignDependentRoundingFPMathOption
HonorSignDependentRoundingFPMath - This returns true when the -enable-sign-dependent-rounding-fp-math...
unsigned ValueTrackingVariableLocations
GlobalISelAbortMode GlobalISelAbort
EnableGlobalISelAbort - Control abort behaviour when global instruction selection fails to lower/sele...
unsigned XCOFFTracebackTable
Emit XCOFF traceback table.
DebuggerKind DebuggerTuning
Which debugger to tune for.
unsigned IgnoreXCOFFVisibility
Do not emit visibility attribute for xcoff.
unsigned NoSignedZerosFPMath
NoSignedZerosFPMath - This flag is enabled when the -enable-no-signed-zeros-fp-math is specified on t...
unsigned EnableCFIFixup
Enable the CFIFixup pass.
unsigned DebugStrictDwarf
When set to true, don't use DWARF extensions in later DWARF versions.
unsigned SupportsDefaultOutlining
Set if the target supports default outlining behaviour.
unsigned PPCGenScalarMASSEntries
Enables scalar MASS conversions.
unsigned UniqueBasicBlockSectionNames
Use unique names for basic block sections.
bool FramePointerIsReserved(const MachineFunction &MF) const
FramePointerIsReserved - This returns true if the frame pointer must always either point to a new fra...
unsigned LoopAlignment
If greater than 0, override TargetLoweringBase::PrefLoopAlignment.
unsigned TLSSize
Bit size of immediate TLS offsets (0 == use the default).
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
unsigned UniqueSectionNames
unsigned NoNaNsFPMath
NoNaNsFPMath - This flag is enabled when the -enable-no-nans-fp-math flag is specified on the command...
unsigned EnableFastISel
EnableFastISel - This flag enables fast-path instruction selection which trades away generated code q...
std::shared_ptr< MemoryBuffer > BBSectionsFuncListBuf
Memory Buffer that contains information on sampled basic blocks and used to selectively generate basi...
unsigned FunctionSections
Emit functions into separate sections.
unsigned EnableMachineFunctionSplitter
Enables the MachineFunctionSplitter pass.
std::string StackUsageOutput
Name of the stack usage file (i.e., .su file) if user passes -fstack-usage.
unsigned EnableIPRA
This flag enables InterProcedural Register Allocation (IPRA).
unsigned NoTrapAfterNoreturn
Do not emit a trap instruction for 'unreachable' IR instructions behind noreturn calls,...
unsigned EnableGlobalISel
EnableGlobalISel - This flag enables global instruction selection.
unsigned DataSections
Emit data into separate sections.
unsigned GuaranteedTailCallOpt
GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is specified on the commandline.
ThreadModel::Model ThreadModel
ThreadModel - This flag specifies the type of threading model to assume for things like atomics.
unsigned TrapUnreachable
Emit target-specific trap instruction for 'unreachable' IR instructions.
unsigned EmulatedTLS
EmulatedTLS - This flag enables emulated TLS model, using emutls function in the runtime library.
unsigned EnableDebugEntryValues
When set to true, the EnableDebugEntryValues option forces production of debug entry values even if t...
unsigned XRayFunctionIndex
Emit XRay Function Index section.
unsigned NoTrappingFPMath
NoTrappingFPMath - This flag is enabled when the -enable-no-trapping-fp-math is specified on the comm...
unsigned DisableIntegratedAS
Disable the integrated assembler.
bool ShouldEmitDebugEntryValues() const
NOTE: There are targets that still do not support the debug entry values production.
ExceptionHandling ExceptionModel
What exception model to use.
unsigned JMCInstrument
Enable JustMyCode instrumentation.
FPOpFusion::FPOpFusionMode AllowFPOpFusion
AllowFPOpFusion - This flag is set by the -fp-contract=xxx option.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
CodeObjectVersionKind
Enumeration value for AMDGPU code object version, which is the code object version times 100.
@ COV_None
ExceptionHandling
@ None
No exception support.
SwiftAsyncFramePointerMode
Indicates when and how the Swift async frame pointer bit should be set.
@ Always
Always set the bit.
@ DeploymentBased
Determine whether to set the bit statically or dynamically based on the deployment target.
@ None
Definition: CodeGenData.h:106
BasicBlockSection
Definition: TargetOptions.h:61
DebuggerKind
Identify a debugger for "tuning" the debug info.
Definition: TargetOptions.h:94
@ SCE
Tune debug info for SCE targets (e.g. PS4).
@ DBX
Tune debug info for dbx.
@ Default
No specific tuning requested.
@ GDB
Tune debug info for gdb.
@ LLDB
Tune debug info for lldb.
@ Default
The result values are uniform if and only if all operands are uniform.
GlobalISelAbortMode
Enable abort calls when global instruction selection fails to lower/select an instruction.
@ Enable
Enable colors.
@ Disable
Disable colors.
Represent subnormal handling kind for floating point instruction inputs and outputs.