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
22 /// CodeGenOptions - Track various options which control how the code
23 /// is optimized and passed to the backend.
24 class CodeGenOptions {
27 NoInlining, // Perform no inlining whatsoever.
28 NormalInlining, // Use the standard function inlining pass.
29 OnlyAlwaysInlining // Only run the always inlining pass.
32 enum ObjCDispatchMethodKind {
38 unsigned AsmVerbose : 1; /// -dA, -fverbose-asm.
39 unsigned ObjCAutoRefCountExceptions : 1; /// Whether ARC should be EH-safe.
40 unsigned CUDAIsDevice : 1; /// Set when compiling for CUDA device.
41 unsigned CXAAtExit : 1; /// Use __cxa_atexit for calling destructors.
42 unsigned CXXCtorDtorAliases: 1; /// Emit complete ctors/dtors as linker
43 /// aliases to base ctors when possible.
44 unsigned DataSections : 1; /// Set when -fdata-sections is enabled
45 unsigned DebugInfo : 1; /// Should generate debug info (-g).
46 unsigned LimitDebugInfo : 1; /// Limit generated debug info to reduce size.
47 unsigned DisableFPElim : 1; /// Set when -fomit-frame-pointer is enabled.
48 unsigned DisableLLVMOpts : 1; /// Don't run any optimizations, for use in
49 /// getting .bc files that correspond to the
50 /// internal state before optimizations are
52 unsigned DisableRedZone : 1; /// Set when -mno-red-zone is enabled.
53 unsigned DisableTailCalls : 1; /// Do not emit tail calls.
54 unsigned EmitDeclMetadata : 1; /// Emit special metadata indicating what
55 /// Decl* various IR entities came from. Only
56 /// useful when running CodeGen as a
58 unsigned EmitGcovArcs : 1; /// Emit coverage data files, aka. GCDA.
59 unsigned EmitGcovNotes : 1; /// Emit coverage "notes" files, aka GCNO.
60 unsigned ForbidGuardVariables : 1; /// Issue errors if C++ guard variables
62 unsigned FunctionSections : 1; /// Set when -ffunction-sections is enabled
63 unsigned HiddenWeakTemplateVTables : 1; /// Emit weak vtables and RTTI for
64 /// template classes with hidden visibility
65 unsigned HiddenWeakVTables : 1; /// Emit weak vtables, RTTI, and thunks with
66 /// hidden visibility.
67 unsigned InstrumentFunctions : 1; /// Set when -finstrument-functions is
69 unsigned InstrumentForProfiling : 1; /// Set when -pg is enabled
70 unsigned LessPreciseFPMAD : 1; /// Enable less precise MAD instructions to be
72 unsigned MergeAllConstants : 1; /// Merge identical constants.
73 unsigned NoCommon : 1; /// Set when -fno-common or C++ is enabled.
74 unsigned NoDwarf2CFIAsm : 1; /// Set when -fno-dwarf2-cfi-asm is enabled.
75 unsigned NoDwarfDirectoryAsm : 1; /// Set when -fno-dwarf-directory-asm is
77 unsigned NoExecStack : 1; /// Set when -Wa,--noexecstack is enabled.
78 unsigned NoGlobalMerge : 1; /// Set when -mno-global-merge is enabled.
79 unsigned NoImplicitFloat : 1; /// Set when -mno-implicit-float is enabled.
80 unsigned NoInfsFPMath : 1; /// Assume FP arguments, results not +-Inf.
81 unsigned NoInline : 1; /// Set when -fno-inline is enabled. Disables
82 /// use of the inline keyword.
83 unsigned NoNaNsFPMath : 1; /// Assume FP arguments, results not NaN.
84 unsigned NoZeroInitializedInBSS : 1; /// -fno-zero-initialized-in-bss
85 unsigned ObjCTrace : 1; /// Emit tracing calls for visualising code
86 /// flow in Objective-C programs
87 unsigned ObjCDispatchMethod : 2; /// Method of Objective-C dispatch to use.
88 unsigned ObjCRuntimeHasARC : 1; /// The target runtime supports ARC natively
89 unsigned ObjCRuntimeHasTerminate : 1; /// The ObjC runtime has objc_terminate
90 unsigned OmitLeafFramePointer : 1; /// Set when -momit-leaf-frame-pointer is
92 unsigned OptimizationLevel : 3; /// The -O[0-4] option specified.
93 unsigned OptimizeSize : 2; /// If -Os (==1) or -Oz (==2) is specified.
94 unsigned RelaxAll : 1; /// Relax all machine code instructions.
95 unsigned RelaxedAliasing : 1; /// Set when -fno-strict-aliasing is enabled.
96 unsigned SaveTempLabels : 1; /// Save temporary labels.
97 unsigned SimplifyLibCalls : 1; /// Set when -fbuiltin is enabled.
98 unsigned SoftFloat : 1; /// -soft-float.
99 unsigned StrictEnums : 1; /// Optimize based on strict enum definition.
100 unsigned TimePasses : 1; /// Set when -ftime-report is enabled.
101 unsigned UnitAtATime : 1; /// Unused. For mirroring GCC optimization
103 unsigned UnrollLoops : 1; /// Control whether loops are unrolled.
104 unsigned UnsafeFPMath : 1; /// Allow unsafe floating point optzns.
105 unsigned UnwindTables : 1; /// Emit unwind tables.
107 /// Attempt to use register sized accesses to bit-fields in structures, when
109 unsigned UseRegisterSizedBitfieldAccess : 1;
111 unsigned VerifyModule : 1; /// Control whether the module should be run
112 /// through the LLVM Verifier.
114 unsigned StackRealignment : 1; /// Control whether to permit stack
116 unsigned StackAlignment; /// Overrides default stack alignment,
119 /// The code model to use (-mcmodel).
120 std::string CodeModel;
122 /// The filename with path we use for coverage files. The extension will be
124 std::string CoverageFile;
126 /// Enable additional debugging information.
127 std::string DebugPass;
129 /// The string to embed in debug information as the current working directory.
130 std::string DebugCompilationDir;
132 /// The string to embed in the debug information for the compile unit, if
134 std::string DwarfDebugFlags;
136 /// The ABI to use for passing floating point arguments.
137 std::string FloatABI;
139 /// The float precision limit to use, if non-empty.
140 std::string LimitFloatPrecision;
142 /// The name of the bitcode file to link before optzns.
143 std::string LinkBitcodeFile;
145 /// The kind of inlining to perform.
146 InliningMethod Inlining;
148 /// The user provided name for the "main file", if non-empty. This is useful
149 /// in situations where the input file name does not match the original input
150 /// file, for example with -save-temps.
151 std::string MainFileName;
153 /// The name of the relocation model to use.
154 std::string RelocationModel;
156 /// If not an empty string, trap intrinsics are lowered to calls to this
157 /// function instead of to trap instructions.
158 std::string TrapFuncName;
160 /// A list of command-line options to forward to the LLVM backend.
161 std::vector<std::string> BackendOptions;
163 /// The user specified number of registers to be used for integral arguments,
164 /// or 0 if unspecified.
165 unsigned NumRegisterParameters;
172 CXXCtorDtorAliases = 0;
179 DisableTailCalls = 0;
180 EmitDeclMetadata = 0;
183 ForbidGuardVariables = 0;
184 FunctionSections = 0;
185 HiddenWeakTemplateVTables = 0;
186 HiddenWeakVTables = 0;
187 InstrumentFunctions = 0;
188 InstrumentForProfiling = 0;
189 LessPreciseFPMAD = 0;
190 MergeAllConstants = 1;
197 NoZeroInitializedInBSS = 0;
198 NumRegisterParameters = 0;
199 ObjCAutoRefCountExceptions = 0;
200 ObjCDispatchMethod = Legacy;
201 ObjCRuntimeHasARC = 0;
202 ObjCRuntimeHasTerminate = 0;
203 OmitLeafFramePointer = 0;
204 OptimizationLevel = 0;
209 SimplifyLibCalls = 1;
217 UseRegisterSizedBitfieldAccess = 0;
219 StackRealignment = 0;
222 Inlining = NoInlining;
223 RelocationModel = "pic";
226 ObjCDispatchMethodKind getObjCDispatchMethod() const {
227 return ObjCDispatchMethodKind(ObjCDispatchMethod);
231 } // end namespace clang