CodeGenOptions.h revision 210299
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 19namespace clang { 20 21/// CodeGenOptions - Track various options which control how the code 22/// is optimized and passed to the backend. 23class CodeGenOptions { 24public: 25 enum InliningMethod { 26 NoInlining, // Perform no inlining whatsoever. 27 NormalInlining, // Use the standard function inlining pass. 28 OnlyAlwaysInlining // Only run the always inlining pass. 29 }; 30 31 enum ObjCDispatchMethodKind { 32 Legacy = 0, 33 NonLegacy = 1, 34 Mixed = 2 35 }; 36 37 unsigned AsmVerbose : 1; /// -dA, -fverbose-asm. 38 unsigned CXAAtExit : 1; /// Use __cxa_atexit for calling destructors. 39 unsigned CXXCtorDtorAliases: 1; /// Emit complete ctors/dtors as linker 40 /// aliases to base ctors when possible. 41 unsigned DataSections : 1; /// Set when -fdata-sections is enabled 42 unsigned DebugInfo : 1; /// Should generate debug info (-g). 43 unsigned DisableFPElim : 1; /// Set when -fomit-frame-pointer is enabled. 44 unsigned DisableLLVMOpts : 1; /// Don't run any optimizations, for use in 45 /// getting .bc files that correspond to the 46 /// internal state before optimizations are 47 /// done. 48 unsigned DisableRedZone : 1; /// Set when -mno-red-zone is enabled. 49 unsigned FunctionSections : 1; /// Set when -ffunction-sections is enabled 50 unsigned InstrumentFunctions : 1; /// Set when -finstrument-functions is enabled 51 unsigned MergeAllConstants : 1; /// Merge identical constants. 52 unsigned NoCommon : 1; /// Set when -fno-common or C++ is enabled. 53 unsigned NoImplicitFloat : 1; /// Set when -mno-implicit-float is enabled. 54 unsigned NoZeroInitializedInBSS : 1; /// -fno-zero-initialized-in-bss 55 unsigned ObjCDispatchMethod : 2; /// Method of Objective-C dispatch to use. 56 unsigned OmitLeafFramePointer : 1; /// Set when -momit-leaf-frame-pointer is 57 /// enabled. 58 unsigned OptimizationLevel : 3; /// The -O[0-4] option specified. 59 unsigned OptimizeSize : 1; /// If -Os is specified. 60 unsigned RelaxAll : 1; /// Relax all machine code instructions. 61 unsigned SimplifyLibCalls : 1; /// Set when -fbuiltin is enabled. 62 unsigned SoftFloat : 1; /// -soft-float. 63 unsigned TimePasses : 1; /// Set when -ftime-report is enabled. 64 unsigned UnitAtATime : 1; /// Unused. For mirroring GCC optimization 65 /// selection. 66 unsigned UnrollLoops : 1; /// Control whether loops are unrolled. 67 unsigned UnwindTables : 1; /// Emit unwind tables. 68 unsigned VerifyModule : 1; /// Control whether the module should be run 69 /// through the LLVM Verifier. 70 unsigned EmitDeclMetadata : 1; /// Emit special metadata indicating what Decl* 71 /// various IR entities came from. Only useful 72 /// when running CodeGen as a subroutine. 73 74 /// The code model to use (-mcmodel). 75 std::string CodeModel; 76 77 /// Enable additional debugging information. 78 std::string DebugPass; 79 80 /// The string to embed in the debug information for the compile unit, if 81 /// non-empty. 82 std::string DwarfDebugFlags; 83 84 /// The ABI to use for passing floating point arguments. 85 std::string FloatABI; 86 87 /// The float precision limit to use, if non-empty. 88 std::string LimitFloatPrecision; 89 90 /// The kind of inlining to perform. 91 InliningMethod Inlining; 92 93 /// The user provided name for the "main file", if non-empty. This is useful 94 /// in situations where the input file name does not match the original input 95 /// file, for example with -save-temps. 96 std::string MainFileName; 97 98 /// The name of the relocation model to use. 99 std::string RelocationModel; 100 101public: 102 CodeGenOptions() { 103 AsmVerbose = 0; 104 CXAAtExit = 1; 105 CXXCtorDtorAliases = 0; 106 DataSections = 0; 107 DebugInfo = 0; 108 DisableFPElim = 0; 109 DisableLLVMOpts = 0; 110 DisableRedZone = 0; 111 FunctionSections = 0; 112 MergeAllConstants = 1; 113 NoCommon = 0; 114 NoImplicitFloat = 0; 115 NoZeroInitializedInBSS = 0; 116 ObjCDispatchMethod = Legacy; 117 OmitLeafFramePointer = 0; 118 OptimizationLevel = 0; 119 OptimizeSize = 0; 120 RelaxAll = 0; 121 SimplifyLibCalls = 1; 122 SoftFloat = 0; 123 TimePasses = 0; 124 UnitAtATime = 1; 125 UnrollLoops = 0; 126 UnwindTables = 0; 127 VerifyModule = 1; 128 EmitDeclMetadata = 0; 129 130 Inlining = NoInlining; 131 RelocationModel = "pic"; 132 } 133 134 ObjCDispatchMethodKind getObjCDispatchMethod() const { 135 return ObjCDispatchMethodKind(ObjCDispatchMethod); 136 } 137}; 138 139} // end namespace clang 140 141#endif 142