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 OnlyAlwaysInlining // Only run the always inlining pass.
53 NoLibrary, // Don't use any vector library.
54 Accelerate // Use the Accelerate framework.
57 enum ObjCDispatchMethodKind {
64 GeneralDynamicTLSModel,
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).
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).
82 enum ProfileInstrKind {
83 ProfileNoInstr, // No instrumentation.
84 ProfileClangInstr // Clang instrumentation to generate execution counts
88 /// The code model to use (-mcmodel).
89 std::string CodeModel;
91 /// The filename with path we use for coverage files. The extension will be
93 std::string CoverageFile;
95 /// The version string to put into coverage files.
96 char CoverageVersion[4];
98 /// Enable additional debugging information.
99 std::string DebugPass;
101 /// The string to embed in debug information as the current working directory.
102 std::string DebugCompilationDir;
104 /// The string to embed in the debug information for the compile unit, if
106 std::string DwarfDebugFlags;
108 std::map<std::string, std::string> DebugPrefixMap;
110 /// The ABI to use for passing floating point arguments.
111 std::string FloatABI;
113 /// The float precision limit to use, if non-empty.
114 std::string LimitFloatPrecision;
116 /// The name of the bitcode file to link before optzns.
117 std::vector<std::pair<unsigned, std::string>> LinkBitcodeFiles;
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;
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;
128 /// The name of the relocation model to use.
129 std::string RelocationModel;
131 /// The thread model to use
132 std::string ThreadModel;
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;
138 /// A list of command-line options to forward to the LLVM backend.
139 std::vector<std::string> BackendOptions;
141 /// A list of dependent libraries.
142 std::vector<std::string> DependentLibraries;
144 /// A list of linker options to embed in the object file.
145 std::vector<std::string> LinkerOptions;
147 /// Name of the profile file to use as output for -fprofile-instr-generate
148 /// and -fprofile-generate.
149 std::string InstrProfileOutput;
151 /// Name of the profile file to use with -fprofile-sample-use.
152 std::string SampleProfileFile;
154 /// Name of the profile file to use as input for -fprofile-instr-use
155 std::string InstrProfileInput;
157 /// Name of the function summary index file to use for ThinLTO function
159 std::string ThinLTOIndexFile;
161 /// The EABI version to use
162 std::string EABIVersion;
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
167 std::vector<std::string> CudaGpuBinaryFileNames;
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;
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;
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
189 std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
191 /// Set of files definining the rules for the symbol rewriting.
192 std::vector<std::string> RewriteMapFiles;
194 /// Set of sanitizer checks that are non-fatal (i.e. execution should be
195 /// continued when possible).
196 SanitizerSet SanitizeRecover;
198 /// Set of sanitizer checks that trap rather than diagnose.
199 SanitizerSet SanitizeTrap;
201 /// \brief A list of all -fno-builtin-* function names (e.g., memset).
202 std::vector<std::string> NoBuiltinFuncs;
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"
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;
218 const std::vector<std::string> &getNoBuiltinFuncs() const {
219 return NoBuiltinFuncs;
222 /// \brief Check if Clang profile instrumenation is on.
223 bool hasProfileClangInstr() const {
224 return getProfileInstr() == ProfileClangInstr;
228 } // end namespace clang