Remove the CFIEnforcing flag from TargetOptions as it is unused.
[oota-llvm.git] / include / llvm / Target / TargetOptions.h
1 //===-- llvm/Target/TargetOptions.h - Target Options ------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines command line option flags that are shared across various
11 // targets.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_TARGET_TARGETOPTIONS_H
16 #define LLVM_TARGET_TARGETOPTIONS_H
17
18 #include "llvm/MC/MCTargetOptions.h"
19 #include <string>
20
21 namespace llvm {
22   class MachineFunction;
23   class StringRef;
24
25   // Possible float ABI settings. Used with FloatABIType in TargetOptions.h.
26   namespace FloatABI {
27     enum ABIType {
28       Default, // Target-specific (either soft or hard depending on triple,etc).
29       Soft, // Soft float.
30       Hard  // Hard float.
31     };
32   }
33
34   namespace FPOpFusion {
35     enum FPOpFusionMode {
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.
39     };
40   }
41
42   namespace JumpTable {
43     enum JumpTableType {
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
50     };
51   }
52
53   namespace ThreadModel {
54     enum Model {
55       POSIX,  // POSIX Threads
56       Single  // Single Threaded Environment
57     };
58   }
59
60   class TargetOptions {
61   public:
62     TargetOptions()
63         : PrintMachineCode(false), NoFramePointerElim(false),
64           LessPreciseFPMADOption(false), UnsafeFPMath(false),
65           NoInfsFPMath(false), NoNaNsFPMath(false),
66           HonorSignDependentRoundingFPMathOption(false), UseSoftFloat(false),
67           NoZerosInBSS(false),
68           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), UniqueSectionNames(true), TrapUnreachable(false),
74           TrapFuncName(), FloatABIType(FloatABI::Default),
75           AllowFPOpFusion(FPOpFusion::Standard), JTType(JumpTable::Single),
76           FCFI(false), ThreadModel(ThreadModel::POSIX),
77           CFIFuncName() {}
78
79     /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
80     /// option is specified on the command line, and should enable debugging
81     /// output from the code generator.
82     unsigned PrintMachineCode : 1;
83
84     /// NoFramePointerElim - This flag is enabled when the -disable-fp-elim is
85     /// specified on the command line.  If the target supports the frame pointer
86     /// elimination optimization, this option should disable it.
87     unsigned NoFramePointerElim : 1;
88
89     /// DisableFramePointerElim - This returns true if frame pointer elimination
90     /// optimization should be disabled for the given machine function.
91     bool DisableFramePointerElim(const MachineFunction &MF) const;
92
93     /// LessPreciseFPMAD - This flag is enabled when the
94     /// -enable-fp-mad is specified on the command line.  When this flag is off
95     /// (the default), the code generator is not allowed to generate mad
96     /// (multiply add) if the result is "less precise" than doing those
97     /// operations individually.
98     unsigned LessPreciseFPMADOption : 1;
99     bool LessPreciseFPMAD() const;
100
101     /// UnsafeFPMath - This flag is enabled when the
102     /// -enable-unsafe-fp-math flag is specified on the command line.  When
103     /// this flag is off (the default), the code generator is not allowed to
104     /// produce results that are "less precise" than IEEE allows.  This includes
105     /// use of X86 instructions like FSIN and FCOS instead of libcalls.
106     /// UnsafeFPMath implies LessPreciseFPMAD.
107     unsigned UnsafeFPMath : 1;
108
109     /// NoInfsFPMath - This flag is enabled when the
110     /// -enable-no-infs-fp-math flag is specified on the command line. When
111     /// this flag is off (the default), the code generator is not allowed to
112     /// assume the FP arithmetic arguments and results are never +-Infs.
113     unsigned NoInfsFPMath : 1;
114
115     /// NoNaNsFPMath - This flag is enabled when the
116     /// -enable-no-nans-fp-math flag is specified on the command line. When
117     /// this flag is off (the default), the code generator is not allowed to
118     /// assume the FP arithmetic arguments and results are never NaNs.
119     unsigned NoNaNsFPMath : 1;
120
121     /// HonorSignDependentRoundingFPMath - This returns true when the
122     /// -enable-sign-dependent-rounding-fp-math is specified.  If this returns
123     /// false (the default), the code generator is allowed to assume that the
124     /// rounding behavior is the default (round-to-zero for all floating point
125     /// to integer conversions, and round-to-nearest for all other arithmetic
126     /// truncations).  If this is enabled (set to true), the code generator must
127     /// assume that the rounding mode may dynamically change.
128     unsigned HonorSignDependentRoundingFPMathOption : 1;
129     bool HonorSignDependentRoundingFPMath() const;
130
131     /// UseSoftFloat - This flag is enabled when the -soft-float flag is
132     /// specified on the command line.  When this flag is on, the code generator
133     /// will generate libcalls to the software floating point library instead of
134     /// target FP instructions.
135     unsigned UseSoftFloat : 1;
136
137     /// NoZerosInBSS - By default some codegens place zero-initialized data to
138     /// .bss section. This flag disables such behaviour (necessary, e.g. for
139     /// crt*.o compiling).
140     unsigned NoZerosInBSS : 1;
141
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;
149
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;
153
154     /// StackAlignmentOverride - Override default stack alignment for target.
155     unsigned StackAlignmentOverride;
156
157     /// EnableFastISel - This flag enables fast-path instruction selection
158     /// which trades away generated code quality in favor of reducing
159     /// compile time.
160     unsigned EnableFastISel : 1;
161
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;
167
168     /// UseInitArray - Use .init_array instead of .ctors for static
169     /// constructors.
170     unsigned UseInitArray : 1;
171
172     /// Disable the integrated assembler.
173     unsigned DisableIntegratedAS : 1;
174
175     /// Compress DWARF debug sections.
176     unsigned CompressDebugSections : 1;
177
178     /// Emit functions into separate sections.
179     unsigned FunctionSections : 1;
180
181     /// Emit data into separate sections.
182     unsigned DataSections : 1;
183
184     unsigned UniqueSectionNames : 1;
185
186     /// Emit target-specific trap instruction for 'unreachable' IR instructions.
187     unsigned TrapUnreachable : 1;
188
189     /// getTrapFunctionName - If this returns a non-empty string, this means
190     /// isel should lower Intrinsic::trap to a call to the specified function
191     /// name instead of an ISD::TRAP node.
192     std::string TrapFuncName;
193     StringRef getTrapFunctionName() const;
194
195     /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
196     /// on the command line. This setting may either be Default, Soft, or Hard.
197     /// Default selects the target's default behavior. Soft selects the ABI for
198     /// software floating point, but does not indicate that FP hardware may not
199     /// be used. Such a combination is unfortunately popular (e.g.
200     /// arm-apple-darwin). Hard presumes that the normal FP ABI is used.
201     FloatABI::ABIType FloatABIType;
202
203     /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
204     /// This controls the creation of fused FP ops that store intermediate
205     /// results in higher precision than IEEE allows (E.g. FMAs).
206     ///
207     /// Fast mode - allows formation of fused FP ops whenever they're
208     /// profitable.
209     /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
210     /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
211     /// may be added.
212     /// Strict mode - allow fusion only if/when it can be proven that the excess
213     /// precision won't effect the result.
214     ///
215     /// Note: This option only controls formation of fused ops by the
216     /// optimizers.  Fused operations that are explicitly specified (e.g. FMA
217     /// via the llvm.fma.* intrinsic) will always be honored, regardless of
218     /// the value of this option.
219     FPOpFusion::FPOpFusionMode AllowFPOpFusion;
220
221     /// JTType - This flag specifies the type of jump-instruction table to
222     /// create for functions that have the jumptable attribute.
223     JumpTable::JumpTableType JTType;
224
225     /// FCFI - This flags controls whether or not forward-edge control-flow
226     /// integrity is applied.
227     bool FCFI;
228
229     /// ThreadModel - This flag specifies the type of threading model to assume
230     /// for things like atomics
231     ThreadModel::Model ThreadModel;
232
233     /// getCFIFuncName - If this returns a non-empty string, then this is the
234     /// name of the function that will be called for each CFI violation in
235     /// non-enforcing mode.
236     std::string CFIFuncName;
237     StringRef getCFIFuncName() const;
238
239     /// Machine level options.
240     MCTargetOptions MCOptions;
241   };
242
243 // Comparison operators:
244
245
246 inline bool operator==(const TargetOptions &LHS,
247                        const TargetOptions &RHS) {
248 #define ARE_EQUAL(X) LHS.X == RHS.X
249   return
250     ARE_EQUAL(UnsafeFPMath) &&
251     ARE_EQUAL(NoInfsFPMath) &&
252     ARE_EQUAL(NoNaNsFPMath) &&
253     ARE_EQUAL(HonorSignDependentRoundingFPMathOption) &&
254     ARE_EQUAL(UseSoftFloat) &&
255     ARE_EQUAL(NoZerosInBSS) &&
256     ARE_EQUAL(GuaranteedTailCallOpt) &&
257     ARE_EQUAL(DisableTailCalls) &&
258     ARE_EQUAL(StackAlignmentOverride) &&
259     ARE_EQUAL(EnableFastISel) &&
260     ARE_EQUAL(PositionIndependentExecutable) &&
261     ARE_EQUAL(UseInitArray) &&
262     ARE_EQUAL(TrapUnreachable) &&
263     ARE_EQUAL(TrapFuncName) &&
264     ARE_EQUAL(FloatABIType) &&
265     ARE_EQUAL(AllowFPOpFusion) &&
266     ARE_EQUAL(JTType) &&
267     ARE_EQUAL(FCFI) &&
268     ARE_EQUAL(ThreadModel) &&
269     ARE_EQUAL(CFIFuncName) &&
270     ARE_EQUAL(MCOptions);
271 #undef ARE_EQUAL
272 }
273
274 inline bool operator!=(const TargetOptions &LHS,
275                        const TargetOptions &RHS) {
276   return !(LHS == RHS);
277 }
278
279 } // End llvm namespace
280
281 #endif