]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h
Replace our version of the pwcache(3) API with NetBSD's implementation.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / 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 <string>
18 #include <vector>
19
20 namespace clang {
21
22 /// CodeGenOptions - Track various options which control how the code
23 /// is optimized and passed to the backend.
24 class CodeGenOptions {
25 public:
26   enum InliningMethod {
27     NoInlining,         // Perform no inlining whatsoever.
28     NormalInlining,     // Use the standard function inlining pass.
29     OnlyAlwaysInlining  // Only run the always inlining pass.
30   };
31
32   enum ObjCDispatchMethodKind {
33     Legacy = 0,
34     NonLegacy = 1,
35     Mixed = 2
36   };
37
38   enum DebugInfoKind {
39     NoDebugInfo,          // Don't generate debug info.
40     DebugLineTablesOnly,  // Emit only debug info necessary for generating
41                           // line number tables (-gline-tables-only).
42     LimitedDebugInfo,     // Limit generated debug info to reduce size
43                           // (-flimit-debug-info).
44     FullDebugInfo         // Generate complete debug info.
45   };
46
47   enum TLSModel {
48     GeneralDynamicTLSModel,
49     LocalDynamicTLSModel,
50     InitialExecTLSModel,
51     LocalExecTLSModel
52   };
53
54   unsigned AsmVerbose        : 1; ///< -dA, -fverbose-asm.
55   unsigned ObjCAutoRefCountExceptions : 1; ///< Whether ARC should be EH-safe.
56   unsigned CUDAIsDevice      : 1; ///< Set when compiling for CUDA device.
57   unsigned CXAAtExit         : 1; ///< Use __cxa_atexit for calling destructors.
58   unsigned CXXCtorDtorAliases: 1; ///< Emit complete ctors/dtors as linker
59                                   ///< aliases to base ctors when possible.
60   unsigned DataSections      : 1; ///< Set when -fdata-sections is enabled.
61   unsigned DisableFPElim     : 1; ///< Set when -fomit-frame-pointer is enabled.
62   unsigned DisableLLVMOpts   : 1; ///< Don't run any optimizations, for use in
63                                   ///< getting .bc files that correspond to the
64                                   ///< internal state before optimizations are
65                                   ///< done.
66   unsigned DisableRedZone    : 1; ///< Set when -mno-red-zone is enabled.
67   unsigned DisableTailCalls  : 1; ///< Do not emit tail calls.
68   unsigned EmitDeclMetadata  : 1; ///< Emit special metadata indicating what
69                                   ///< Decl* various IR entities came from. Only
70                                   ///< useful when running CodeGen as a
71                                   ///< subroutine.
72   unsigned EmitGcovArcs      : 1; ///< Emit coverage data files, aka. GCDA.
73   unsigned EmitGcovNotes     : 1; ///< Emit coverage "notes" files, aka GCNO.
74   unsigned EmitOpenCLArgMetadata : 1; ///< Emit OpenCL kernel arg metadata.
75   unsigned EmitMicrosoftInlineAsm : 1; ///< Enable emission of MS-style inline
76                                        ///< assembly.
77   unsigned ForbidGuardVariables : 1; ///< Issue errors if C++ guard variables
78                                      ///< are required.
79   unsigned FunctionSections  : 1; ///< Set when -ffunction-sections is enabled.
80   unsigned HiddenWeakTemplateVTables : 1; ///< Emit weak vtables and RTTI for
81                                   ///< template classes with hidden visibility
82   unsigned HiddenWeakVTables : 1; ///< Emit weak vtables, RTTI, and thunks with
83                                   ///< hidden visibility.
84   unsigned InstrumentFunctions : 1; ///< Set when -finstrument-functions is
85                                     ///< enabled.
86   unsigned InstrumentForProfiling : 1; ///< Set when -pg is enabled.
87   unsigned LessPreciseFPMAD  : 1; ///< Enable less precise MAD instructions to
88                                   ///< be generated.
89   unsigned MergeAllConstants : 1; ///< Merge identical constants.
90   unsigned NoCommon          : 1; ///< Set when -fno-common or C++ is enabled.
91   unsigned NoDwarf2CFIAsm    : 1; ///< Set when -fno-dwarf2-cfi-asm is enabled.
92   unsigned NoDwarfDirectoryAsm : 1; ///< Set when -fno-dwarf-directory-asm is
93                                     ///< enabled.
94   unsigned NoExecStack       : 1; ///< Set when -Wa,--noexecstack is enabled.
95   unsigned NoGlobalMerge     : 1; ///< Set when -mno-global-merge is enabled.
96   unsigned NoImplicitFloat   : 1; ///< Set when -mno-implicit-float is enabled.
97   unsigned NoInfsFPMath      : 1; ///< Assume FP arguments, results not +-Inf.
98   unsigned NoInline          : 1; ///< Set when -fno-inline is enabled. Disables
99                                   ///< use of the inline keyword.
100   unsigned NoNaNsFPMath      : 1; ///< Assume FP arguments, results not NaN.
101   unsigned NoZeroInitializedInBSS : 1; ///< -fno-zero-initialized-in-bss.
102   unsigned ObjCDispatchMethod : 2; ///< Method of Objective-C dispatch to use.
103   unsigned OmitLeafFramePointer : 1; ///< Set when -momit-leaf-frame-pointer is
104                                      ///< enabled.
105   unsigned OptimizationLevel : 3; ///< The -O[0-4] option specified.
106   unsigned OptimizeSize      : 2; ///< If -Os (==1) or -Oz (==2) is specified.
107   unsigned RelaxAll          : 1; ///< Relax all machine code instructions.
108   unsigned RelaxedAliasing   : 1; ///< Set when -fno-strict-aliasing is enabled.
109   unsigned SaveTempLabels    : 1; ///< Save temporary labels.
110   unsigned SimplifyLibCalls  : 1; ///< Set when -fbuiltin is enabled.
111   unsigned SoftFloat         : 1; ///< -soft-float.
112   unsigned StrictEnums       : 1; ///< Optimize based on strict enum definition.
113   unsigned TimePasses        : 1; ///< Set when -ftime-report is enabled.
114   unsigned UnitAtATime       : 1; ///< Unused. For mirroring GCC optimization
115                                   ///< selection.
116   unsigned UnrollLoops       : 1; ///< Control whether loops are unrolled.
117   unsigned UnsafeFPMath      : 1; ///< Allow unsafe floating point optzns.
118   unsigned UnwindTables      : 1; ///< Emit unwind tables.
119
120   /// Attempt to use register sized accesses to bit-fields in structures, when
121   /// possible.
122   unsigned UseRegisterSizedBitfieldAccess : 1;
123
124   unsigned VerifyModule      : 1; ///< Control whether the module should be run
125                                   ///< through the LLVM Verifier.
126
127   unsigned StackRealignment  : 1; ///< Control whether to permit stack
128                                   ///< realignment.
129   unsigned UseInitArray      : 1; ///< Control whether to use .init_array or
130                                   ///< .ctors.
131   unsigned StackAlignment;        ///< Overrides default stack alignment,
132                                   ///< if not 0.
133
134   /// The code model to use (-mcmodel).
135   std::string CodeModel;
136
137   /// The filename with path we use for coverage files. The extension will be
138   /// replaced.
139   std::string CoverageFile;
140
141   /// Enable additional debugging information.
142   std::string DebugPass;
143
144   /// The string to embed in debug information as the current working directory.
145   std::string DebugCompilationDir;
146
147   /// The kind of generated debug info.
148   DebugInfoKind DebugInfo;
149
150   /// The string to embed in the debug information for the compile unit, if
151   /// non-empty.
152   std::string DwarfDebugFlags;
153
154   /// The ABI to use for passing floating point arguments.
155   std::string FloatABI;
156
157   /// The float precision limit to use, if non-empty.
158   std::string LimitFloatPrecision;
159
160   /// The name of the bitcode file to link before optzns.
161   std::string LinkBitcodeFile;
162
163   /// The kind of inlining to perform.
164   InliningMethod Inlining;
165
166   /// The user provided name for the "main file", if non-empty. This is useful
167   /// in situations where the input file name does not match the original input
168   /// file, for example with -save-temps.
169   std::string MainFileName;
170
171   /// The name of the relocation model to use.
172   std::string RelocationModel;
173
174   /// If not an empty string, trap intrinsics are lowered to calls to this
175   /// function instead of to trap instructions.
176   std::string TrapFuncName;
177
178   /// A list of command-line options to forward to the LLVM backend.
179   std::vector<std::string> BackendOptions;
180
181   /// The user specified number of registers to be used for integral arguments,
182   /// or 0 if unspecified.
183   unsigned NumRegisterParameters;
184
185   /// The run-time penalty for bounds checking, or 0 to disable.
186   unsigned char BoundsChecking;
187
188   /// The default TLS model to use.
189   TLSModel DefaultTLSModel;
190
191 public:
192   CodeGenOptions() {
193     AsmVerbose = 0;
194     CUDAIsDevice = 0;
195     CXAAtExit = 1;
196     CXXCtorDtorAliases = 0;
197     DataSections = 0;
198     DisableFPElim = 0;
199     DisableLLVMOpts = 0;
200     DisableRedZone = 0;
201     DisableTailCalls = 0;
202     EmitDeclMetadata = 0;
203     EmitGcovArcs = 0;
204     EmitGcovNotes = 0;
205     EmitOpenCLArgMetadata = 0;
206     EmitMicrosoftInlineAsm = 0;
207     ForbidGuardVariables = 0;
208     FunctionSections = 0;
209     HiddenWeakTemplateVTables = 0;
210     HiddenWeakVTables = 0;
211     InstrumentFunctions = 0;
212     InstrumentForProfiling = 0;
213     LessPreciseFPMAD = 0;
214     MergeAllConstants = 1;
215     NoCommon = 0;
216     NoDwarf2CFIAsm = 0;
217     NoImplicitFloat = 0;
218     NoInfsFPMath = 0;
219     NoInline = 0;
220     NoNaNsFPMath = 0;
221     NoZeroInitializedInBSS = 0;
222     NumRegisterParameters = 0;
223     ObjCAutoRefCountExceptions = 0;
224     ObjCDispatchMethod = Legacy;
225     OmitLeafFramePointer = 0;
226     OptimizationLevel = 0;
227     OptimizeSize = 0;
228     RelaxAll = 0;
229     RelaxedAliasing = 0;
230     SaveTempLabels = 0;
231     SimplifyLibCalls = 1;
232     SoftFloat = 0;
233     StrictEnums = 0;
234     TimePasses = 0;
235     UnitAtATime = 1;
236     UnrollLoops = 0;
237     UnsafeFPMath = 0;
238     UnwindTables = 0;
239     UseRegisterSizedBitfieldAccess = 0;
240     VerifyModule = 1;
241     StackRealignment = 0;
242     StackAlignment = 0;
243     BoundsChecking = 0;
244     UseInitArray = 0;
245
246     DebugInfo = NoDebugInfo;
247     Inlining = NoInlining;
248     RelocationModel = "pic";
249     DefaultTLSModel = GeneralDynamicTLSModel;
250   }
251
252   ObjCDispatchMethodKind getObjCDispatchMethod() const {
253     return ObjCDispatchMethodKind(ObjCDispatchMethod);
254   }
255 };
256
257 }  // end namespace clang
258
259 #endif