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