Remove templates from CostTableLookup functions. All instantiations had the same...
[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/Target/TargetRecip.h"
19 #include "llvm/MC/MCTargetOptions.h"
20 #include <string>
21
22 namespace llvm {
23   class MachineFunction;
24   class Module;
25   class StringRef;
26
27   namespace FloatABI {
28     enum ABIType {
29       Default, // Target-specific (either soft or hard depending on triple, etc).
30       Soft,    // Soft float.
31       Hard     // Hard float.
32     };
33   }
34
35   namespace FPOpFusion {
36     enum FPOpFusionMode {
37       Fast,     // Enable fusion of FP ops wherever it's profitable.
38       Standard, // Only allow fusion of 'blessed' ops (currently just fmuladd).
39       Strict    // Never fuse FP-ops.
40     };
41   }
42
43   namespace JumpTable {
44     enum JumpTableType {
45       Single,          // Use a single table for all indirect jumptable calls.
46       Arity,           // Use one table per number of function parameters.
47       Simplified,      // Use one table per function type, with types projected
48                        // into 4 types: pointer to non-function, struct,
49                        // primitive, and function pointer.
50       Full             // Use one table per unique function type
51     };
52   }
53
54   namespace ThreadModel {
55     enum Model {
56       POSIX,  // POSIX Threads
57       Single  // Single Threaded Environment
58     };
59   }
60
61   class TargetOptions {
62   public:
63     TargetOptions()
64         : PrintMachineCode(false),
65           LessPreciseFPMADOption(false), UnsafeFPMath(false),
66           NoInfsFPMath(false), NoNaNsFPMath(false),
67           HonorSignDependentRoundingFPMathOption(false),
68           NoZerosInBSS(false),
69           GuaranteedTailCallOpt(false),
70           StackAlignmentOverride(0),
71           EnableFastISel(false), PositionIndependentExecutable(false),
72           UseInitArray(false), DisableIntegratedAS(false),
73           CompressDebugSections(false), FunctionSections(false),
74           DataSections(false), UniqueSectionNames(true), TrapUnreachable(false),
75           EmulatedTLS(false), FloatABIType(FloatABI::Default),
76           AllowFPOpFusion(FPOpFusion::Standard), Reciprocals(TargetRecip()),
77           JTType(JumpTable::Single),
78           ThreadModel(ThreadModel::POSIX) {}
79
80     /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
81     /// option is specified on the command line, and should enable debugging
82     /// output from the code generator.
83     unsigned PrintMachineCode : 1;
84
85     /// DisableFramePointerElim - This returns true if frame pointer elimination
86     /// optimization should be disabled for the given machine function.
87     bool DisableFramePointerElim(const MachineFunction &MF) const;
88
89     /// LessPreciseFPMAD - This flag is enabled when the
90     /// -enable-fp-mad is specified on the command line.  When this flag is off
91     /// (the default), the code generator is not allowed to generate mad
92     /// (multiply add) if the result is "less precise" than doing those
93     /// operations individually.
94     unsigned LessPreciseFPMADOption : 1;
95     bool LessPreciseFPMAD() const;
96
97     /// UnsafeFPMath - This flag is enabled when the
98     /// -enable-unsafe-fp-math flag is specified on the command line.  When
99     /// this flag is off (the default), the code generator is not allowed to
100     /// produce results that are "less precise" than IEEE allows.  This includes
101     /// use of X86 instructions like FSIN and FCOS instead of libcalls.
102     /// UnsafeFPMath implies LessPreciseFPMAD.
103     unsigned UnsafeFPMath : 1;
104
105     /// NoInfsFPMath - This flag is enabled when the
106     /// -enable-no-infs-fp-math flag is specified on the command line. When
107     /// this flag is off (the default), the code generator is not allowed to
108     /// assume the FP arithmetic arguments and results are never +-Infs.
109     unsigned NoInfsFPMath : 1;
110
111     /// NoNaNsFPMath - This flag is enabled when the
112     /// -enable-no-nans-fp-math flag is specified on the command line. When
113     /// this flag is off (the default), the code generator is not allowed to
114     /// assume the FP arithmetic arguments and results are never NaNs.
115     unsigned NoNaNsFPMath : 1;
116
117     /// HonorSignDependentRoundingFPMath - This returns true when the
118     /// -enable-sign-dependent-rounding-fp-math is specified.  If this returns
119     /// false (the default), the code generator is allowed to assume that the
120     /// rounding behavior is the default (round-to-zero for all floating point
121     /// to integer conversions, and round-to-nearest for all other arithmetic
122     /// truncations).  If this is enabled (set to true), the code generator must
123     /// assume that the rounding mode may dynamically change.
124     unsigned HonorSignDependentRoundingFPMathOption : 1;
125     bool HonorSignDependentRoundingFPMath() const;
126
127     /// NoZerosInBSS - By default some codegens place zero-initialized data to
128     /// .bss section. This flag disables such behaviour (necessary, e.g. for
129     /// crt*.o compiling).
130     unsigned NoZerosInBSS : 1;
131
132     /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is
133     /// specified on the commandline. When the flag is on, participating targets
134     /// will perform tail call optimization on all calls which use the fastcc
135     /// calling convention and which satisfy certain target-independent
136     /// criteria (being at the end of a function, having the same return type
137     /// as their parent function, etc.), using an alternate ABI if necessary.
138     unsigned GuaranteedTailCallOpt : 1;
139
140     /// StackAlignmentOverride - Override default stack alignment for target.
141     unsigned StackAlignmentOverride;
142
143     /// EnableFastISel - This flag enables fast-path instruction selection
144     /// which trades away generated code quality in favor of reducing
145     /// compile time.
146     unsigned EnableFastISel : 1;
147
148     /// PositionIndependentExecutable - This flag indicates whether the code
149     /// will eventually be linked into a single executable, despite the PIC
150     /// relocation model being in use. It's value is undefined (and irrelevant)
151     /// if the relocation model is anything other than PIC.
152     unsigned PositionIndependentExecutable : 1;
153
154     /// UseInitArray - Use .init_array instead of .ctors for static
155     /// constructors.
156     unsigned UseInitArray : 1;
157
158     /// Disable the integrated assembler.
159     unsigned DisableIntegratedAS : 1;
160
161     /// Compress DWARF debug sections.
162     unsigned CompressDebugSections : 1;
163
164     /// Emit functions into separate sections.
165     unsigned FunctionSections : 1;
166
167     /// Emit data into separate sections.
168     unsigned DataSections : 1;
169
170     unsigned UniqueSectionNames : 1;
171
172     /// Emit target-specific trap instruction for 'unreachable' IR instructions.
173     unsigned TrapUnreachable : 1;
174
175     /// EmulatedTLS - This flag enables emulated TLS model, using emutls
176     /// function in the runtime library..
177     unsigned EmulatedTLS : 1;
178
179     /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
180     /// on the command line. This setting may either be Default, Soft, or Hard.
181     /// Default selects the target's default behavior. Soft selects the ABI for
182     /// software floating point, but does not indicate that FP hardware may not
183     /// be used. Such a combination is unfortunately popular (e.g.
184     /// arm-apple-darwin). Hard presumes that the normal FP ABI is used.
185     FloatABI::ABIType FloatABIType;
186
187     /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
188     /// This controls the creation of fused FP ops that store intermediate
189     /// results in higher precision than IEEE allows (E.g. FMAs).
190     ///
191     /// Fast mode - allows formation of fused FP ops whenever they're
192     /// profitable.
193     /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
194     /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
195     /// may be added.
196     /// Strict mode - allow fusion only if/when it can be proven that the excess
197     /// precision won't effect the result.
198     ///
199     /// Note: This option only controls formation of fused ops by the
200     /// optimizers.  Fused operations that are explicitly specified (e.g. FMA
201     /// via the llvm.fma.* intrinsic) will always be honored, regardless of
202     /// the value of this option.
203     FPOpFusion::FPOpFusionMode AllowFPOpFusion;
204
205     /// This class encapsulates options for reciprocal-estimate code generation.
206     TargetRecip Reciprocals;
207
208     /// JTType - This flag specifies the type of jump-instruction table to
209     /// create for functions that have the jumptable attribute.
210     JumpTable::JumpTableType JTType;
211
212     /// ThreadModel - This flag specifies the type of threading model to assume
213     /// for things like atomics
214     ThreadModel::Model ThreadModel;
215
216     /// Machine level options.
217     MCTargetOptions MCOptions;
218   };
219
220 // Comparison operators:
221
222
223 inline bool operator==(const TargetOptions &LHS,
224                        const TargetOptions &RHS) {
225 #define ARE_EQUAL(X) LHS.X == RHS.X
226   return
227     ARE_EQUAL(UnsafeFPMath) &&
228     ARE_EQUAL(NoInfsFPMath) &&
229     ARE_EQUAL(NoNaNsFPMath) &&
230     ARE_EQUAL(HonorSignDependentRoundingFPMathOption) &&
231     ARE_EQUAL(NoZerosInBSS) &&
232     ARE_EQUAL(GuaranteedTailCallOpt) &&
233     ARE_EQUAL(StackAlignmentOverride) &&
234     ARE_EQUAL(EnableFastISel) &&
235     ARE_EQUAL(PositionIndependentExecutable) &&
236     ARE_EQUAL(UseInitArray) &&
237     ARE_EQUAL(TrapUnreachable) &&
238     ARE_EQUAL(EmulatedTLS) &&
239     ARE_EQUAL(FloatABIType) &&
240     ARE_EQUAL(AllowFPOpFusion) &&
241     ARE_EQUAL(Reciprocals) &&
242     ARE_EQUAL(JTType) &&
243     ARE_EQUAL(ThreadModel) &&
244     ARE_EQUAL(MCOptions);
245 #undef ARE_EQUAL
246 }
247
248 inline bool operator!=(const TargetOptions &LHS,
249                        const TargetOptions &RHS) {
250   return !(LHS == RHS);
251 }
252
253 } // End llvm namespace
254
255 #endif