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/Sanitizers.h"
18 #include "clang/Driver/DebugInfoKind.h"
19 #include "llvm/Support/Regex.h"
27 /// \brief Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure
28 /// that this large collection of bitfields is a trivial class type.
29 class CodeGenOptionsBase {
31 #define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
32 #define ENUM_CODEGENOPT(Name, Type, Bits, Default)
33 #include "clang/Frontend/CodeGenOptions.def"
36 #define CODEGENOPT(Name, Bits, Default)
37 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
38 #include "clang/Frontend/CodeGenOptions.def"
41 /// CodeGenOptions - Track various options which control how the code
42 /// is optimized and passed to the backend.
43 class CodeGenOptions : public CodeGenOptionsBase {
46 NoInlining, // Perform no inlining whatsoever.
47 NormalInlining, // Use the standard function inlining pass.
48 OnlyAlwaysInlining // Only run the always inlining pass.
52 NoLibrary, // Don't use any vector library.
53 Accelerate // Use the Accelerate framework.
56 enum ObjCDispatchMethodKind {
70 GeneralDynamicTLSModel,
76 enum FPContractModeKind {
77 FPC_Off, // Form fused FP ops only where result will not be affected.
78 FPC_On, // Form fused FP ops according to FP_CONTRACT rules.
79 FPC_Fast // Aggressively fuse FP ops (E.g. FMA).
82 enum StructReturnConventionKind {
83 SRCK_Default, // No special option was passed.
84 SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return).
85 SRCK_InRegs // Small structs in registers (-freg-struct-return).
88 enum ProfileInstrKind {
89 ProfileNoInstr, // No instrumentation.
90 ProfileClangInstr // Clang instrumentation to generate execution counts
94 /// The code model to use (-mcmodel).
95 std::string CodeModel;
97 /// The filename with path we use for coverage files. The extension will be
99 std::string CoverageFile;
101 /// The version string to put into coverage files.
102 char CoverageVersion[4];
104 /// Enable additional debugging information.
105 std::string DebugPass;
107 /// The string to embed in debug information as the current working directory.
108 std::string DebugCompilationDir;
110 /// The string to embed in the debug information for the compile unit, if
112 std::string DwarfDebugFlags;
114 std::map<std::string, std::string> DebugPrefixMap;
116 /// The ABI to use for passing floating point arguments.
117 std::string FloatABI;
119 /// The float precision limit to use, if non-empty.
120 std::string LimitFloatPrecision;
122 /// The name of the bitcode file to link before optzns.
123 std::vector<std::pair<unsigned, std::string>> LinkBitcodeFiles;
125 /// The user provided name for the "main file", if non-empty. This is useful
126 /// in situations where the input file name does not match the original input
127 /// file, for example with -save-temps.
128 std::string MainFileName;
130 /// The name for the split debug info file that we'll break out. This is used
131 /// in the backend for setting the name in the skeleton cu.
132 std::string SplitDwarfFile;
134 /// The name of the relocation model to use.
135 std::string RelocationModel;
137 /// The thread model to use
138 std::string ThreadModel;
140 /// If not an empty string, trap intrinsics are lowered to calls to this
141 /// function instead of to trap instructions.
142 std::string TrapFuncName;
144 /// A list of command-line options to forward to the LLVM backend.
145 std::vector<std::string> BackendOptions;
147 /// A list of dependent libraries.
148 std::vector<std::string> DependentLibraries;
150 /// A list of linker options to embed in the object file.
151 std::vector<std::string> LinkerOptions;
153 /// Name of the profile file to use as output for -fprofile-instr-generate
154 /// and -fprofile-generate.
155 std::string InstrProfileOutput;
157 /// Name of the profile file to use with -fprofile-sample-use.
158 std::string SampleProfileFile;
160 /// Name of the profile file to use as input for -fprofile-instr-use
161 std::string InstrProfileInput;
163 /// Name of the function summary index file to use for ThinLTO function
165 std::string ThinLTOIndexFile;
167 /// The EABI version to use
168 std::string EABIVersion;
170 /// A list of file names passed with -fcuda-include-gpubinary options to
171 /// forward to CUDA runtime back-end for incorporating them into host-side
173 std::vector<std::string> CudaGpuBinaryFileNames;
175 /// Regular expression to select optimizations for which we should enable
176 /// optimization remarks. Transformation passes whose name matches this
177 /// expression (and support this feature), will emit a diagnostic
178 /// whenever they perform a transformation. This is enabled by the
179 /// -Rpass=regexp flag.
180 std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
182 /// Regular expression to select optimizations for which we should enable
183 /// missed optimization remarks. Transformation passes whose name matches this
184 /// expression (and support this feature), will emit a diagnostic
185 /// whenever they tried but failed to perform a transformation. This is
186 /// enabled by the -Rpass-missed=regexp flag.
187 std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
189 /// Regular expression to select optimizations for which we should enable
190 /// optimization analyses. Transformation passes whose name matches this
191 /// expression (and support this feature), will emit a diagnostic
192 /// whenever they want to explain why they decided to apply or not apply
193 /// a given transformation. This is enabled by the -Rpass-analysis=regexp
195 std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
197 /// Set of files definining the rules for the symbol rewriting.
198 std::vector<std::string> RewriteMapFiles;
200 /// Set of sanitizer checks that are non-fatal (i.e. execution should be
201 /// continued when possible).
202 SanitizerSet SanitizeRecover;
204 /// Set of sanitizer checks that trap rather than diagnose.
205 SanitizerSet SanitizeTrap;
207 /// \brief A list of all -fno-builtin-* function names (e.g., memset).
208 std::vector<std::string> NoBuiltinFuncs;
211 // Define accessors/mutators for code generation options of enumeration type.
212 #define CODEGENOPT(Name, Bits, Default)
213 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
214 Type get##Name() const { return static_cast<Type>(Name); } \
215 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
216 #include "clang/Frontend/CodeGenOptions.def"
220 /// \brief Is this a libc/libm function that is no longer recognized as a
221 /// builtin because a -fno-builtin-* option has been specified?
222 bool isNoBuiltinFunc(const char *Name) const;
224 const std::vector<std::string> &getNoBuiltinFuncs() const {
225 return NoBuiltinFuncs;
228 /// \brief Check if Clang profile instrumenation is on.
229 bool hasProfileClangInstr() const {
230 return getProfileInstr() == ProfileClangInstr;
234 } // end namespace clang