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.
50 NoLibrary, // Don't use any vector library.
51 Accelerate // Use the Accelerate framework.
54 enum ObjCDispatchMethodKind {
61 NoDebugInfo, /// Don't generate debug info.
63 LocTrackingOnly, /// Emit location information but do not generate
64 /// debug info in the output. This is useful in
65 /// cases where the backend wants to track source
66 /// locations for instructions without actually
67 /// emitting debug info for them (e.g., when -Rpass
70 DebugLineTablesOnly, /// Emit only debug info necessary for generating
71 /// line number tables (-gline-tables-only).
73 LimitedDebugInfo, /// Limit generated debug info to reduce size
74 /// (-fno-standalone-debug). This emits
75 /// forward decls for types that could be
76 /// replaced with forward decls in the source
77 /// code. For dynamic C++ classes type info
78 /// is only emitted int the module that
79 /// contains the classe's vtable.
81 FullDebugInfo /// Generate complete debug info.
85 GeneralDynamicTLSModel,
91 enum FPContractModeKind {
92 FPC_Off, // Form fused FP ops only where result will not be affected.
93 FPC_On, // Form fused FP ops according to FP_CONTRACT rules.
94 FPC_Fast // Aggressively fuse FP ops (E.g. FMA).
97 enum StructReturnConventionKind {
98 SRCK_Default, // No special option was passed.
99 SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return).
100 SRCK_InRegs // Small structs in registers (-freg-struct-return).
103 /// The code model to use (-mcmodel).
104 std::string CodeModel;
106 /// The filename with path we use for coverage files. The extension will be
108 std::string CoverageFile;
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 /// The ABI to use for passing floating point arguments.
124 std::string FloatABI;
126 /// The float precision limit to use, if non-empty.
127 std::string LimitFloatPrecision;
129 /// The name of the bitcode file to link before optzns.
130 std::string LinkBitcodeFile;
132 /// The user provided name for the "main file", if non-empty. This is useful
133 /// in situations where the input file name does not match the original input
134 /// file, for example with -save-temps.
135 std::string MainFileName;
137 /// The name for the split debug info file that we'll break out. This is used
138 /// in the backend for setting the name in the skeleton cu.
139 std::string SplitDwarfFile;
141 /// The name of the relocation model to use.
142 std::string RelocationModel;
144 /// The thread model to use
145 std::string ThreadModel;
147 /// If not an empty string, trap intrinsics are lowered to calls to this
148 /// function instead of to trap instructions.
149 std::string TrapFuncName;
151 /// A list of command-line options to forward to the LLVM backend.
152 std::vector<std::string> BackendOptions;
154 /// A list of dependent libraries.
155 std::vector<std::string> DependentLibraries;
157 /// Name of the profile file to use as output for -fprofile-instr-generate
158 std::string InstrProfileOutput;
160 /// Name of the profile file to use with -fprofile-sample-use.
161 std::string SampleProfileFile;
163 /// Name of the profile file to use as input for -fprofile-instr-use
164 std::string InstrProfileInput;
166 /// A list of file names passed with -fcuda-include-gpubinary options to
167 /// forward to CUDA runtime back-end for incorporating them into host-side
169 std::vector<std::string> CudaGpuBinaryFileNames;
171 /// Regular expression to select optimizations for which we should enable
172 /// optimization remarks. Transformation passes whose name matches this
173 /// expression (and support this feature), will emit a diagnostic
174 /// whenever they perform a transformation. This is enabled by the
175 /// -Rpass=regexp flag.
176 std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
178 /// Regular expression to select optimizations for which we should enable
179 /// missed optimization remarks. Transformation passes whose name matches this
180 /// expression (and support this feature), will emit a diagnostic
181 /// whenever they tried but failed to perform a transformation. This is
182 /// enabled by the -Rpass-missed=regexp flag.
183 std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
185 /// Regular expression to select optimizations for which we should enable
186 /// optimization analyses. Transformation passes whose name matches this
187 /// expression (and support this feature), will emit a diagnostic
188 /// whenever they want to explain why they decided to apply or not apply
189 /// a given transformation. This is enabled by the -Rpass-analysis=regexp
191 std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
193 /// Set of files definining the rules for the symbol rewriting.
194 std::vector<std::string> RewriteMapFiles;
196 /// Set of sanitizer checks that are non-fatal (i.e. execution should be
197 /// continued when possible).
198 SanitizerSet SanitizeRecover;
200 /// Set of sanitizer checks that trap rather than diagnose.
201 SanitizerSet SanitizeTrap;
204 // Define accessors/mutators for code generation options of enumeration type.
205 #define CODEGENOPT(Name, Bits, Default)
206 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
207 Type get##Name() const { return static_cast<Type>(Name); } \
208 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
209 #include "clang/Frontend/CodeGenOptions.def"
214 } // end namespace clang