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