1 //===--- CodeGenOptions.h ---------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the CodeGenOptions interface.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
15 #define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
17 #include "clang/Basic/DebugInfoOptions.h"
18 #include "clang/Basic/Sanitizers.h"
19 #include "llvm/Support/Regex.h"
20 #include "llvm/Target/TargetOptions.h"
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 {
32 #define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
33 #define ENUM_CODEGENOPT(Name, Type, Bits, Default)
34 #include "clang/Frontend/CodeGenOptions.def"
37 #define CODEGENOPT(Name, Bits, Default)
38 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
39 #include "clang/Frontend/CodeGenOptions.def"
42 /// CodeGenOptions - Track various options which control how the code
43 /// is optimized and passed to the backend.
44 class CodeGenOptions : public CodeGenOptionsBase {
47 NoInlining, // Perform no inlining whatsoever.
48 NormalInlining, // Use the standard function inlining pass.
49 OnlyHintInlining, // Inline only (implicitly) hinted functions.
50 OnlyAlwaysInlining // Only run the always inlining pass.
54 NoLibrary, // Don't use any vector library.
55 Accelerate, // Use the Accelerate framework.
56 SVML // Intel short vector math library.
60 enum ObjCDispatchMethodKind {
67 GeneralDynamicTLSModel,
73 enum FPContractModeKind {
74 FPC_Off, // Form fused FP ops only where result will not be affected.
75 FPC_On, // Form fused FP ops according to FP_CONTRACT rules.
76 FPC_Fast // Aggressively fuse FP ops (E.g. FMA).
79 enum StructReturnConventionKind {
80 SRCK_Default, // No special option was passed.
81 SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return).
82 SRCK_InRegs // Small structs in registers (-freg-struct-return).
85 enum ProfileInstrKind {
86 ProfileNone, // Profile instrumentation is turned off.
87 ProfileClangInstr, // Clang instrumentation to generate execution counts
89 ProfileIRInstr, // IR level PGO instrumentation in LLVM.
92 enum EmbedBitcodeKind {
93 Embed_Off, // No embedded bitcode.
94 Embed_All, // Embed both bitcode and commandline in the output.
95 Embed_Bitcode, // Embed just the bitcode in the output.
96 Embed_Marker // Embed a marker as a placeholder for bitcode.
99 /// The code model to use (-mcmodel).
100 std::string CodeModel;
102 /// The filename with path we use for coverage data files. The runtime
103 /// allows further manipulation with the GCOV_PREFIX and GCOV_PREFIX_STRIP
104 /// environment variables.
105 std::string CoverageDataFile;
107 /// The filename with path we use for coverage notes files.
108 std::string CoverageNotesFile;
110 /// The version string to put into coverage files.
111 char CoverageVersion[4];
113 /// Enable additional debugging information.
114 std::string DebugPass;
116 /// The string to embed in debug information as the current working directory.
117 std::string DebugCompilationDir;
119 /// The string to embed in the debug information for the compile unit, if
121 std::string DwarfDebugFlags;
123 std::map<std::string, std::string> DebugPrefixMap;
125 /// The ABI to use for passing floating point arguments.
126 std::string FloatABI;
128 /// The floating-point denormal mode to use.
129 std::string FPDenormalMode;
131 /// The float precision limit to use, if non-empty.
132 std::string LimitFloatPrecision;
134 /// The name of the bitcode file to link before optzns.
135 std::vector<std::pair<unsigned, std::string>> LinkBitcodeFiles;
137 /// The user provided name for the "main file", if non-empty. This is useful
138 /// in situations where the input file name does not match the original input
139 /// file, for example with -save-temps.
140 std::string MainFileName;
142 /// The name for the split debug info file that we'll break out. This is used
143 /// in the backend for setting the name in the skeleton cu.
144 std::string SplitDwarfFile;
146 /// The name of the relocation model to use.
147 std::string RelocationModel;
149 /// The thread model to use
150 std::string ThreadModel;
152 /// If not an empty string, trap intrinsics are lowered to calls to this
153 /// function instead of to trap instructions.
154 std::string TrapFuncName;
156 /// A list of command-line options to forward to the LLVM backend.
157 std::vector<std::string> BackendOptions;
159 /// A list of dependent libraries.
160 std::vector<std::string> DependentLibraries;
162 /// A list of linker options to embed in the object file.
163 std::vector<std::string> LinkerOptions;
165 /// Name of the profile file to use as output for -fprofile-instr-generate
166 /// and -fprofile-generate.
167 std::string InstrProfileOutput;
169 /// Name of the profile file to use with -fprofile-sample-use.
170 std::string SampleProfileFile;
172 /// Name of the profile file to use as input for -fprofile-instr-use
173 std::string ProfileInstrumentUsePath;
175 /// Name of the function summary index file to use for ThinLTO function
177 std::string ThinLTOIndexFile;
179 /// A list of file names passed with -fcuda-include-gpubinary options to
180 /// forward to CUDA runtime back-end for incorporating them into host-side
182 std::vector<std::string> CudaGpuBinaryFileNames;
184 /// The name of the file to which the backend should save YAML optimization
186 std::string OptRecordFile;
188 /// Regular expression to select optimizations for which we should enable
189 /// optimization remarks. Transformation passes whose name matches this
190 /// expression (and support this feature), will emit a diagnostic
191 /// whenever they perform a transformation. This is enabled by the
192 /// -Rpass=regexp flag.
193 std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
195 /// Regular expression to select optimizations for which we should enable
196 /// missed optimization remarks. Transformation passes whose name matches this
197 /// expression (and support this feature), will emit a diagnostic
198 /// whenever they tried but failed to perform a transformation. This is
199 /// enabled by the -Rpass-missed=regexp flag.
200 std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
202 /// Regular expression to select optimizations for which we should enable
203 /// optimization analyses. Transformation passes whose name matches this
204 /// expression (and support this feature), will emit a diagnostic
205 /// whenever they want to explain why they decided to apply or not apply
206 /// a given transformation. This is enabled by the -Rpass-analysis=regexp
208 std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
210 /// Set of files definining the rules for the symbol rewriting.
211 std::vector<std::string> RewriteMapFiles;
213 /// Set of sanitizer checks that are non-fatal (i.e. execution should be
214 /// continued when possible).
215 SanitizerSet SanitizeRecover;
217 /// Set of sanitizer checks that trap rather than diagnose.
218 SanitizerSet SanitizeTrap;
220 /// List of backend command-line options for -fembed-bitcode.
221 std::vector<uint8_t> CmdArgs;
223 /// \brief A list of all -fno-builtin-* function names (e.g., memset).
224 std::vector<std::string> NoBuiltinFuncs;
227 // Define accessors/mutators for code generation options of enumeration type.
228 #define CODEGENOPT(Name, Bits, Default)
229 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
230 Type get##Name() const { return static_cast<Type>(Name); } \
231 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
232 #include "clang/Frontend/CodeGenOptions.def"
236 /// \brief Is this a libc/libm function that is no longer recognized as a
237 /// builtin because a -fno-builtin-* option has been specified?
238 bool isNoBuiltinFunc(const char *Name) const;
240 const std::vector<std::string> &getNoBuiltinFuncs() const {
241 return NoBuiltinFuncs;
244 /// \brief Check if Clang profile instrumenation is on.
245 bool hasProfileClangInstr() const {
246 return getProfileInstr() == ProfileClangInstr;
249 /// \brief Check if IR level profile instrumentation is on.
250 bool hasProfileIRInstr() const {
251 return getProfileInstr() == ProfileIRInstr;
254 /// \brief Check if Clang profile use is on.
255 bool hasProfileClangUse() const {
256 return getProfileUse() == ProfileClangInstr;
259 /// \brief Check if IR level profile use is on.
260 bool hasProfileIRUse() const {
261 return getProfileUse() == ProfileIRInstr;
266 } // end namespace clang