3a1809a80a0d8f24bfc770343dbfa11d8f4a5e06
[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 <string>
19
20 namespace llvm {
21   class MachineFunction;
22   class StringRef;
23
24   // Possible float ABI settings. Used with FloatABIType in TargetOptions.h.
25   namespace FloatABI {
26     enum ABIType {
27       Default, // Target-specific (either soft or hard depending on triple, etc).
28       Soft, // Soft float.
29       Hard  // Hard float.
30     };
31   }
32
33   namespace FPOpFusion {
34     enum FPOpFusionMode {
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.
38     };
39   }
40
41   class TargetOptions {
42   public:
43     TargetOptions()
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), JITExceptionHandling(false),
49           JITEmitDebugInfo(false), JITEmitDebugInfoToDisk(false),
50           GuaranteedTailCallOpt(false), DisableTailCalls(false),
51           StackAlignmentOverride(0), RealignStack(true),
52           DisableJumpTables(false), EnableFastISel(false),
53           PositionIndependentExecutable(false), EnableSegmentedStacks(false),
54           UseInitArray(false), TrapFuncName(""), FloatABIType(FloatABI::Default),
55           AllowFPOpFusion(FPOpFusion::Standard)
56     {}
57
58     /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
59     /// option is specified on the command line, and should enable debugging
60     /// output from the code generator.
61     unsigned PrintMachineCode : 1;
62
63     /// NoFramePointerElim - This flag is enabled when the -disable-fp-elim is
64     /// specified on the command line.  If the target supports the frame pointer
65     /// elimination optimization, this option should disable it.
66     unsigned NoFramePointerElim : 1;
67
68     /// NoFramePointerElimNonLeaf - This flag is enabled when the
69     /// -disable-non-leaf-fp-elim is specified on the command line. If the
70     /// target supports the frame pointer elimination optimization, this option
71     /// should disable it for non-leaf functions.
72     unsigned NoFramePointerElimNonLeaf : 1;
73
74     /// DisableFramePointerElim - This returns true if frame pointer elimination
75     /// optimization should be disabled for the given machine function.
76     bool DisableFramePointerElim(const MachineFunction &MF) const;
77
78     /// LessPreciseFPMAD - This flag is enabled when the
79     /// -enable-fp-mad is specified on the command line.  When this flag is off
80     /// (the default), the code generator is not allowed to generate mad
81     /// (multiply add) if the result is "less precise" than doing those
82     /// operations individually.
83     unsigned LessPreciseFPMADOption : 1;
84     bool LessPreciseFPMAD() const;
85
86     /// UnsafeFPMath - This flag is enabled when the
87     /// -enable-unsafe-fp-math flag is specified on the command line.  When
88     /// this flag is off (the default), the code generator is not allowed to
89     /// produce results that are "less precise" than IEEE allows.  This includes
90     /// use of X86 instructions like FSIN and FCOS instead of libcalls.
91     /// UnsafeFPMath implies LessPreciseFPMAD.
92     unsigned UnsafeFPMath : 1;
93
94     /// NoInfsFPMath - This flag is enabled when the
95     /// -enable-no-infs-fp-math flag is specified on the command line. When
96     /// this flag is off (the default), the code generator is not allowed to
97     /// assume the FP arithmetic arguments and results are never +-Infs.
98     unsigned NoInfsFPMath : 1;
99
100     /// NoNaNsFPMath - This flag is enabled when the
101     /// -enable-no-nans-fp-math flag is specified on the command line. When
102     /// this flag is off (the default), the code generator is not allowed to
103     /// assume the FP arithmetic arguments and results are never NaNs.
104     unsigned NoNaNsFPMath : 1;
105
106     /// HonorSignDependentRoundingFPMath - This returns true when the
107     /// -enable-sign-dependent-rounding-fp-math is specified.  If this returns
108     /// false (the default), the code generator is allowed to assume that the
109     /// rounding behavior is the default (round-to-zero for all floating point
110     /// to integer conversions, and round-to-nearest for all other arithmetic
111     /// truncations).  If this is enabled (set to true), the code generator must
112     /// assume that the rounding mode may dynamically change.
113     unsigned HonorSignDependentRoundingFPMathOption : 1;
114     bool HonorSignDependentRoundingFPMath() const;
115
116     /// UseSoftFloat - This flag is enabled when the -soft-float flag is
117     /// specified on the command line.  When this flag is on, the code generator
118     /// will generate libcalls to the software floating point library instead of
119     /// target FP instructions.
120     unsigned UseSoftFloat : 1;
121
122     /// NoZerosInBSS - By default some codegens place zero-initialized data to
123     /// .bss section. This flag disables such behaviour (necessary, e.g. for
124     /// crt*.o compiling).
125     unsigned NoZerosInBSS : 1;
126
127     /// JITExceptionHandling - This flag indicates that the JIT should emit
128     /// exception handling information.
129     unsigned JITExceptionHandling : 1;
130
131     /// JITEmitDebugInfo - This flag indicates that the JIT should try to emit
132     /// debug information and notify a debugger about it.
133     unsigned JITEmitDebugInfo : 1;
134
135     /// JITEmitDebugInfoToDisk - This flag indicates that the JIT should write
136     /// the object files generated by the JITEmitDebugInfo flag to disk.  This
137     /// flag is hidden and is only for debugging the debug info.
138     unsigned JITEmitDebugInfoToDisk : 1;
139
140     /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is
141     /// specified on the commandline. When the flag is on, participating targets
142     /// will perform tail call optimization on all calls which use the fastcc
143     /// calling convention and which satisfy certain target-independent
144     /// criteria (being at the end of a function, having the same return type
145     /// as their parent function, etc.), using an alternate ABI if necessary.
146     unsigned GuaranteedTailCallOpt : 1;
147
148     /// DisableTailCalls - This flag controls whether we will use tail calls.
149     /// Disabling them may be useful to maintain a correct call stack.
150     unsigned DisableTailCalls : 1;
151
152     /// StackAlignmentOverride - Override default stack alignment for target.
153     unsigned StackAlignmentOverride;
154
155     /// RealignStack - This flag indicates whether the stack should be
156     /// automatically realigned, if needed.
157     unsigned RealignStack : 1;
158
159     /// DisableJumpTables - This flag indicates jump tables should not be
160     /// generated.
161     unsigned DisableJumpTables : 1;
162
163     /// EnableFastISel - This flag enables fast-path instruction selection
164     /// which trades away generated code quality in favor of reducing
165     /// compile time.
166     unsigned EnableFastISel : 1;
167
168     /// PositionIndependentExecutable - This flag indicates whether the code
169     /// will eventually be linked into a single executable, despite the PIC
170     /// relocation model being in use. It's value is undefined (and irrelevant)
171     /// if the relocation model is anything other than PIC.
172     unsigned PositionIndependentExecutable : 1;
173
174     unsigned EnableSegmentedStacks : 1;
175
176     /// UseInitArray - Use .init_array instead of .ctors for static
177     /// constructors.
178     unsigned UseInitArray : 1;
179
180     /// getTrapFunctionName - If this returns a non-empty string, this means
181     /// isel should lower Intrinsic::trap to a call to the specified function
182     /// name instead of an ISD::TRAP node.
183     std::string TrapFuncName;
184     StringRef getTrapFunctionName() const;
185
186     /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
187     /// on the command line. This setting may either be Default, Soft, or Hard.
188     /// Default selects the target's default behavior. Soft selects the ABI for
189     /// UseSoftFloat, but does not indicate that FP hardware may not be used.
190     /// Such a combination is unfortunately popular (e.g. arm-apple-darwin).
191     /// Hard presumes that the normal FP ABI is used.
192     FloatABI::ABIType FloatABIType;
193
194     /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
195     /// This controls the creation of fused FP ops that store intermediate
196     /// results in higher precision than IEEE allows (E.g. FMAs).
197     ///
198     /// Fast mode - allows formation of fused FP ops whenever they're
199     /// profitable.
200     /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
201     /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
202     /// may be added.
203     /// Strict mode - allow fusion only if/when it can be proven that the excess
204     /// precision won't effect the result.
205     ///
206     /// Note: This option only controls formation of fused ops by the optimizers.
207     /// Fused operations that are explicitly specified (e.g. FMA via the
208     /// llvm.fma.* intrinsic) will always be honored, regardless of the value of
209     /// this option.
210     FPOpFusion::FPOpFusionMode AllowFPOpFusion;
211
212   };
213 } // End llvm namespace
214
215 #endif