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
21 class MachineFunction;
24 // Possible float ABI settings. Used with FloatABIType in TargetOptions.h.
27 Default, // Target-specific (either soft or hard depending on triple,etc).
33 namespace FPOpFusion {
35 Fast, // Enable fusion of FP ops wherever it's profitable.
36 Standard, // Only allow fusion of 'blessed' ops (currently just fmuladd).
37 Strict // Never fuse FP-ops.
44 : PrintMachineCode(false), NoFramePointerElim(false),
45 LessPreciseFPMADOption(false), UnsafeFPMath(false),
46 NoInfsFPMath(false), NoNaNsFPMath(false),
47 HonorSignDependentRoundingFPMathOption(false), UseSoftFloat(false),
48 NoZerosInBSS(false), JITEmitDebugInfo(false),
49 JITEmitDebugInfoToDisk(false), GuaranteedTailCallOpt(false),
50 DisableTailCalls(false), StackAlignmentOverride(0),
51 EnableFastISel(false), PositionIndependentExecutable(false),
53 DisableIntegratedAS(false), CompressDebugSections(false),
54 TrapUnreachable(false),
55 TrapFuncName(""), FloatABIType(FloatABI::Default),
56 AllowFPOpFusion(FPOpFusion::Standard) {}
58 /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
59 /// option is specified on the command line, and should enable debugging
60 /// output from the code generator.
61 unsigned PrintMachineCode : 1;
63 /// NoFramePointerElim - This flag is enabled when the -disable-fp-elim is
64 /// specified on the command line. If the target supports the frame pointer
65 /// elimination optimization, this option should disable it.
66 unsigned NoFramePointerElim : 1;
68 /// DisableFramePointerElim - This returns true if frame pointer elimination
69 /// optimization should be disabled for the given machine function.
70 bool DisableFramePointerElim(const MachineFunction &MF) const;
72 /// LessPreciseFPMAD - This flag is enabled when the
73 /// -enable-fp-mad is specified on the command line. When this flag is off
74 /// (the default), the code generator is not allowed to generate mad
75 /// (multiply add) if the result is "less precise" than doing those
76 /// operations individually.
77 unsigned LessPreciseFPMADOption : 1;
78 bool LessPreciseFPMAD() const;
80 /// UnsafeFPMath - This flag is enabled when the
81 /// -enable-unsafe-fp-math flag is specified on the command line. When
82 /// this flag is off (the default), the code generator is not allowed to
83 /// produce results that are "less precise" than IEEE allows. This includes
84 /// use of X86 instructions like FSIN and FCOS instead of libcalls.
85 /// UnsafeFPMath implies LessPreciseFPMAD.
86 unsigned UnsafeFPMath : 1;
88 /// NoInfsFPMath - This flag is enabled when the
89 /// -enable-no-infs-fp-math flag is specified on the command line. When
90 /// this flag is off (the default), the code generator is not allowed to
91 /// assume the FP arithmetic arguments and results are never +-Infs.
92 unsigned NoInfsFPMath : 1;
94 /// NoNaNsFPMath - This flag is enabled when the
95 /// -enable-no-nans-fp-math flag is specified on the command line. When
96 /// this flag is off (the default), the code generator is not allowed to
97 /// assume the FP arithmetic arguments and results are never NaNs.
98 unsigned NoNaNsFPMath : 1;
100 /// HonorSignDependentRoundingFPMath - This returns true when the
101 /// -enable-sign-dependent-rounding-fp-math is specified. If this returns
102 /// false (the default), the code generator is allowed to assume that the
103 /// rounding behavior is the default (round-to-zero for all floating point
104 /// to integer conversions, and round-to-nearest for all other arithmetic
105 /// truncations). If this is enabled (set to true), the code generator must
106 /// assume that the rounding mode may dynamically change.
107 unsigned HonorSignDependentRoundingFPMathOption : 1;
108 bool HonorSignDependentRoundingFPMath() const;
110 /// UseSoftFloat - This flag is enabled when the -soft-float flag is
111 /// specified on the command line. When this flag is on, the code generator
112 /// will generate libcalls to the software floating point library instead of
113 /// target FP instructions.
114 unsigned UseSoftFloat : 1;
116 /// NoZerosInBSS - By default some codegens place zero-initialized data to
117 /// .bss section. This flag disables such behaviour (necessary, e.g. for
118 /// crt*.o compiling).
119 unsigned NoZerosInBSS : 1;
121 /// JITEmitDebugInfo - This flag indicates that the JIT should try to emit
122 /// debug information and notify a debugger about it.
123 unsigned JITEmitDebugInfo : 1;
125 /// JITEmitDebugInfoToDisk - This flag indicates that the JIT should write
126 /// the object files generated by the JITEmitDebugInfo flag to disk. This
127 /// flag is hidden and is only for debugging the debug info.
128 unsigned JITEmitDebugInfoToDisk : 1;
130 /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is
131 /// specified on the commandline. When the flag is on, participating targets
132 /// will perform tail call optimization on all calls which use the fastcc
133 /// calling convention and which satisfy certain target-independent
134 /// criteria (being at the end of a function, having the same return type
135 /// as their parent function, etc.), using an alternate ABI if necessary.
136 unsigned GuaranteedTailCallOpt : 1;
138 /// DisableTailCalls - This flag controls whether we will use tail calls.
139 /// Disabling them may be useful to maintain a correct call stack.
140 unsigned DisableTailCalls : 1;
142 /// StackAlignmentOverride - Override default stack alignment for target.
143 unsigned StackAlignmentOverride;
145 /// EnableFastISel - This flag enables fast-path instruction selection
146 /// which trades away generated code quality in favor of reducing
148 unsigned EnableFastISel : 1;
150 /// PositionIndependentExecutable - This flag indicates whether the code
151 /// will eventually be linked into a single executable, despite the PIC
152 /// relocation model being in use. It's value is undefined (and irrelevant)
153 /// if the relocation model is anything other than PIC.
154 unsigned PositionIndependentExecutable : 1;
156 /// UseInitArray - Use .init_array instead of .ctors for static
158 unsigned UseInitArray : 1;
160 /// Disable the integrated assembler.
161 unsigned DisableIntegratedAS : 1;
163 /// Compress DWARF debug sections.
164 unsigned CompressDebugSections : 1;
166 /// Emit target-specific trap instruction for 'unreachable' IR instructions.
167 unsigned TrapUnreachable : 1;
169 /// getTrapFunctionName - If this returns a non-empty string, this means
170 /// isel should lower Intrinsic::trap to a call to the specified function
171 /// name instead of an ISD::TRAP node.
172 std::string TrapFuncName;
173 StringRef getTrapFunctionName() const;
175 /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
176 /// on the command line. This setting may either be Default, Soft, or Hard.
177 /// Default selects the target's default behavior. Soft selects the ABI for
178 /// UseSoftFloat, but does not indicate that FP hardware may not be used.
179 /// Such a combination is unfortunately popular (e.g. arm-apple-darwin).
180 /// Hard presumes that the normal FP ABI is used.
181 FloatABI::ABIType FloatABIType;
183 /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
184 /// This controls the creation of fused FP ops that store intermediate
185 /// results in higher precision than IEEE allows (E.g. FMAs).
187 /// Fast mode - allows formation of fused FP ops whenever they're
189 /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
190 /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
192 /// Strict mode - allow fusion only if/when it can be proven that the excess
193 /// precision won't effect the result.
195 /// Note: This option only controls formation of fused ops by the
196 /// optimizers. Fused operations that are explicitly specified (e.g. FMA
197 /// via the llvm.fma.* intrinsic) will always be honored, regardless of
198 /// the value of this option.
199 FPOpFusion::FPOpFusionMode AllowFPOpFusion;
202 // Comparison operators:
205 inline bool operator==(const TargetOptions &LHS,
206 const TargetOptions &RHS) {
207 #define ARE_EQUAL(X) LHS.X == RHS.X
209 ARE_EQUAL(UnsafeFPMath) &&
210 ARE_EQUAL(NoInfsFPMath) &&
211 ARE_EQUAL(NoNaNsFPMath) &&
212 ARE_EQUAL(HonorSignDependentRoundingFPMathOption) &&
213 ARE_EQUAL(UseSoftFloat) &&
214 ARE_EQUAL(NoZerosInBSS) &&
215 ARE_EQUAL(JITEmitDebugInfo) &&
216 ARE_EQUAL(JITEmitDebugInfoToDisk) &&
217 ARE_EQUAL(GuaranteedTailCallOpt) &&
218 ARE_EQUAL(DisableTailCalls) &&
219 ARE_EQUAL(StackAlignmentOverride) &&
220 ARE_EQUAL(EnableFastISel) &&
221 ARE_EQUAL(PositionIndependentExecutable) &&
222 ARE_EQUAL(UseInitArray) &&
223 ARE_EQUAL(TrapUnreachable) &&
224 ARE_EQUAL(TrapFuncName) &&
225 ARE_EQUAL(FloatABIType) &&
226 ARE_EQUAL(AllowFPOpFusion);
230 inline bool operator!=(const TargetOptions &LHS,
231 const TargetOptions &RHS) {
232 return !(LHS == RHS);
235 } // End llvm namespace