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