]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/clang/Frontend/CodeGenOptions.h
Vendor import of clang trunk r242221:
[FreeBSD/FreeBSD.git] / include / clang / Frontend / CodeGenOptions.h
1 //===--- CodeGenOptions.h ---------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  This file defines the CodeGenOptions interface.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
15 #define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
16
17 #include "clang/Basic/Sanitizers.h"
18 #include "llvm/Support/Regex.h"
19 #include <memory>
20 #include <string>
21 #include <vector>
22
23 namespace clang {
24
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 {
28 public:
29 #define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
30 #define ENUM_CODEGENOPT(Name, Type, Bits, Default)
31 #include "clang/Frontend/CodeGenOptions.def"
32
33 protected:
34 #define CODEGENOPT(Name, Bits, Default)
35 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
36 #include "clang/Frontend/CodeGenOptions.def"
37 };
38
39 /// CodeGenOptions - Track various options which control how the code
40 /// is optimized and passed to the backend.
41 class CodeGenOptions : public CodeGenOptionsBase {
42 public:
43   enum InliningMethod {
44     NoInlining,         // Perform no inlining whatsoever.
45     NormalInlining,     // Use the standard function inlining pass.
46     OnlyAlwaysInlining  // Only run the always inlining pass.
47   };
48
49   enum VectorLibrary {
50     NoLibrary, // Don't use any vector library.
51     Accelerate // Use the Accelerate framework.
52   };
53
54   enum ObjCDispatchMethodKind {
55     Legacy = 0,
56     NonLegacy = 1,
57     Mixed = 2
58   };
59
60   enum DebugInfoKind {
61     NoDebugInfo,          /// Don't generate debug info.
62
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
68                           /// is used).
69
70     DebugLineTablesOnly,  /// Emit only debug info necessary for generating
71                           /// line number tables (-gline-tables-only).
72
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.
80
81     FullDebugInfo         /// Generate complete debug info.
82   };
83
84   enum TLSModel {
85     GeneralDynamicTLSModel,
86     LocalDynamicTLSModel,
87     InitialExecTLSModel,
88     LocalExecTLSModel
89   };
90
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).
95   };
96
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).
101   };
102
103   /// The code model to use (-mcmodel).
104   std::string CodeModel;
105
106   /// The filename with path we use for coverage files. The extension will be
107   /// replaced.
108   std::string CoverageFile;
109
110   /// The version string to put into coverage files.
111   char CoverageVersion[4];
112
113   /// Enable additional debugging information.
114   std::string DebugPass;
115
116   /// The string to embed in debug information as the current working directory.
117   std::string DebugCompilationDir;
118
119   /// The string to embed in the debug information for the compile unit, if
120   /// non-empty.
121   std::string DwarfDebugFlags;
122
123   /// The ABI to use for passing floating point arguments.
124   std::string FloatABI;
125
126   /// The float precision limit to use, if non-empty.
127   std::string LimitFloatPrecision;
128
129   /// The name of the bitcode file to link before optzns.
130   std::string LinkBitcodeFile;
131
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;
136
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;
140
141   /// The name of the relocation model to use.
142   std::string RelocationModel;
143
144   /// The thread model to use
145   std::string ThreadModel;
146
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;
150
151   /// A list of command-line options to forward to the LLVM backend.
152   std::vector<std::string> BackendOptions;
153
154   /// A list of dependent libraries.
155   std::vector<std::string> DependentLibraries;
156
157   /// Name of the profile file to use as output for -fprofile-instr-generate
158   /// and -fprofile-generate.
159   std::string InstrProfileOutput;
160
161   /// Name of the profile file to use with -fprofile-sample-use.
162   std::string SampleProfileFile;
163
164   /// Name of the profile file to use as input for -fprofile-instr-use
165   std::string InstrProfileInput;
166
167   /// A list of file names passed with -fcuda-include-gpubinary options to
168   /// forward to CUDA runtime back-end for incorporating them into host-side
169   /// object file.
170   std::vector<std::string> CudaGpuBinaryFileNames;
171
172   /// Regular expression to select optimizations for which we should enable
173   /// optimization remarks. Transformation passes whose name matches this
174   /// expression (and support this feature), will emit a diagnostic
175   /// whenever they perform a transformation. This is enabled by the
176   /// -Rpass=regexp flag.
177   std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
178
179   /// Regular expression to select optimizations for which we should enable
180   /// missed optimization remarks. Transformation passes whose name matches this
181   /// expression (and support this feature), will emit a diagnostic
182   /// whenever they tried but failed to perform a transformation. This is
183   /// enabled by the -Rpass-missed=regexp flag.
184   std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
185
186   /// Regular expression to select optimizations for which we should enable
187   /// optimization analyses. Transformation passes whose name matches this
188   /// expression (and support this feature), will emit a diagnostic
189   /// whenever they want to explain why they decided to apply or not apply
190   /// a given transformation. This is enabled by the -Rpass-analysis=regexp
191   /// flag.
192   std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
193
194   /// Set of files definining the rules for the symbol rewriting.
195   std::vector<std::string> RewriteMapFiles;
196
197   /// Set of sanitizer checks that are non-fatal (i.e. execution should be
198   /// continued when possible).
199   SanitizerSet SanitizeRecover;
200
201   /// Set of sanitizer checks that trap rather than diagnose.
202   SanitizerSet SanitizeTrap;
203
204 public:
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"
211
212   CodeGenOptions();
213 };
214
215 }  // end namespace clang
216
217 #endif