]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h
Update clang to trunk r290819 and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Frontend / CodeGenOptions.h
1 //===--- CodeGenOptions.h ---------------------------------------*- 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 the CodeGenOptions interface.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
15 #define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
16
17 #include "clang/Basic/DebugInfoOptions.h"
18 #include "clang/Basic/Sanitizers.h"
19 #include "llvm/Support/Regex.h"
20 #include "llvm/Target/TargetOptions.h"
21 #include <map>
22 #include <memory>
23 #include <string>
24 #include <vector>
25
26 namespace clang {
27
28 /// \brief Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure
29 /// that this large collection of bitfields is a trivial class type.
30 class CodeGenOptionsBase {
31 public:
32 #define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
33 #define ENUM_CODEGENOPT(Name, Type, Bits, Default)
34 #include "clang/Frontend/CodeGenOptions.def"
35
36 protected:
37 #define CODEGENOPT(Name, Bits, Default)
38 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
39 #include "clang/Frontend/CodeGenOptions.def"
40 };
41
42 /// CodeGenOptions - Track various options which control how the code
43 /// is optimized and passed to the backend.
44 class CodeGenOptions : public CodeGenOptionsBase {
45 public:
46   enum InliningMethod {
47     NormalInlining,     // Use the standard function inlining pass.
48     OnlyHintInlining,   // Inline only (implicitly) hinted functions.
49     OnlyAlwaysInlining  // Only run the always inlining pass.
50   };
51
52   enum VectorLibrary {
53     NoLibrary,  // Don't use any vector library.
54     Accelerate, // Use the Accelerate framework.
55     SVML        // Intel short vector math library.
56   };
57
58
59   enum ObjCDispatchMethodKind {
60     Legacy = 0,
61     NonLegacy = 1,
62     Mixed = 2
63   };
64
65   enum TLSModel {
66     GeneralDynamicTLSModel,
67     LocalDynamicTLSModel,
68     InitialExecTLSModel,
69     LocalExecTLSModel
70   };
71
72   enum FPContractModeKind {
73     FPC_Off,        // Form fused FP ops only where result will not be affected.
74     FPC_On,         // Form fused FP ops according to FP_CONTRACT rules.
75     FPC_Fast        // Aggressively fuse FP ops (E.g. FMA).
76   };
77
78   enum StructReturnConventionKind {
79     SRCK_Default,  // No special option was passed.
80     SRCK_OnStack,  // Small structs on the stack (-fpcc-struct-return).
81     SRCK_InRegs    // Small structs in registers (-freg-struct-return).
82   };
83
84   enum ProfileInstrKind {
85     ProfileNone,       // Profile instrumentation is turned off.
86     ProfileClangInstr, // Clang instrumentation to generate execution counts
87                        // to use with PGO.
88     ProfileIRInstr,    // IR level PGO instrumentation in LLVM.
89   };
90
91   enum EmbedBitcodeKind {
92     Embed_Off,      // No embedded bitcode.
93     Embed_All,      // Embed both bitcode and commandline in the output.
94     Embed_Bitcode,  // Embed just the bitcode in the output.
95     Embed_Marker    // Embed a marker as a placeholder for bitcode.
96   };
97
98   /// The code model to use (-mcmodel).
99   std::string CodeModel;
100
101   /// The filename with path we use for coverage data files. The runtime
102   /// allows further manipulation with the GCOV_PREFIX and GCOV_PREFIX_STRIP
103   /// environment variables.
104   std::string CoverageDataFile;
105
106   /// The filename with path we use for coverage notes files.
107   std::string CoverageNotesFile;
108
109   /// The version string to put into coverage files.
110   char CoverageVersion[4];
111
112   /// Enable additional debugging information.
113   std::string DebugPass;
114
115   /// The string to embed in debug information as the current working directory.
116   std::string DebugCompilationDir;
117
118   /// The string to embed in the debug information for the compile unit, if
119   /// non-empty.
120   std::string DwarfDebugFlags;
121
122   std::map<std::string, std::string> DebugPrefixMap;
123
124   /// The ABI to use for passing floating point arguments.
125   std::string FloatABI;
126
127   /// The floating-point denormal mode to use.
128   std::string FPDenormalMode;
129
130   /// The float precision limit to use, if non-empty.
131   std::string LimitFloatPrecision;
132
133   /// The name of the bitcode file to link before optzns.
134   std::vector<std::pair<unsigned, std::string>> LinkBitcodeFiles;
135
136   /// The user provided name for the "main file", if non-empty. This is useful
137   /// in situations where the input file name does not match the original input
138   /// file, for example with -save-temps.
139   std::string MainFileName;
140
141   /// The name for the split debug info file that we'll break out. This is used
142   /// in the backend for setting the name in the skeleton cu.
143   std::string SplitDwarfFile;
144
145   /// The name of the relocation model to use.
146   std::string RelocationModel;
147
148   /// The thread model to use
149   std::string ThreadModel;
150
151   /// If not an empty string, trap intrinsics are lowered to calls to this
152   /// function instead of to trap instructions.
153   std::string TrapFuncName;
154
155   /// A list of command-line options to forward to the LLVM backend.
156   std::vector<std::string> BackendOptions;
157
158   /// A list of dependent libraries.
159   std::vector<std::string> DependentLibraries;
160
161   /// A list of linker options to embed in the object file.
162   std::vector<std::string> LinkerOptions;
163
164   /// Name of the profile file to use as output for -fprofile-instr-generate
165   /// and -fprofile-generate.
166   std::string InstrProfileOutput;
167
168   /// Name of the profile file to use with -fprofile-sample-use.
169   std::string SampleProfileFile;
170
171   /// Name of the profile file to use as input for -fprofile-instr-use
172   std::string ProfileInstrumentUsePath;
173
174   /// Name of the function summary index file to use for ThinLTO function
175   /// importing.
176   std::string ThinLTOIndexFile;
177
178   /// A list of file names passed with -fcuda-include-gpubinary options to
179   /// forward to CUDA runtime back-end for incorporating them into host-side
180   /// object file.
181   std::vector<std::string> CudaGpuBinaryFileNames;
182
183   /// The name of the file to which the backend should save YAML optimization
184   /// records.
185   std::string OptRecordFile;
186
187   /// Regular expression to select optimizations for which we should enable
188   /// optimization remarks. Transformation passes whose name matches this
189   /// expression (and support this feature), will emit a diagnostic
190   /// whenever they perform a transformation. This is enabled by the
191   /// -Rpass=regexp flag.
192   std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
193
194   /// Regular expression to select optimizations for which we should enable
195   /// missed optimization remarks. Transformation passes whose name matches this
196   /// expression (and support this feature), will emit a diagnostic
197   /// whenever they tried but failed to perform a transformation. This is
198   /// enabled by the -Rpass-missed=regexp flag.
199   std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
200
201   /// Regular expression to select optimizations for which we should enable
202   /// optimization analyses. Transformation passes whose name matches this
203   /// expression (and support this feature), will emit a diagnostic
204   /// whenever they want to explain why they decided to apply or not apply
205   /// a given transformation. This is enabled by the -Rpass-analysis=regexp
206   /// flag.
207   std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
208
209   /// Set of files definining the rules for the symbol rewriting.
210   std::vector<std::string> RewriteMapFiles;
211
212   /// Set of sanitizer checks that are non-fatal (i.e. execution should be
213   /// continued when possible).
214   SanitizerSet SanitizeRecover;
215
216   /// Set of sanitizer checks that trap rather than diagnose.
217   SanitizerSet SanitizeTrap;
218
219   /// List of backend command-line options for -fembed-bitcode.
220   std::vector<uint8_t> CmdArgs;
221
222   /// \brief A list of all -fno-builtin-* function names (e.g., memset).
223   std::vector<std::string> NoBuiltinFuncs;
224
225 public:
226   // Define accessors/mutators for code generation options of enumeration type.
227 #define CODEGENOPT(Name, Bits, Default)
228 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
229   Type get##Name() const { return static_cast<Type>(Name); } \
230   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
231 #include "clang/Frontend/CodeGenOptions.def"
232
233   CodeGenOptions();
234
235   /// \brief Is this a libc/libm function that is no longer recognized as a
236   /// builtin because a -fno-builtin-* option has been specified?
237   bool isNoBuiltinFunc(const char *Name) const;
238
239   const std::vector<std::string> &getNoBuiltinFuncs() const {
240     return NoBuiltinFuncs;
241   }
242
243   /// \brief Check if Clang profile instrumenation is on.
244   bool hasProfileClangInstr() const {
245     return getProfileInstr() == ProfileClangInstr;
246   }
247
248   /// \brief Check if IR level profile instrumentation is on.
249   bool hasProfileIRInstr() const {
250     return getProfileInstr() == ProfileIRInstr;
251   }
252
253   /// \brief Check if Clang profile use is on.
254   bool hasProfileClangUse() const {
255     return getProfileUse() == ProfileClangInstr;
256   }
257
258   /// \brief Check if IR level profile use is on.
259   bool hasProfileIRUse() const {
260     return getProfileUse() == ProfileIRInstr;
261   }
262
263 };
264
265 }  // end namespace clang
266
267 #endif