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
19 #include "llvm/Support/Regex.h"
23 /// \brief Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure
24 /// that this large collection of bitfields is a trivial class type.
25 class CodeGenOptionsBase {
27 #define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
28 #define ENUM_CODEGENOPT(Name, Type, Bits, Default)
29 #include "clang/Frontend/CodeGenOptions.def"
32 #define CODEGENOPT(Name, Bits, Default)
33 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
34 #include "clang/Frontend/CodeGenOptions.def"
37 /// CodeGenOptions - Track various options which control how the code
38 /// is optimized and passed to the backend.
39 class CodeGenOptions : public CodeGenOptionsBase {
42 NoInlining, // Perform no inlining whatsoever.
43 NormalInlining, // Use the standard function inlining pass.
44 OnlyAlwaysInlining // Only run the always inlining pass.
47 enum ObjCDispatchMethodKind {
54 NoDebugInfo, /// Don't generate debug info.
56 LocTrackingOnly, /// Emit location information but do not generate
57 /// debug info in the output. This is useful in
58 /// cases where the backend wants to track source
59 /// locations for instructions without actually
60 /// emitting debug info for them (e.g., when -Rpass
63 DebugLineTablesOnly, /// Emit only debug info necessary for generating
64 /// line number tables (-gline-tables-only).
66 LimitedDebugInfo, /// Limit generated debug info to reduce size
67 /// (-fno-standalone-debug). This emits
68 /// forward decls for types that could be
69 /// replaced with forward decls in the source
70 /// code. For dynamic C++ classes type info
71 /// is only emitted int the module that
72 /// contains the classe's vtable.
74 FullDebugInfo /// Generate complete debug info.
78 GeneralDynamicTLSModel,
84 enum FPContractModeKind {
85 FPC_Off, // Form fused FP ops only where result will not be affected.
86 FPC_On, // Form fused FP ops according to FP_CONTRACT rules.
87 FPC_Fast // Aggressively fuse FP ops (E.g. FMA).
90 enum StructReturnConventionKind {
91 SRCK_Default, // No special option was passed.
92 SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return).
93 SRCK_InRegs // Small structs in registers (-freg-struct-return).
96 /// The code model to use (-mcmodel).
97 std::string CodeModel;
99 /// The filename with path we use for coverage files. The extension will be
101 std::string CoverageFile;
103 /// The version string to put into coverage files.
104 char CoverageVersion[4];
106 /// Enable additional debugging information.
107 std::string DebugPass;
109 /// The string to embed in debug information as the current working directory.
110 std::string DebugCompilationDir;
112 /// The string to embed in the debug information for the compile unit, if
114 std::string DwarfDebugFlags;
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::string LinkBitcodeFile;
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 /// Path to blacklist file for sanitizers.
138 std::string SanitizerBlacklistFile;
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 /// Name of the profile file to use with -fprofile-sample-use.
151 std::string SampleProfileFile;
153 /// Name of the profile file to use as input for -fprofile-instr-use
154 std::string InstrProfileInput;
156 /// Regular expression to select optimizations for which we should enable
157 /// optimization remarks. Transformation passes whose name matches this
158 /// expression (and support this feature), will emit a diagnostic
159 /// whenever they perform a transformation. This is enabled by the
160 /// -Rpass=regexp flag.
161 std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
163 /// Regular expression to select optimizations for which we should enable
164 /// missed optimization remarks. Transformation passes whose name matches this
165 /// expression (and support this feature), will emit a diagnostic
166 /// whenever they tried but failed to perform a transformation. This is
167 /// enabled by the -Rpass-missed=regexp flag.
168 std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
170 /// Regular expression to select optimizations for which we should enable
171 /// optimization analyses. Transformation passes whose name matches this
172 /// expression (and support this feature), will emit a diagnostic
173 /// whenever they want to explain why they decided to apply or not apply
174 /// a given transformation. This is enabled by the -Rpass-analysis=regexp
176 std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
179 // Define accessors/mutators for code generation options of enumeration type.
180 #define CODEGENOPT(Name, Bits, Default)
181 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
182 Type get##Name() const { return static_cast<Type>(Name); } \
183 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
184 #include "clang/Frontend/CodeGenOptions.def"
187 #define CODEGENOPT(Name, Bits, Default) Name = Default;
188 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
190 #include "clang/Frontend/CodeGenOptions.def"
192 RelocationModel = "pic";
193 memcpy(CoverageVersion, "402*", 4);
197 } // end namespace clang