• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 with -fprofile-sample-use.
158   std::string SampleProfileFile;
159 
160   /// Name of the profile file to use as input for -fprofile-instr-use
161   std::string InstrProfileInput;
162 
163   /// Regular expression to select optimizations for which we should enable
164   /// optimization remarks. Transformation passes whose name matches this
165   /// expression (and support this feature), will emit a diagnostic
166   /// whenever they perform a transformation. This is enabled by the
167   /// -Rpass=regexp flag.
168   std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
169 
170   /// Regular expression to select optimizations for which we should enable
171   /// missed optimization remarks. Transformation passes whose name matches this
172   /// expression (and support this feature), will emit a diagnostic
173   /// whenever they tried but failed to perform a transformation. This is
174   /// enabled by the -Rpass-missed=regexp flag.
175   std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
176 
177   /// Regular expression to select optimizations for which we should enable
178   /// optimization analyses. Transformation passes whose name matches this
179   /// expression (and support this feature), will emit a diagnostic
180   /// whenever they want to explain why they decided to apply or not apply
181   /// a given transformation. This is enabled by the -Rpass-analysis=regexp
182   /// flag.
183   std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
184 
185   /// Set of files definining the rules for the symbol rewriting.
186   std::vector<std::string> RewriteMapFiles;
187 
188   /// Set of sanitizer checks that are non-fatal (i.e. execution should be
189   /// continued when possible).
190   SanitizerSet SanitizeRecover;
191 
192 public:
193   // Define accessors/mutators for code generation options of enumeration type.
194 #define CODEGENOPT(Name, Bits, Default)
195 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
196   Type get##Name() const { return static_cast<Type>(Name); } \
197   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
198 #include "clang/Frontend/CodeGenOptions.def"
199 
200   CodeGenOptions();
201 };
202 
203 }  // end namespace clang
204 
205 #endif
206