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),
67 NoZerosInBSS(false), JITEmitDebugInfo(false),
68 JITEmitDebugInfoToDisk(false), 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), TrapUnreachable(false), TrapFuncName(""),
74 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 /// JITEmitDebugInfo - This flag indicates that the JIT should try to emit
142 /// debug information and notify a debugger about it.
143 unsigned JITEmitDebugInfo : 1;
145 /// JITEmitDebugInfoToDisk - This flag indicates that the JIT should write
146 /// the object files generated by the JITEmitDebugInfo flag to disk. This
147 /// flag is hidden and is only for debugging the debug info.
148 unsigned JITEmitDebugInfoToDisk : 1;
150 /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is
151 /// specified on the commandline. When the flag is on, participating targets
152 /// will perform tail call optimization on all calls which use the fastcc
153 /// calling convention and which satisfy certain target-independent
154 /// criteria (being at the end of a function, having the same return type
155 /// as their parent function, etc.), using an alternate ABI if necessary.
156 unsigned GuaranteedTailCallOpt : 1;
158 /// DisableTailCalls - This flag controls whether we will use tail calls.
159 /// Disabling them may be useful to maintain a correct call stack.
160 unsigned DisableTailCalls : 1;
162 /// StackAlignmentOverride - Override default stack alignment for target.
163 unsigned StackAlignmentOverride;
165 /// EnableFastISel - This flag enables fast-path instruction selection
166 /// which trades away generated code quality in favor of reducing
168 unsigned EnableFastISel : 1;
170 /// PositionIndependentExecutable - This flag indicates whether the code
171 /// will eventually be linked into a single executable, despite the PIC
172 /// relocation model being in use. It's value is undefined (and irrelevant)
173 /// if the relocation model is anything other than PIC.
174 unsigned PositionIndependentExecutable : 1;
176 /// UseInitArray - Use .init_array instead of .ctors for static
178 unsigned UseInitArray : 1;
180 /// Disable the integrated assembler.
181 unsigned DisableIntegratedAS : 1;
183 /// Compress DWARF debug sections.
184 unsigned CompressDebugSections : 1;
186 /// Emit functions into separate sections.
187 unsigned FunctionSections : 1;
189 /// Emit data into separate sections.
190 unsigned DataSections : 1;
192 /// Emit target-specific trap instruction for 'unreachable' IR instructions.
193 unsigned TrapUnreachable : 1;
195 /// getTrapFunctionName - If this returns a non-empty string, this means
196 /// isel should lower Intrinsic::trap to a call to the specified function
197 /// name instead of an ISD::TRAP node.
198 std::string TrapFuncName;
199 StringRef getTrapFunctionName() const;
201 /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
202 /// on the command line. This setting may either be Default, Soft, or Hard.
203 /// Default selects the target's default behavior. Soft selects the ABI for
204 /// UseSoftFloat, but does not indicate that FP hardware may not be used.
205 /// Such a combination is unfortunately popular (e.g. arm-apple-darwin).
206 /// Hard presumes that the normal FP ABI is used.
207 FloatABI::ABIType FloatABIType;
209 /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
210 /// This controls the creation of fused FP ops that store intermediate
211 /// results in higher precision than IEEE allows (E.g. FMAs).
213 /// Fast mode - allows formation of fused FP ops whenever they're
215 /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
216 /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
218 /// Strict mode - allow fusion only if/when it can be proven that the excess
219 /// precision won't effect the result.
221 /// Note: This option only controls formation of fused ops by the
222 /// optimizers. Fused operations that are explicitly specified (e.g. FMA
223 /// via the llvm.fma.* intrinsic) will always be honored, regardless of
224 /// the value of this option.
225 FPOpFusion::FPOpFusionMode AllowFPOpFusion;
227 /// JTType - This flag specifies the type of jump-instruction table to
228 /// create for functions that have the jumptable attribute.
229 JumpTable::JumpTableType JTType;
231 /// ThreadModel - This flag specifies the type of threading model to assume
232 /// for things like atomics
233 ThreadModel::Model ThreadModel;
235 /// Machine level options.
236 MCTargetOptions MCOptions;
239 // Comparison operators:
242 inline bool operator==(const TargetOptions &LHS,
243 const TargetOptions &RHS) {
244 #define ARE_EQUAL(X) LHS.X == RHS.X
246 ARE_EQUAL(UnsafeFPMath) &&
247 ARE_EQUAL(NoInfsFPMath) &&
248 ARE_EQUAL(NoNaNsFPMath) &&
249 ARE_EQUAL(HonorSignDependentRoundingFPMathOption) &&
250 ARE_EQUAL(UseSoftFloat) &&
251 ARE_EQUAL(NoZerosInBSS) &&
252 ARE_EQUAL(JITEmitDebugInfo) &&
253 ARE_EQUAL(JITEmitDebugInfoToDisk) &&
254 ARE_EQUAL(GuaranteedTailCallOpt) &&
255 ARE_EQUAL(DisableTailCalls) &&
256 ARE_EQUAL(StackAlignmentOverride) &&
257 ARE_EQUAL(EnableFastISel) &&
258 ARE_EQUAL(PositionIndependentExecutable) &&
259 ARE_EQUAL(UseInitArray) &&
260 ARE_EQUAL(TrapUnreachable) &&
261 ARE_EQUAL(TrapFuncName) &&
262 ARE_EQUAL(FloatABIType) &&
263 ARE_EQUAL(AllowFPOpFusion) &&
264 ARE_EQUAL(MCOptions);
268 inline bool operator!=(const TargetOptions &LHS,
269 const TargetOptions &RHS) {
270 return !(LHS == RHS);
273 } // End llvm namespace