1 //===-- llvm/Target/TargetOptions.h - Target Options ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines command line option flags that are shared across various
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TARGET_TARGETOPTIONS_H
16 #define LLVM_TARGET_TARGETOPTIONS_H
18 #include "llvm/Target/TargetRecip.h"
19 #include "llvm/MC/MCTargetOptions.h"
20 #include "llvm/MC/MCAsmInfo.h"
23 class MachineFunction;
28 Default, // Target-specific (either soft or hard depending on triple, etc).
34 namespace FPOpFusion {
36 Fast, // Enable fusion of FP ops wherever it's profitable.
37 Standard, // Only allow fusion of 'blessed' ops (currently just fmuladd).
38 Strict // Never fuse FP-ops.
44 Single, // Use a single table for all indirect jumptable calls.
45 Arity, // Use one table per number of function parameters.
46 Simplified, // Use one table per function type, with types projected
47 // into 4 types: pointer to non-function, struct,
48 // primitive, and function pointer.
49 Full // Use one table per unique function type
53 namespace ThreadModel {
55 POSIX, // POSIX Threads
56 Single // Single Threaded Environment
62 Default, // Default means not specified
63 EABI4, // Target-specific (either 4, 5 or gnu depending on triple).
68 /// Identify a debugger for "tuning" the debug info.
70 /// The "debugger tuning" concept allows us to present a more intuitive
71 /// interface that unpacks into different sets of defaults for the various
72 /// individual feature-flag settings, that suit the preferences of the
73 /// various debuggers. However, it's worth remembering that debuggers are
74 /// not the only consumers of debug info, and some variations in DWARF might
75 /// better be treated as target/platform issues. Fundamentally,
76 /// o if the feature is useful (or not) to a particular debugger, regardless
77 /// of the target, that's a tuning decision;
78 /// o if the feature is useful (or not) on a particular platform, regardless
79 /// of the debugger, that's a target decision.
80 /// It's not impossible to see both factors in some specific case.
82 /// The "tuning" should be used to set defaults for individual feature flags
83 /// in DwarfDebug; if a given feature has a more specific command-line option,
84 /// that option should take precedence over the tuning.
85 enum class DebuggerKind {
86 Default, // No specific tuning requested.
87 GDB, // Tune debug info for gdb.
88 LLDB, // Tune debug info for lldb.
89 SCE // Tune debug info for SCE targets (e.g. PS4).
95 : PrintMachineCode(false), LessPreciseFPMADOption(false),
96 UnsafeFPMath(false), NoInfsFPMath(false), NoNaNsFPMath(false),
97 HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
98 GuaranteedTailCallOpt(false), StackAlignmentOverride(0),
99 StackSymbolOrdering(true), EnableFastISel(false), UseInitArray(false),
100 DisableIntegratedAS(false), CompressDebugSections(false),
101 RelaxELFRelocations(false), FunctionSections(false),
102 DataSections(false), UniqueSectionNames(true), TrapUnreachable(false),
103 EmulatedTLS(false), EnableIPRA(false),
104 FloatABIType(FloatABI::Default),
105 AllowFPOpFusion(FPOpFusion::Standard), Reciprocals(TargetRecip()),
106 JTType(JumpTable::Single), ThreadModel(ThreadModel::POSIX),
107 EABIVersion(EABI::Default), DebuggerTuning(DebuggerKind::Default),
108 ExceptionModel(ExceptionHandling::None) {}
110 /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
111 /// option is specified on the command line, and should enable debugging
112 /// output from the code generator.
113 unsigned PrintMachineCode : 1;
115 /// DisableFramePointerElim - This returns true if frame pointer elimination
116 /// optimization should be disabled for the given machine function.
117 bool DisableFramePointerElim(const MachineFunction &MF) const;
119 /// LessPreciseFPMAD - This flag is enabled when the
120 /// -enable-fp-mad is specified on the command line. When this flag is off
121 /// (the default), the code generator is not allowed to generate mad
122 /// (multiply add) if the result is "less precise" than doing those
123 /// operations individually.
124 unsigned LessPreciseFPMADOption : 1;
125 bool LessPreciseFPMAD() const;
127 /// UnsafeFPMath - This flag is enabled when the
128 /// -enable-unsafe-fp-math flag is specified on the command line. When
129 /// this flag is off (the default), the code generator is not allowed to
130 /// produce results that are "less precise" than IEEE allows. This includes
131 /// use of X86 instructions like FSIN and FCOS instead of libcalls.
132 /// UnsafeFPMath implies LessPreciseFPMAD.
133 unsigned UnsafeFPMath : 1;
135 /// NoInfsFPMath - This flag is enabled when the
136 /// -enable-no-infs-fp-math flag is specified on the command line. When
137 /// this flag is off (the default), the code generator is not allowed to
138 /// assume the FP arithmetic arguments and results are never +-Infs.
139 unsigned NoInfsFPMath : 1;
141 /// NoNaNsFPMath - This flag is enabled when the
142 /// -enable-no-nans-fp-math flag is specified on the command line. When
143 /// this flag is off (the default), the code generator is not allowed to
144 /// assume the FP arithmetic arguments and results are never NaNs.
145 unsigned NoNaNsFPMath : 1;
147 /// HonorSignDependentRoundingFPMath - This returns true when the
148 /// -enable-sign-dependent-rounding-fp-math is specified. If this returns
149 /// false (the default), the code generator is allowed to assume that the
150 /// rounding behavior is the default (round-to-zero for all floating point
151 /// to integer conversions, and round-to-nearest for all other arithmetic
152 /// truncations). If this is enabled (set to true), the code generator must
153 /// assume that the rounding mode may dynamically change.
154 unsigned HonorSignDependentRoundingFPMathOption : 1;
155 bool HonorSignDependentRoundingFPMath() const;
157 /// NoZerosInBSS - By default some codegens place zero-initialized data to
158 /// .bss section. This flag disables such behaviour (necessary, e.g. for
159 /// crt*.o compiling).
160 unsigned NoZerosInBSS : 1;
162 /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is
163 /// specified on the commandline. When the flag is on, participating targets
164 /// will perform tail call optimization on all calls which use the fastcc
165 /// calling convention and which satisfy certain target-independent
166 /// criteria (being at the end of a function, having the same return type
167 /// as their parent function, etc.), using an alternate ABI if necessary.
168 unsigned GuaranteedTailCallOpt : 1;
170 /// StackAlignmentOverride - Override default stack alignment for target.
171 unsigned StackAlignmentOverride;
173 /// StackSymbolOrdering - When true, this will allow CodeGen to order
174 /// the local stack symbols (for code size, code locality, or any other
175 /// heuristics). When false, the local symbols are left in whatever order
176 /// they were generated. Default is true.
177 unsigned StackSymbolOrdering : 1;
179 /// EnableFastISel - This flag enables fast-path instruction selection
180 /// which trades away generated code quality in favor of reducing
182 unsigned EnableFastISel : 1;
184 /// UseInitArray - Use .init_array instead of .ctors for static
186 unsigned UseInitArray : 1;
188 /// Disable the integrated assembler.
189 unsigned DisableIntegratedAS : 1;
191 /// Compress DWARF debug sections.
192 unsigned CompressDebugSections : 1;
194 unsigned RelaxELFRelocations : 1;
196 /// Emit functions into separate sections.
197 unsigned FunctionSections : 1;
199 /// Emit data into separate sections.
200 unsigned DataSections : 1;
202 unsigned UniqueSectionNames : 1;
204 /// Emit target-specific trap instruction for 'unreachable' IR instructions.
205 unsigned TrapUnreachable : 1;
207 /// EmulatedTLS - This flag enables emulated TLS model, using emutls
208 /// function in the runtime library..
209 unsigned EmulatedTLS : 1;
211 /// This flag enables InterProcedural Register Allocation (IPRA).
212 unsigned EnableIPRA : 1;
214 /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
215 /// on the command line. This setting may either be Default, Soft, or Hard.
216 /// Default selects the target's default behavior. Soft selects the ABI for
217 /// software floating point, but does not indicate that FP hardware may not
218 /// be used. Such a combination is unfortunately popular (e.g.
219 /// arm-apple-darwin). Hard presumes that the normal FP ABI is used.
220 FloatABI::ABIType FloatABIType;
222 /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
223 /// This controls the creation of fused FP ops that store intermediate
224 /// results in higher precision than IEEE allows (E.g. FMAs).
226 /// Fast mode - allows formation of fused FP ops whenever they're
228 /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
229 /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
231 /// Strict mode - allow fusion only if/when it can be proven that the excess
232 /// precision won't effect the result.
234 /// Note: This option only controls formation of fused ops by the
235 /// optimizers. Fused operations that are explicitly specified (e.g. FMA
236 /// via the llvm.fma.* intrinsic) will always be honored, regardless of
237 /// the value of this option.
238 FPOpFusion::FPOpFusionMode AllowFPOpFusion;
240 /// This class encapsulates options for reciprocal-estimate code generation.
241 TargetRecip Reciprocals;
243 /// JTType - This flag specifies the type of jump-instruction table to
244 /// create for functions that have the jumptable attribute.
245 JumpTable::JumpTableType JTType;
247 /// ThreadModel - This flag specifies the type of threading model to assume
248 /// for things like atomics
249 ThreadModel::Model ThreadModel;
251 /// EABIVersion - This flag specifies the EABI version
254 /// Which debugger to tune for.
255 DebuggerKind DebuggerTuning;
257 /// What exception model to use
258 ExceptionHandling ExceptionModel;
260 /// Machine level options.
261 MCTargetOptions MCOptions;
264 // Comparison operators:
267 inline bool operator==(const TargetOptions &LHS,
268 const TargetOptions &RHS) {
269 #define ARE_EQUAL(X) LHS.X == RHS.X
271 ARE_EQUAL(UnsafeFPMath) &&
272 ARE_EQUAL(NoInfsFPMath) &&
273 ARE_EQUAL(NoNaNsFPMath) &&
274 ARE_EQUAL(HonorSignDependentRoundingFPMathOption) &&
275 ARE_EQUAL(NoZerosInBSS) &&
276 ARE_EQUAL(GuaranteedTailCallOpt) &&
277 ARE_EQUAL(StackAlignmentOverride) &&
278 ARE_EQUAL(EnableFastISel) &&
279 ARE_EQUAL(UseInitArray) &&
280 ARE_EQUAL(TrapUnreachable) &&
281 ARE_EQUAL(EmulatedTLS) &&
282 ARE_EQUAL(FloatABIType) &&
283 ARE_EQUAL(AllowFPOpFusion) &&
284 ARE_EQUAL(Reciprocals) &&
286 ARE_EQUAL(ThreadModel) &&
287 ARE_EQUAL(EABIVersion) &&
288 ARE_EQUAL(DebuggerTuning) &&
289 ARE_EQUAL(ExceptionModel) &&
290 ARE_EQUAL(MCOptions) &&
291 ARE_EQUAL(EnableIPRA);
295 inline bool operator!=(const TargetOptions &LHS,
296 const TargetOptions &RHS) {
297 return !(LHS == RHS);
300 } // End llvm namespace