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"
23 class MachineFunction;
29 Default, // Target-specific (either soft or hard depending on triple, etc).
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.
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
54 namespace ThreadModel {
56 POSIX, // POSIX Threads
57 Single // Single Threaded Environment
63 Default, // Default means not specified
64 EABI4, // Target-specific (either 4, 5 or gnu depending on triple).
72 : PrintMachineCode(false), LessPreciseFPMADOption(false),
73 UnsafeFPMath(false), NoInfsFPMath(false), NoNaNsFPMath(false),
74 HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
75 GuaranteedTailCallOpt(false), StackAlignmentOverride(0),
76 EnableFastISel(false), PositionIndependentExecutable(false),
77 UseInitArray(false), DisableIntegratedAS(false),
78 CompressDebugSections(false), FunctionSections(false),
79 DataSections(false), UniqueSectionNames(true), TrapUnreachable(false),
80 EmulatedTLS(false), FloatABIType(FloatABI::Default),
81 AllowFPOpFusion(FPOpFusion::Standard), Reciprocals(TargetRecip()),
82 JTType(JumpTable::Single), ThreadModel(ThreadModel::POSIX),
83 EABIVersion(EABI::Default) {}
85 /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
86 /// option is specified on the command line, and should enable debugging
87 /// output from the code generator.
88 unsigned PrintMachineCode : 1;
90 /// DisableFramePointerElim - This returns true if frame pointer elimination
91 /// optimization should be disabled for the given machine function.
92 bool DisableFramePointerElim(const MachineFunction &MF) const;
94 /// LessPreciseFPMAD - This flag is enabled when the
95 /// -enable-fp-mad is specified on the command line. When this flag is off
96 /// (the default), the code generator is not allowed to generate mad
97 /// (multiply add) if the result is "less precise" than doing those
98 /// operations individually.
99 unsigned LessPreciseFPMADOption : 1;
100 bool LessPreciseFPMAD() const;
102 /// UnsafeFPMath - This flag is enabled when the
103 /// -enable-unsafe-fp-math flag is specified on the command line. When
104 /// this flag is off (the default), the code generator is not allowed to
105 /// produce results that are "less precise" than IEEE allows. This includes
106 /// use of X86 instructions like FSIN and FCOS instead of libcalls.
107 /// UnsafeFPMath implies LessPreciseFPMAD.
108 unsigned UnsafeFPMath : 1;
110 /// NoInfsFPMath - This flag is enabled when the
111 /// -enable-no-infs-fp-math flag is specified on the command line. When
112 /// this flag is off (the default), the code generator is not allowed to
113 /// assume the FP arithmetic arguments and results are never +-Infs.
114 unsigned NoInfsFPMath : 1;
116 /// NoNaNsFPMath - This flag is enabled when the
117 /// -enable-no-nans-fp-math flag is specified on the command line. When
118 /// this flag is off (the default), the code generator is not allowed to
119 /// assume the FP arithmetic arguments and results are never NaNs.
120 unsigned NoNaNsFPMath : 1;
122 /// HonorSignDependentRoundingFPMath - This returns true when the
123 /// -enable-sign-dependent-rounding-fp-math is specified. If this returns
124 /// false (the default), the code generator is allowed to assume that the
125 /// rounding behavior is the default (round-to-zero for all floating point
126 /// to integer conversions, and round-to-nearest for all other arithmetic
127 /// truncations). If this is enabled (set to true), the code generator must
128 /// assume that the rounding mode may dynamically change.
129 unsigned HonorSignDependentRoundingFPMathOption : 1;
130 bool HonorSignDependentRoundingFPMath() const;
132 /// NoZerosInBSS - By default some codegens place zero-initialized data to
133 /// .bss section. This flag disables such behaviour (necessary, e.g. for
134 /// crt*.o compiling).
135 unsigned NoZerosInBSS : 1;
137 /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is
138 /// specified on the commandline. When the flag is on, participating targets
139 /// will perform tail call optimization on all calls which use the fastcc
140 /// calling convention and which satisfy certain target-independent
141 /// criteria (being at the end of a function, having the same return type
142 /// as their parent function, etc.), using an alternate ABI if necessary.
143 unsigned GuaranteedTailCallOpt : 1;
145 /// StackAlignmentOverride - Override default stack alignment for target.
146 unsigned StackAlignmentOverride;
148 /// EnableFastISel - This flag enables fast-path instruction selection
149 /// which trades away generated code quality in favor of reducing
151 unsigned EnableFastISel : 1;
153 /// PositionIndependentExecutable - This flag indicates whether the code
154 /// will eventually be linked into a single executable, despite the PIC
155 /// relocation model being in use. It's value is undefined (and irrelevant)
156 /// if the relocation model is anything other than PIC.
157 unsigned PositionIndependentExecutable : 1;
159 /// UseInitArray - Use .init_array instead of .ctors for static
161 unsigned UseInitArray : 1;
163 /// Disable the integrated assembler.
164 unsigned DisableIntegratedAS : 1;
166 /// Compress DWARF debug sections.
167 unsigned CompressDebugSections : 1;
169 /// Emit functions into separate sections.
170 unsigned FunctionSections : 1;
172 /// Emit data into separate sections.
173 unsigned DataSections : 1;
175 unsigned UniqueSectionNames : 1;
177 /// Emit target-specific trap instruction for 'unreachable' IR instructions.
178 unsigned TrapUnreachable : 1;
180 /// EmulatedTLS - This flag enables emulated TLS model, using emutls
181 /// function in the runtime library..
182 unsigned EmulatedTLS : 1;
184 /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
185 /// on the command line. This setting may either be Default, Soft, or Hard.
186 /// Default selects the target's default behavior. Soft selects the ABI for
187 /// software floating point, but does not indicate that FP hardware may not
188 /// be used. Such a combination is unfortunately popular (e.g.
189 /// arm-apple-darwin). Hard presumes that the normal FP ABI is used.
190 FloatABI::ABIType FloatABIType;
192 /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
193 /// This controls the creation of fused FP ops that store intermediate
194 /// results in higher precision than IEEE allows (E.g. FMAs).
196 /// Fast mode - allows formation of fused FP ops whenever they're
198 /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
199 /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
201 /// Strict mode - allow fusion only if/when it can be proven that the excess
202 /// precision won't effect the result.
204 /// Note: This option only controls formation of fused ops by the
205 /// optimizers. Fused operations that are explicitly specified (e.g. FMA
206 /// via the llvm.fma.* intrinsic) will always be honored, regardless of
207 /// the value of this option.
208 FPOpFusion::FPOpFusionMode AllowFPOpFusion;
210 /// This class encapsulates options for reciprocal-estimate code generation.
211 TargetRecip Reciprocals;
213 /// JTType - This flag specifies the type of jump-instruction table to
214 /// create for functions that have the jumptable attribute.
215 JumpTable::JumpTableType JTType;
217 /// ThreadModel - This flag specifies the type of threading model to assume
218 /// for things like atomics
219 ThreadModel::Model ThreadModel;
221 /// EABIVersion - This flag specifies the EABI version
224 /// Machine level options.
225 MCTargetOptions MCOptions;
228 // Comparison operators:
231 inline bool operator==(const TargetOptions &LHS,
232 const TargetOptions &RHS) {
233 #define ARE_EQUAL(X) LHS.X == RHS.X
235 ARE_EQUAL(UnsafeFPMath) &&
236 ARE_EQUAL(NoInfsFPMath) &&
237 ARE_EQUAL(NoNaNsFPMath) &&
238 ARE_EQUAL(HonorSignDependentRoundingFPMathOption) &&
239 ARE_EQUAL(NoZerosInBSS) &&
240 ARE_EQUAL(GuaranteedTailCallOpt) &&
241 ARE_EQUAL(StackAlignmentOverride) &&
242 ARE_EQUAL(EnableFastISel) &&
243 ARE_EQUAL(PositionIndependentExecutable) &&
244 ARE_EQUAL(UseInitArray) &&
245 ARE_EQUAL(TrapUnreachable) &&
246 ARE_EQUAL(EmulatedTLS) &&
247 ARE_EQUAL(FloatABIType) &&
248 ARE_EQUAL(AllowFPOpFusion) &&
249 ARE_EQUAL(Reciprocals) &&
251 ARE_EQUAL(ThreadModel) &&
252 ARE_EQUAL(EABIVersion) &&
253 ARE_EQUAL(MCOptions);
257 inline bool operator!=(const TargetOptions &LHS,
258 const TargetOptions &RHS) {
259 return !(LHS == RHS);
262 } // End llvm namespace