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