LLVM API Documentation

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