clang API Documentation
00001 //===--- CodeGenOptions.h ---------------------------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the CodeGenOptions interface. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H 00015 #define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H 00016 00017 #include <string> 00018 #include <vector> 00019 00020 namespace clang { 00021 00022 /// CodeGenOptions - Track various options which control how the code 00023 /// is optimized and passed to the backend. 00024 class CodeGenOptions { 00025 public: 00026 enum InliningMethod { 00027 NoInlining, // Perform no inlining whatsoever. 00028 NormalInlining, // Use the standard function inlining pass. 00029 OnlyAlwaysInlining // Only run the always inlining pass. 00030 }; 00031 00032 enum ObjCDispatchMethodKind { 00033 Legacy = 0, 00034 NonLegacy = 1, 00035 Mixed = 2 00036 }; 00037 00038 enum DebugInfoKind { 00039 NoDebugInfo, // Don't generate debug info. 00040 DebugLineTablesOnly, // Emit only debug info necessary for generating 00041 // line number tables (-gline-tables-only). 00042 LimitedDebugInfo, // Limit generated debug info to reduce size 00043 // (-flimit-debug-info). 00044 FullDebugInfo // Generate complete debug info. 00045 }; 00046 00047 unsigned AsmVerbose : 1; ///< -dA, -fverbose-asm. 00048 unsigned ObjCAutoRefCountExceptions : 1; ///< Whether ARC should be EH-safe. 00049 unsigned CUDAIsDevice : 1; ///< Set when compiling for CUDA device. 00050 unsigned CXAAtExit : 1; ///< Use __cxa_atexit for calling destructors. 00051 unsigned CXXCtorDtorAliases: 1; ///< Emit complete ctors/dtors as linker 00052 ///< aliases to base ctors when possible. 00053 unsigned DataSections : 1; ///< Set when -fdata-sections is enabled 00054 unsigned DisableFPElim : 1; ///< Set when -fomit-frame-pointer is enabled. 00055 unsigned DisableLLVMOpts : 1; ///< Don't run any optimizations, for use in 00056 ///< getting .bc files that correspond to the 00057 ///< internal state before optimizations are 00058 ///< done. 00059 unsigned DisableRedZone : 1; ///< Set when -mno-red-zone is enabled. 00060 unsigned DisableTailCalls : 1; ///< Do not emit tail calls. 00061 unsigned EmitDeclMetadata : 1; ///< Emit special metadata indicating what 00062 ///< Decl* various IR entities came from. Only 00063 ///< useful when running CodeGen as a 00064 ///< subroutine. 00065 unsigned EmitGcovArcs : 1; ///< Emit coverage data files, aka. GCDA. 00066 unsigned EmitGcovNotes : 1; ///< Emit coverage "notes" files, aka GCNO. 00067 unsigned ForbidGuardVariables : 1; ///< Issue errors if C++ guard variables 00068 ///< are required 00069 unsigned FunctionSections : 1; ///< Set when -ffunction-sections is enabled 00070 unsigned HiddenWeakTemplateVTables : 1; ///< Emit weak vtables and RTTI for 00071 ///< template classes with hidden visibility 00072 unsigned HiddenWeakVTables : 1; ///< Emit weak vtables, RTTI, and thunks with 00073 ///< hidden visibility. 00074 unsigned InstrumentFunctions : 1; ///< Set when -finstrument-functions is 00075 ///< enabled. 00076 unsigned InstrumentForProfiling : 1; ///< Set when -pg is enabled 00077 unsigned LessPreciseFPMAD : 1; ///< Enable less precise MAD instructions to 00078 ///< be generated. 00079 unsigned MergeAllConstants : 1; ///< Merge identical constants. 00080 unsigned NoCommon : 1; ///< Set when -fno-common or C++ is enabled. 00081 unsigned NoDwarf2CFIAsm : 1; ///< Set when -fno-dwarf2-cfi-asm is enabled. 00082 unsigned NoDwarfDirectoryAsm : 1; ///< Set when -fno-dwarf-directory-asm is 00083 ///< enabled. 00084 unsigned NoExecStack : 1; ///< Set when -Wa,--noexecstack is enabled. 00085 unsigned NoGlobalMerge : 1; ///< Set when -mno-global-merge is enabled. 00086 unsigned NoImplicitFloat : 1; ///< Set when -mno-implicit-float is enabled. 00087 unsigned NoInfsFPMath : 1; ///< Assume FP arguments, results not +-Inf. 00088 unsigned NoInline : 1; ///< Set when -fno-inline is enabled. Disables 00089 ///< use of the inline keyword. 00090 unsigned NoNaNsFPMath : 1; ///< Assume FP arguments, results not NaN. 00091 unsigned NoZeroInitializedInBSS : 1; ///< -fno-zero-initialized-in-bss 00092 unsigned ObjCDispatchMethod : 2; ///< Method of Objective-C dispatch to use. 00093 unsigned ObjCRuntimeHasARC : 1; ///< The target runtime supports ARC natively 00094 unsigned ObjCRuntimeHasTerminate : 1; ///< The ObjC runtime has objc_terminate 00095 unsigned OmitLeafFramePointer : 1; ///< Set when -momit-leaf-frame-pointer is 00096 ///< enabled. 00097 unsigned OptimizationLevel : 3; ///< The -O[0-4] option specified. 00098 unsigned OptimizeSize : 2; ///< If -Os (==1) or -Oz (==2) is specified. 00099 unsigned RelaxAll : 1; ///< Relax all machine code instructions. 00100 unsigned RelaxedAliasing : 1; ///< Set when -fno-strict-aliasing is enabled. 00101 unsigned SaveTempLabels : 1; ///< Save temporary labels. 00102 unsigned SimplifyLibCalls : 1; ///< Set when -fbuiltin is enabled. 00103 unsigned SoftFloat : 1; ///< -soft-float. 00104 unsigned StrictEnums : 1; ///< Optimize based on strict enum definition. 00105 unsigned TimePasses : 1; ///< Set when -ftime-report is enabled. 00106 unsigned UnitAtATime : 1; ///< Unused. For mirroring GCC optimization 00107 /// selection. 00108 unsigned UnrollLoops : 1; ///< Control whether loops are unrolled. 00109 unsigned UnsafeFPMath : 1; ///< Allow unsafe floating point optzns. 00110 unsigned UnwindTables : 1; ///< Emit unwind tables. 00111 00112 /// Attempt to use register sized accesses to bit-fields in structures, when 00113 /// possible. 00114 unsigned UseRegisterSizedBitfieldAccess : 1; 00115 00116 unsigned VerifyModule : 1; ///< Control whether the module should be run 00117 ///< through the LLVM Verifier. 00118 00119 unsigned StackRealignment : 1; ///< Control whether to permit stack 00120 ///< realignment. 00121 unsigned StackAlignment; ///< Overrides default stack alignment, 00122 ///< if not 0. 00123 00124 /// The code model to use (-mcmodel). 00125 std::string CodeModel; 00126 00127 /// The filename with path we use for coverage files. The extension will be 00128 /// replaced. 00129 std::string CoverageFile; 00130 00131 /// Enable additional debugging information. 00132 std::string DebugPass; 00133 00134 /// The string to embed in debug information as the current working directory. 00135 std::string DebugCompilationDir; 00136 00137 /// The kind of generated debug info. 00138 DebugInfoKind DebugInfo; 00139 00140 /// The string to embed in the debug information for the compile unit, if 00141 /// non-empty. 00142 std::string DwarfDebugFlags; 00143 00144 /// The ABI to use for passing floating point arguments. 00145 std::string FloatABI; 00146 00147 /// The float precision limit to use, if non-empty. 00148 std::string LimitFloatPrecision; 00149 00150 /// The name of the bitcode file to link before optzns. 00151 std::string LinkBitcodeFile; 00152 00153 /// The kind of inlining to perform. 00154 InliningMethod Inlining; 00155 00156 /// The user provided name for the "main file", if non-empty. This is useful 00157 /// in situations where the input file name does not match the original input 00158 /// file, for example with -save-temps. 00159 std::string MainFileName; 00160 00161 /// The name of the relocation model to use. 00162 std::string RelocationModel; 00163 00164 /// If not an empty string, trap intrinsics are lowered to calls to this 00165 /// function instead of to trap instructions. 00166 std::string TrapFuncName; 00167 00168 /// A list of command-line options to forward to the LLVM backend. 00169 std::vector<std::string> BackendOptions; 00170 00171 /// The user specified number of registers to be used for integral arguments, 00172 /// or 0 if unspecified. 00173 unsigned NumRegisterParameters; 00174 00175 public: 00176 CodeGenOptions() { 00177 AsmVerbose = 0; 00178 CUDAIsDevice = 0; 00179 CXAAtExit = 1; 00180 CXXCtorDtorAliases = 0; 00181 DataSections = 0; 00182 DisableFPElim = 0; 00183 DisableLLVMOpts = 0; 00184 DisableRedZone = 0; 00185 DisableTailCalls = 0; 00186 EmitDeclMetadata = 0; 00187 EmitGcovArcs = 0; 00188 EmitGcovNotes = 0; 00189 ForbidGuardVariables = 0; 00190 FunctionSections = 0; 00191 HiddenWeakTemplateVTables = 0; 00192 HiddenWeakVTables = 0; 00193 InstrumentFunctions = 0; 00194 InstrumentForProfiling = 0; 00195 LessPreciseFPMAD = 0; 00196 MergeAllConstants = 1; 00197 NoCommon = 0; 00198 NoDwarf2CFIAsm = 0; 00199 NoImplicitFloat = 0; 00200 NoInfsFPMath = 0; 00201 NoInline = 0; 00202 NoNaNsFPMath = 0; 00203 NoZeroInitializedInBSS = 0; 00204 NumRegisterParameters = 0; 00205 ObjCAutoRefCountExceptions = 0; 00206 ObjCDispatchMethod = Legacy; 00207 ObjCRuntimeHasARC = 0; 00208 ObjCRuntimeHasTerminate = 0; 00209 OmitLeafFramePointer = 0; 00210 OptimizationLevel = 0; 00211 OptimizeSize = 0; 00212 RelaxAll = 0; 00213 RelaxedAliasing = 0; 00214 SaveTempLabels = 0; 00215 SimplifyLibCalls = 1; 00216 SoftFloat = 0; 00217 StrictEnums = 0; 00218 TimePasses = 0; 00219 UnitAtATime = 1; 00220 UnrollLoops = 0; 00221 UnsafeFPMath = 0; 00222 UnwindTables = 0; 00223 UseRegisterSizedBitfieldAccess = 0; 00224 VerifyModule = 1; 00225 StackRealignment = 0; 00226 StackAlignment = 0; 00227 00228 DebugInfo = NoDebugInfo; 00229 Inlining = NoInlining; 00230 RelocationModel = "pic"; 00231 } 00232 00233 ObjCDispatchMethodKind getObjCDispatchMethod() const { 00234 return ObjCDispatchMethodKind(ObjCDispatchMethod); 00235 } 00236 }; 00237 00238 } // end namespace clang 00239 00240 #endif