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"
25 /// \brief Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure
26 /// that this large collection of bitfields is a trivial class type.
27 class CodeGenOptionsBase {
29 #define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
30 #define ENUM_CODEGENOPT(Name, Type, Bits, Default)
31 #include "clang/Frontend/CodeGenOptions.def"
34 #define CODEGENOPT(Name, Bits, Default)
35 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
36 #include "clang/Frontend/CodeGenOptions.def"
39 /// CodeGenOptions - Track various options which control how the code
40 /// is optimized and passed to the backend.
41 class CodeGenOptions : public CodeGenOptionsBase {
44 NoInlining, // Perform no inlining whatsoever.
45 NormalInlining, // Use the standard function inlining pass.
46 OnlyAlwaysInlining // Only run the always inlining pass.
49 enum ObjCDispatchMethodKind {
56 NoDebugInfo, /// Don't generate debug info.
58 LocTrackingOnly, /// Emit location information but do not generate
59 /// debug info in the output. This is useful in
60 /// cases where the backend wants to track source
61 /// locations for instructions without actually
62 /// emitting debug info for them (e.g., when -Rpass
65 DebugLineTablesOnly, /// Emit only debug info necessary for generating
66 /// line number tables (-gline-tables-only).
68 LimitedDebugInfo, /// Limit generated debug info to reduce size
69 /// (-fno-standalone-debug). This emits
70 /// forward decls for types that could be
71 /// replaced with forward decls in the source
72 /// code. For dynamic C++ classes type info
73 /// is only emitted int the module that
74 /// contains the classe's vtable.
76 FullDebugInfo /// Generate complete debug info.
80 GeneralDynamicTLSModel,
86 enum FPContractModeKind {
87 FPC_Off, // Form fused FP ops only where result will not be affected.
88 FPC_On, // Form fused FP ops according to FP_CONTRACT rules.
89 FPC_Fast // Aggressively fuse FP ops (E.g. FMA).
92 enum StructReturnConventionKind {
93 SRCK_Default, // No special option was passed.
94 SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return).
95 SRCK_InRegs // Small structs in registers (-freg-struct-return).
98 /// The code model to use (-mcmodel).
99 std::string CodeModel;
101 /// The filename with path we use for coverage files. The extension will be
103 std::string CoverageFile;
105 /// The version string to put into coverage files.
106 char CoverageVersion[4];
108 /// Enable additional debugging information.
109 std::string DebugPass;
111 /// The string to embed in debug information as the current working directory.
112 std::string DebugCompilationDir;
114 /// The string to embed in the debug information for the compile unit, if
116 std::string DwarfDebugFlags;
118 /// The ABI to use for passing floating point arguments.
119 std::string FloatABI;
121 /// The float precision limit to use, if non-empty.
122 std::string LimitFloatPrecision;
124 /// The name of the bitcode file to link before optzns.
125 std::string LinkBitcodeFile;
127 /// The user provided name for the "main file", if non-empty. This is useful
128 /// in situations where the input file name does not match the original input
129 /// file, for example with -save-temps.
130 std::string MainFileName;
132 /// The name for the split debug info file that we'll break out. This is used
133 /// in the backend for setting the name in the skeleton cu.
134 std::string SplitDwarfFile;
136 /// The name of the relocation model to use.
137 std::string RelocationModel;
139 /// The thread model to use
140 std::string ThreadModel;
142 /// If not an empty string, trap intrinsics are lowered to calls to this
143 /// function instead of to trap instructions.
144 std::string TrapFuncName;
146 /// A list of command-line options to forward to the LLVM backend.
147 std::vector<std::string> BackendOptions;
149 /// A list of dependent libraries.
150 std::vector<std::string> DependentLibraries;
152 /// Name of the profile file to use with -fprofile-sample-use.
153 std::string SampleProfileFile;
155 /// Name of the profile file to use as input for -fprofile-instr-use
156 std::string InstrProfileInput;
158 /// Regular expression to select optimizations for which we should enable
159 /// optimization remarks. Transformation passes whose name matches this
160 /// expression (and support this feature), will emit a diagnostic
161 /// whenever they perform a transformation. This is enabled by the
162 /// -Rpass=regexp flag.
163 std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
165 /// Regular expression to select optimizations for which we should enable
166 /// missed optimization remarks. Transformation passes whose name matches this
167 /// expression (and support this feature), will emit a diagnostic
168 /// whenever they tried but failed to perform a transformation. This is
169 /// enabled by the -Rpass-missed=regexp flag.
170 std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
172 /// Regular expression to select optimizations for which we should enable
173 /// optimization analyses. Transformation passes whose name matches this
174 /// expression (and support this feature), will emit a diagnostic
175 /// whenever they want to explain why they decided to apply or not apply
176 /// a given transformation. This is enabled by the -Rpass-analysis=regexp
178 std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
180 /// Set of files definining the rules for the symbol rewriting.
181 std::vector<std::string> RewriteMapFiles;
183 /// Set of sanitizer checks that are non-fatal (i.e. execution should be
184 /// continued when possible).
185 SanitizerSet SanitizeRecover;
188 // Define accessors/mutators for code generation options of enumeration type.
189 #define CODEGENOPT(Name, Bits, Default)
190 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
191 Type get##Name() const { return static_cast<Type>(Name); } \
192 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
193 #include "clang/Frontend/CodeGenOptions.def"
198 } // end namespace clang