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