]> granicus.if.org Git - clang/blob - include/clang/Frontend/CodeGenOptions.h
Eliminate an unnecessary enum, use the LLVM version. NFC
[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     NoInlining,         // Perform no inlining whatsoever.
48     NormalInlining,     // Use the standard function inlining pass.
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   };
56
57   enum ObjCDispatchMethodKind {
58     Legacy = 0,
59     NonLegacy = 1,
60     Mixed = 2
61   };
62
63   enum TLSModel {
64     GeneralDynamicTLSModel,
65     LocalDynamicTLSModel,
66     InitialExecTLSModel,
67     LocalExecTLSModel
68   };
69
70   enum FPContractModeKind {
71     FPC_Off,        // Form fused FP ops only where result will not be affected.
72     FPC_On,         // Form fused FP ops according to FP_CONTRACT rules.
73     FPC_Fast        // Aggressively fuse FP ops (E.g. FMA).
74   };
75
76   enum StructReturnConventionKind {
77     SRCK_Default,  // No special option was passed.
78     SRCK_OnStack,  // Small structs on the stack (-fpcc-struct-return).
79     SRCK_InRegs    // Small structs in registers (-freg-struct-return).
80   };
81
82   enum ProfileInstrKind {
83     ProfileNoInstr,    // No instrumentation.
84     ProfileClangInstr  // Clang instrumentation to generate execution counts
85                        // to use with PGO.
86   };
87
88   /// The code model to use (-mcmodel).
89   std::string CodeModel;
90
91   /// The filename with path we use for coverage files. The extension will be
92   /// replaced.
93   std::string CoverageFile;
94
95   /// The version string to put into coverage files.
96   char CoverageVersion[4];
97
98   /// Enable additional debugging information.
99   std::string DebugPass;
100
101   /// The string to embed in debug information as the current working directory.
102   std::string DebugCompilationDir;
103
104   /// The string to embed in the debug information for the compile unit, if
105   /// non-empty.
106   std::string DwarfDebugFlags;
107
108   std::map<std::string, std::string> DebugPrefixMap;
109
110   /// The ABI to use for passing floating point arguments.
111   std::string FloatABI;
112
113   /// The float precision limit to use, if non-empty.
114   std::string LimitFloatPrecision;
115
116   /// The name of the bitcode file to link before optzns.
117   std::vector<std::pair<unsigned, std::string>> LinkBitcodeFiles;
118
119   /// The user provided name for the "main file", if non-empty. This is useful
120   /// in situations where the input file name does not match the original input
121   /// file, for example with -save-temps.
122   std::string MainFileName;
123
124   /// The name for the split debug info file that we'll break out. This is used
125   /// in the backend for setting the name in the skeleton cu.
126   std::string SplitDwarfFile;
127
128   /// The name of the relocation model to use.
129   std::string RelocationModel;
130
131   /// The thread model to use
132   std::string ThreadModel;
133
134   /// If not an empty string, trap intrinsics are lowered to calls to this
135   /// function instead of to trap instructions.
136   std::string TrapFuncName;
137
138   /// A list of command-line options to forward to the LLVM backend.
139   std::vector<std::string> BackendOptions;
140
141   /// A list of dependent libraries.
142   std::vector<std::string> DependentLibraries;
143
144   /// A list of linker options to embed in the object file.
145   std::vector<std::string> LinkerOptions;
146
147   /// Name of the profile file to use as output for -fprofile-instr-generate
148   /// and -fprofile-generate.
149   std::string InstrProfileOutput;
150
151   /// Name of the profile file to use with -fprofile-sample-use.
152   std::string SampleProfileFile;
153
154   /// Name of the profile file to use as input for -fprofile-instr-use
155   std::string InstrProfileInput;
156
157   /// Name of the function summary index file to use for ThinLTO function
158   /// importing.
159   std::string ThinLTOIndexFile;
160
161   /// The EABI version to use
162   std::string EABIVersion;
163
164   /// A list of file names passed with -fcuda-include-gpubinary options to
165   /// forward to CUDA runtime back-end for incorporating them into host-side
166   /// object file.
167   std::vector<std::string> CudaGpuBinaryFileNames;
168
169   /// Regular expression to select optimizations for which we should enable
170   /// optimization remarks. Transformation passes whose name matches this
171   /// expression (and support this feature), will emit a diagnostic
172   /// whenever they perform a transformation. This is enabled by the
173   /// -Rpass=regexp flag.
174   std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
175
176   /// Regular expression to select optimizations for which we should enable
177   /// missed optimization remarks. Transformation passes whose name matches this
178   /// expression (and support this feature), will emit a diagnostic
179   /// whenever they tried but failed to perform a transformation. This is
180   /// enabled by the -Rpass-missed=regexp flag.
181   std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
182
183   /// Regular expression to select optimizations for which we should enable
184   /// optimization analyses. Transformation passes whose name matches this
185   /// expression (and support this feature), will emit a diagnostic
186   /// whenever they want to explain why they decided to apply or not apply
187   /// a given transformation. This is enabled by the -Rpass-analysis=regexp
188   /// flag.
189   std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
190
191   /// Set of files definining the rules for the symbol rewriting.
192   std::vector<std::string> RewriteMapFiles;
193
194   /// Set of sanitizer checks that are non-fatal (i.e. execution should be
195   /// continued when possible).
196   SanitizerSet SanitizeRecover;
197
198   /// Set of sanitizer checks that trap rather than diagnose.
199   SanitizerSet SanitizeTrap;
200
201   /// \brief A list of all -fno-builtin-* function names (e.g., memset).
202   std::vector<std::string> NoBuiltinFuncs;
203
204 public:
205   // Define accessors/mutators for code generation options of enumeration type.
206 #define CODEGENOPT(Name, Bits, Default)
207 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
208   Type get##Name() const { return static_cast<Type>(Name); } \
209   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
210 #include "clang/Frontend/CodeGenOptions.def"
211
212   CodeGenOptions();
213
214   /// \brief Is this a libc/libm function that is no longer recognized as a
215   /// builtin because a -fno-builtin-* option has been specified?
216   bool isNoBuiltinFunc(const char *Name) const;
217
218   const std::vector<std::string> &getNoBuiltinFuncs() const {
219     return NoBuiltinFuncs;
220   }
221
222   /// \brief Check if Clang profile instrumenation is on.
223   bool hasProfileClangInstr() const {
224     return getProfileInstr() == ProfileClangInstr;
225   }
226 };
227
228 }  // end namespace clang
229
230 #endif