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 "llvm/Support/Regex.h"
26 /// \brief Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure
27 /// that this large collection of bitfields is a trivial class type.
28 class CodeGenOptionsBase {
30 #define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
31 #define ENUM_CODEGENOPT(Name, Type, Bits, Default)
32 #include "clang/Frontend/CodeGenOptions.def"
35 #define CODEGENOPT(Name, Bits, Default)
36 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
37 #include "clang/Frontend/CodeGenOptions.def"
40 /// CodeGenOptions - Track various options which control how the code
41 /// is optimized and passed to the backend.
42 class CodeGenOptions : public CodeGenOptionsBase {
45 NoInlining, // Perform no inlining whatsoever.
46 NormalInlining, // Use the standard function inlining pass.
47 OnlyAlwaysInlining // Only run the always inlining pass.
51 NoLibrary, // Don't use any vector library.
52 Accelerate // Use the Accelerate framework.
55 enum ObjCDispatchMethodKind {
62 NoDebugInfo, /// Don't generate debug info.
64 LocTrackingOnly, /// Emit location information but do not generate
65 /// debug info in the output. This is useful in
66 /// cases where the backend wants to track source
67 /// locations for instructions without actually
68 /// emitting debug info for them (e.g., when -Rpass
71 DebugLineTablesOnly, /// Emit only debug info necessary for generating
72 /// line number tables (-gline-tables-only).
74 LimitedDebugInfo, /// Limit generated debug info to reduce size
75 /// (-fno-standalone-debug). This emits
76 /// forward decls for types that could be
77 /// replaced with forward decls in the source
78 /// code. For dynamic C++ classes type info
79 /// is only emitted int the module that
80 /// contains the classe's vtable.
82 FullDebugInfo /// Generate complete debug info.
93 GeneralDynamicTLSModel,
99 enum FPContractModeKind {
100 FPC_Off, // Form fused FP ops only where result will not be affected.
101 FPC_On, // Form fused FP ops according to FP_CONTRACT rules.
102 FPC_Fast // Aggressively fuse FP ops (E.g. FMA).
105 enum StructReturnConventionKind {
106 SRCK_Default, // No special option was passed.
107 SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return).
108 SRCK_InRegs // Small structs in registers (-freg-struct-return).
111 /// The code model to use (-mcmodel).
112 std::string CodeModel;
114 /// The filename with path we use for coverage files. The extension will be
116 std::string CoverageFile;
118 /// The version string to put into coverage files.
119 char CoverageVersion[4];
121 /// Enable additional debugging information.
122 std::string DebugPass;
124 /// The string to embed in debug information as the current working directory.
125 std::string DebugCompilationDir;
127 /// The string to embed in the debug information for the compile unit, if
129 std::string DwarfDebugFlags;
131 std::map<std::string, std::string> DebugPrefixMap;
133 /// The ABI to use for passing floating point arguments.
134 std::string FloatABI;
136 /// The float precision limit to use, if non-empty.
137 std::string LimitFloatPrecision;
139 /// The name of the bitcode file to link before optzns.
140 std::vector<std::pair<unsigned, std::string>> LinkBitcodeFiles;
142 /// The user provided name for the "main file", if non-empty. This is useful
143 /// in situations where the input file name does not match the original input
144 /// file, for example with -save-temps.
145 std::string MainFileName;
147 /// The name for the split debug info file that we'll break out. This is used
148 /// in the backend for setting the name in the skeleton cu.
149 std::string SplitDwarfFile;
151 /// The name of the relocation model to use.
152 std::string RelocationModel;
154 /// The thread model to use
155 std::string ThreadModel;
157 /// If not an empty string, trap intrinsics are lowered to calls to this
158 /// function instead of to trap instructions.
159 std::string TrapFuncName;
161 /// A list of command-line options to forward to the LLVM backend.
162 std::vector<std::string> BackendOptions;
164 /// A list of dependent libraries.
165 std::vector<std::string> DependentLibraries;
167 /// Name of the profile file to use as output for -fprofile-instr-generate
168 /// and -fprofile-generate.
169 std::string InstrProfileOutput;
171 /// Name of the profile file to use with -fprofile-sample-use.
172 std::string SampleProfileFile;
174 /// Name of the profile file to use as input for -fprofile-instr-use
175 std::string InstrProfileInput;
177 /// Name of the function summary index file to use for ThinLTO function
179 std::string ThinLTOIndexFile;
181 /// The EABI version to use
182 std::string EABIVersion;
184 /// A list of file names passed with -fcuda-include-gpubinary options to
185 /// forward to CUDA runtime back-end for incorporating them into host-side
187 std::vector<std::string> CudaGpuBinaryFileNames;
189 /// Regular expression to select optimizations for which we should enable
190 /// optimization remarks. Transformation passes whose name matches this
191 /// expression (and support this feature), will emit a diagnostic
192 /// whenever they perform a transformation. This is enabled by the
193 /// -Rpass=regexp flag.
194 std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
196 /// Regular expression to select optimizations for which we should enable
197 /// missed optimization remarks. Transformation passes whose name matches this
198 /// expression (and support this feature), will emit a diagnostic
199 /// whenever they tried but failed to perform a transformation. This is
200 /// enabled by the -Rpass-missed=regexp flag.
201 std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
203 /// Regular expression to select optimizations for which we should enable
204 /// optimization analyses. Transformation passes whose name matches this
205 /// expression (and support this feature), will emit a diagnostic
206 /// whenever they want to explain why they decided to apply or not apply
207 /// a given transformation. This is enabled by the -Rpass-analysis=regexp
209 std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
211 /// Set of files definining the rules for the symbol rewriting.
212 std::vector<std::string> RewriteMapFiles;
214 /// Set of sanitizer checks that are non-fatal (i.e. execution should be
215 /// continued when possible).
216 SanitizerSet SanitizeRecover;
218 /// Set of sanitizer checks that trap rather than diagnose.
219 SanitizerSet SanitizeTrap;
222 // Define accessors/mutators for code generation options of enumeration type.
223 #define CODEGENOPT(Name, Bits, Default)
224 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
225 Type get##Name() const { return static_cast<Type>(Name); } \
226 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
227 #include "clang/Frontend/CodeGenOptions.def"
232 } // end namespace clang