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