]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/Target/TargetOptions.h
Merge ^/head r304700 through r304884.
[FreeBSD/FreeBSD.git] / contrib / llvm / 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/Target/TargetRecip.h"
19 #include "llvm/MC/MCTargetOptions.h"
20 #include "llvm/MC/MCAsmInfo.h"
21
22 namespace llvm {
23   class MachineFunction;
24   class Module;
25
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   enum class EABI {
61     Unknown,
62     Default, // Default means not specified
63     EABI4,   // Target-specific (either 4, 5 or gnu depending on triple).
64     EABI5,
65     GNU
66   };
67
68   /// Identify a debugger for "tuning" the debug info.
69   ///
70   /// The "debugger tuning" concept allows us to present a more intuitive
71   /// interface that unpacks into different sets of defaults for the various
72   /// individual feature-flag settings, that suit the preferences of the
73   /// various debuggers.  However, it's worth remembering that debuggers are
74   /// not the only consumers of debug info, and some variations in DWARF might
75   /// better be treated as target/platform issues. Fundamentally,
76   /// o if the feature is useful (or not) to a particular debugger, regardless
77   ///   of the target, that's a tuning decision;
78   /// o if the feature is useful (or not) on a particular platform, regardless
79   ///   of the debugger, that's a target decision.
80   /// It's not impossible to see both factors in some specific case.
81   ///
82   /// The "tuning" should be used to set defaults for individual feature flags
83   /// in DwarfDebug; if a given feature has a more specific command-line option,
84   /// that option should take precedence over the tuning.
85   enum class DebuggerKind {
86     Default,  // No specific tuning requested.
87     GDB,      // Tune debug info for gdb.
88     LLDB,     // Tune debug info for lldb.
89     SCE       // Tune debug info for SCE targets (e.g. PS4).
90   };
91
92   class TargetOptions {
93   public:
94     TargetOptions()
95         : PrintMachineCode(false), LessPreciseFPMADOption(false),
96           UnsafeFPMath(false), NoInfsFPMath(false), NoNaNsFPMath(false),
97           HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
98           GuaranteedTailCallOpt(false), StackAlignmentOverride(0),
99           StackSymbolOrdering(true), EnableFastISel(false), UseInitArray(false),
100           DisableIntegratedAS(false), CompressDebugSections(false),
101           RelaxELFRelocations(false), FunctionSections(false),
102           DataSections(false), UniqueSectionNames(true), TrapUnreachable(false),
103           EmulatedTLS(false), EnableIPRA(false),
104           FloatABIType(FloatABI::Default),
105           AllowFPOpFusion(FPOpFusion::Standard), Reciprocals(TargetRecip()),
106           JTType(JumpTable::Single), ThreadModel(ThreadModel::POSIX),
107           EABIVersion(EABI::Default), DebuggerTuning(DebuggerKind::Default),
108           ExceptionModel(ExceptionHandling::None) {}
109
110     /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
111     /// option is specified on the command line, and should enable debugging
112     /// output from the code generator.
113     unsigned PrintMachineCode : 1;
114
115     /// DisableFramePointerElim - This returns true if frame pointer elimination
116     /// optimization should be disabled for the given machine function.
117     bool DisableFramePointerElim(const MachineFunction &MF) const;
118
119     /// LessPreciseFPMAD - This flag is enabled when the
120     /// -enable-fp-mad is specified on the command line.  When this flag is off
121     /// (the default), the code generator is not allowed to generate mad
122     /// (multiply add) if the result is "less precise" than doing those
123     /// operations individually.
124     unsigned LessPreciseFPMADOption : 1;
125     bool LessPreciseFPMAD() const;
126
127     /// UnsafeFPMath - This flag is enabled when the
128     /// -enable-unsafe-fp-math flag is specified on the command line.  When
129     /// this flag is off (the default), the code generator is not allowed to
130     /// produce results that are "less precise" than IEEE allows.  This includes
131     /// use of X86 instructions like FSIN and FCOS instead of libcalls.
132     /// UnsafeFPMath implies LessPreciseFPMAD.
133     unsigned UnsafeFPMath : 1;
134
135     /// NoInfsFPMath - This flag is enabled when the
136     /// -enable-no-infs-fp-math flag is specified on the command line. When
137     /// this flag is off (the default), the code generator is not allowed to
138     /// assume the FP arithmetic arguments and results are never +-Infs.
139     unsigned NoInfsFPMath : 1;
140
141     /// NoNaNsFPMath - This flag is enabled when the
142     /// -enable-no-nans-fp-math flag is specified on the command line. When
143     /// this flag is off (the default), the code generator is not allowed to
144     /// assume the FP arithmetic arguments and results are never NaNs.
145     unsigned NoNaNsFPMath : 1;
146
147     /// HonorSignDependentRoundingFPMath - This returns true when the
148     /// -enable-sign-dependent-rounding-fp-math is specified.  If this returns
149     /// false (the default), the code generator is allowed to assume that the
150     /// rounding behavior is the default (round-to-zero for all floating point
151     /// to integer conversions, and round-to-nearest for all other arithmetic
152     /// truncations).  If this is enabled (set to true), the code generator must
153     /// assume that the rounding mode may dynamically change.
154     unsigned HonorSignDependentRoundingFPMathOption : 1;
155     bool HonorSignDependentRoundingFPMath() const;
156
157     /// NoZerosInBSS - By default some codegens place zero-initialized data to
158     /// .bss section. This flag disables such behaviour (necessary, e.g. for
159     /// crt*.o compiling).
160     unsigned NoZerosInBSS : 1;
161
162     /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is
163     /// specified on the commandline. When the flag is on, participating targets
164     /// will perform tail call optimization on all calls which use the fastcc
165     /// calling convention and which satisfy certain target-independent
166     /// criteria (being at the end of a function, having the same return type
167     /// as their parent function, etc.), using an alternate ABI if necessary.
168     unsigned GuaranteedTailCallOpt : 1;
169
170     /// StackAlignmentOverride - Override default stack alignment for target.
171     unsigned StackAlignmentOverride;
172
173     /// StackSymbolOrdering - When true, this will allow CodeGen to order
174     /// the local stack symbols (for code size, code locality, or any other
175     /// heuristics). When false, the local symbols are left in whatever order
176     /// they were generated. Default is true.
177     unsigned StackSymbolOrdering : 1;
178
179     /// EnableFastISel - This flag enables fast-path instruction selection
180     /// which trades away generated code quality in favor of reducing
181     /// compile time.
182     unsigned EnableFastISel : 1;
183
184     /// UseInitArray - Use .init_array instead of .ctors for static
185     /// constructors.
186     unsigned UseInitArray : 1;
187
188     /// Disable the integrated assembler.
189     unsigned DisableIntegratedAS : 1;
190
191     /// Compress DWARF debug sections.
192     unsigned CompressDebugSections : 1;
193
194     unsigned RelaxELFRelocations : 1;
195
196     /// Emit functions into separate sections.
197     unsigned FunctionSections : 1;
198
199     /// Emit data into separate sections.
200     unsigned DataSections : 1;
201
202     unsigned UniqueSectionNames : 1;
203
204     /// Emit target-specific trap instruction for 'unreachable' IR instructions.
205     unsigned TrapUnreachable : 1;
206
207     /// EmulatedTLS - This flag enables emulated TLS model, using emutls
208     /// function in the runtime library..
209     unsigned EmulatedTLS : 1;
210
211     /// This flag enables InterProcedural Register Allocation (IPRA).
212     unsigned EnableIPRA : 1;
213
214     /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
215     /// on the command line. This setting may either be Default, Soft, or Hard.
216     /// Default selects the target's default behavior. Soft selects the ABI for
217     /// software floating point, but does not indicate that FP hardware may not
218     /// be used. Such a combination is unfortunately popular (e.g.
219     /// arm-apple-darwin). Hard presumes that the normal FP ABI is used.
220     FloatABI::ABIType FloatABIType;
221
222     /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
223     /// This controls the creation of fused FP ops that store intermediate
224     /// results in higher precision than IEEE allows (E.g. FMAs).
225     ///
226     /// Fast mode - allows formation of fused FP ops whenever they're
227     /// profitable.
228     /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
229     /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
230     /// may be added.
231     /// Strict mode - allow fusion only if/when it can be proven that the excess
232     /// precision won't effect the result.
233     ///
234     /// Note: This option only controls formation of fused ops by the
235     /// optimizers.  Fused operations that are explicitly specified (e.g. FMA
236     /// via the llvm.fma.* intrinsic) will always be honored, regardless of
237     /// the value of this option.
238     FPOpFusion::FPOpFusionMode AllowFPOpFusion;
239
240     /// This class encapsulates options for reciprocal-estimate code generation.
241     TargetRecip Reciprocals;
242
243     /// JTType - This flag specifies the type of jump-instruction table to
244     /// create for functions that have the jumptable attribute.
245     JumpTable::JumpTableType JTType;
246
247     /// ThreadModel - This flag specifies the type of threading model to assume
248     /// for things like atomics
249     ThreadModel::Model ThreadModel;
250
251     /// EABIVersion - This flag specifies the EABI version
252     EABI EABIVersion;
253
254     /// Which debugger to tune for.
255     DebuggerKind DebuggerTuning;
256
257     /// What exception model to use
258     ExceptionHandling ExceptionModel;
259
260     /// Machine level options.
261     MCTargetOptions MCOptions;
262   };
263
264 // Comparison operators:
265
266
267 inline bool operator==(const TargetOptions &LHS,
268                        const TargetOptions &RHS) {
269 #define ARE_EQUAL(X) LHS.X == RHS.X
270   return
271     ARE_EQUAL(UnsafeFPMath) &&
272     ARE_EQUAL(NoInfsFPMath) &&
273     ARE_EQUAL(NoNaNsFPMath) &&
274     ARE_EQUAL(HonorSignDependentRoundingFPMathOption) &&
275     ARE_EQUAL(NoZerosInBSS) &&
276     ARE_EQUAL(GuaranteedTailCallOpt) &&
277     ARE_EQUAL(StackAlignmentOverride) &&
278     ARE_EQUAL(EnableFastISel) &&
279     ARE_EQUAL(UseInitArray) &&
280     ARE_EQUAL(TrapUnreachable) &&
281     ARE_EQUAL(EmulatedTLS) &&
282     ARE_EQUAL(FloatABIType) &&
283     ARE_EQUAL(AllowFPOpFusion) &&
284     ARE_EQUAL(Reciprocals) &&
285     ARE_EQUAL(JTType) &&
286     ARE_EQUAL(ThreadModel) &&
287     ARE_EQUAL(EABIVersion) &&
288     ARE_EQUAL(DebuggerTuning) &&
289     ARE_EQUAL(ExceptionModel) &&
290     ARE_EQUAL(MCOptions) &&
291     ARE_EQUAL(EnableIPRA);
292 #undef ARE_EQUAL
293 }
294
295 inline bool operator!=(const TargetOptions &LHS,
296                        const TargetOptions &RHS) {
297   return !(LHS == RHS);
298 }
299
300 } // End llvm namespace
301
302 #endif