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
64 : PrintMachineCode(false),
65 LessPreciseFPMADOption(false), UnsafeFPMath(false),
66 NoInfsFPMath(false), NoNaNsFPMath(false),
67 HonorSignDependentRoundingFPMathOption(false),
69 GuaranteedTailCallOpt(false),
70 DisableTailCalls(false), StackAlignmentOverride(0),
71 EnableFastISel(false), PositionIndependentExecutable(false),
72 UseInitArray(false), DisableIntegratedAS(false),
73 CompressDebugSections(false), FunctionSections(false),
74 DataSections(false), UniqueSectionNames(true), TrapUnreachable(false),
75 TrapFuncName(), FloatABIType(FloatABI::Default),
76 AllowFPOpFusion(FPOpFusion::Standard), Reciprocals(TargetRecip()),
77 JTType(JumpTable::Single),
78 ThreadModel(ThreadModel::POSIX) {}
80 /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
81 /// option is specified on the command line, and should enable debugging
82 /// output from the code generator.
83 unsigned PrintMachineCode : 1;
85 /// DisableFramePointerElim - This returns true if frame pointer elimination
86 /// optimization should be disabled for the given machine function.
87 bool DisableFramePointerElim(const MachineFunction &MF) const;
89 /// LessPreciseFPMAD - This flag is enabled when the
90 /// -enable-fp-mad is specified on the command line. When this flag is off
91 /// (the default), the code generator is not allowed to generate mad
92 /// (multiply add) if the result is "less precise" than doing those
93 /// operations individually.
94 unsigned LessPreciseFPMADOption : 1;
95 bool LessPreciseFPMAD() const;
97 /// UnsafeFPMath - This flag is enabled when the
98 /// -enable-unsafe-fp-math flag is specified on the command line. When
99 /// this flag is off (the default), the code generator is not allowed to
100 /// produce results that are "less precise" than IEEE allows. This includes
101 /// use of X86 instructions like FSIN and FCOS instead of libcalls.
102 /// UnsafeFPMath implies LessPreciseFPMAD.
103 unsigned UnsafeFPMath : 1;
105 /// NoInfsFPMath - This flag is enabled when the
106 /// -enable-no-infs-fp-math flag is specified on the command line. When
107 /// this flag is off (the default), the code generator is not allowed to
108 /// assume the FP arithmetic arguments and results are never +-Infs.
109 unsigned NoInfsFPMath : 1;
111 /// NoNaNsFPMath - This flag is enabled when the
112 /// -enable-no-nans-fp-math flag is specified on the command line. When
113 /// this flag is off (the default), the code generator is not allowed to
114 /// assume the FP arithmetic arguments and results are never NaNs.
115 unsigned NoNaNsFPMath : 1;
117 /// HonorSignDependentRoundingFPMath - This returns true when the
118 /// -enable-sign-dependent-rounding-fp-math is specified. If this returns
119 /// false (the default), the code generator is allowed to assume that the
120 /// rounding behavior is the default (round-to-zero for all floating point
121 /// to integer conversions, and round-to-nearest for all other arithmetic
122 /// truncations). If this is enabled (set to true), the code generator must
123 /// assume that the rounding mode may dynamically change.
124 unsigned HonorSignDependentRoundingFPMathOption : 1;
125 bool HonorSignDependentRoundingFPMath() const;
127 /// NoZerosInBSS - By default some codegens place zero-initialized data to
128 /// .bss section. This flag disables such behaviour (necessary, e.g. for
129 /// crt*.o compiling).
130 unsigned NoZerosInBSS : 1;
132 /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is
133 /// specified on the commandline. When the flag is on, participating targets
134 /// will perform tail call optimization on all calls which use the fastcc
135 /// calling convention and which satisfy certain target-independent
136 /// criteria (being at the end of a function, having the same return type
137 /// as their parent function, etc.), using an alternate ABI if necessary.
138 unsigned GuaranteedTailCallOpt : 1;
140 /// DisableTailCalls - This flag controls whether we will use tail calls.
141 /// Disabling them may be useful to maintain a correct call stack.
142 unsigned DisableTailCalls : 1;
144 /// StackAlignmentOverride - Override default stack alignment for target.
145 unsigned StackAlignmentOverride;
147 /// EnableFastISel - This flag enables fast-path instruction selection
148 /// which trades away generated code quality in favor of reducing
150 unsigned EnableFastISel : 1;
152 /// PositionIndependentExecutable - This flag indicates whether the code
153 /// will eventually be linked into a single executable, despite the PIC
154 /// relocation model being in use. It's value is undefined (and irrelevant)
155 /// if the relocation model is anything other than PIC.
156 unsigned PositionIndependentExecutable : 1;
158 /// UseInitArray - Use .init_array instead of .ctors for static
160 unsigned UseInitArray : 1;
162 /// Disable the integrated assembler.
163 unsigned DisableIntegratedAS : 1;
165 /// Compress DWARF debug sections.
166 unsigned CompressDebugSections : 1;
168 /// Emit functions into separate sections.
169 unsigned FunctionSections : 1;
171 /// Emit data into separate sections.
172 unsigned DataSections : 1;
174 unsigned UniqueSectionNames : 1;
176 /// Emit target-specific trap instruction for 'unreachable' IR instructions.
177 unsigned TrapUnreachable : 1;
179 /// getTrapFunctionName - If this returns a non-empty string, this means
180 /// isel should lower Intrinsic::trap to a call to the specified function
181 /// name instead of an ISD::TRAP node.
182 std::string TrapFuncName;
183 StringRef getTrapFunctionName() const;
185 /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
186 /// on the command line. This setting may either be Default, Soft, or Hard.
187 /// Default selects the target's default behavior. Soft selects the ABI for
188 /// software floating point, but does not indicate that FP hardware may not
189 /// be used. Such a combination is unfortunately popular (e.g.
190 /// arm-apple-darwin). Hard presumes that the normal FP ABI is used.
191 FloatABI::ABIType FloatABIType;
193 /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
194 /// This controls the creation of fused FP ops that store intermediate
195 /// results in higher precision than IEEE allows (E.g. FMAs).
197 /// Fast mode - allows formation of fused FP ops whenever they're
199 /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
200 /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
202 /// Strict mode - allow fusion only if/when it can be proven that the excess
203 /// precision won't effect the result.
205 /// Note: This option only controls formation of fused ops by the
206 /// optimizers. Fused operations that are explicitly specified (e.g. FMA
207 /// via the llvm.fma.* intrinsic) will always be honored, regardless of
208 /// the value of this option.
209 FPOpFusion::FPOpFusionMode AllowFPOpFusion;
211 /// This class encapsulates options for reciprocal-estimate code generation.
212 TargetRecip Reciprocals;
214 /// JTType - This flag specifies the type of jump-instruction table to
215 /// create for functions that have the jumptable attribute.
216 JumpTable::JumpTableType JTType;
218 /// ThreadModel - This flag specifies the type of threading model to assume
219 /// for things like atomics
220 ThreadModel::Model ThreadModel;
222 /// Machine level options.
223 MCTargetOptions MCOptions;
226 // Comparison operators:
229 inline bool operator==(const TargetOptions &LHS,
230 const TargetOptions &RHS) {
231 #define ARE_EQUAL(X) LHS.X == RHS.X
233 ARE_EQUAL(UnsafeFPMath) &&
234 ARE_EQUAL(NoInfsFPMath) &&
235 ARE_EQUAL(NoNaNsFPMath) &&
236 ARE_EQUAL(HonorSignDependentRoundingFPMathOption) &&
237 ARE_EQUAL(NoZerosInBSS) &&
238 ARE_EQUAL(GuaranteedTailCallOpt) &&
239 ARE_EQUAL(DisableTailCalls) &&
240 ARE_EQUAL(StackAlignmentOverride) &&
241 ARE_EQUAL(EnableFastISel) &&
242 ARE_EQUAL(PositionIndependentExecutable) &&
243 ARE_EQUAL(UseInitArray) &&
244 ARE_EQUAL(TrapUnreachable) &&
245 ARE_EQUAL(TrapFuncName) &&
246 ARE_EQUAL(FloatABIType) &&
247 ARE_EQUAL(AllowFPOpFusion) &&
248 ARE_EQUAL(Reciprocals) &&
250 ARE_EQUAL(ThreadModel) &&
251 ARE_EQUAL(MCOptions);
255 inline bool operator!=(const TargetOptions &LHS,
256 const TargetOptions &RHS) {
257 return !(LHS == RHS);
260 } // End llvm namespace