CodeGenOptions.h revision 7255a2d997b15beae82e627052fdb1b2474495c2
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 OptimizationLevel : 3; /// The -O[0-4] option specified. 57 unsigned OptimizeSize : 1; /// If -Os is specified. 58 unsigned RelaxAll : 1; /// Relax all machine code instructions. 59 unsigned SimplifyLibCalls : 1; /// Set when -fbuiltin is enabled. 60 unsigned SoftFloat : 1; /// -soft-float. 61 unsigned TimePasses : 1; /// Set when -ftime-report is enabled. 62 unsigned UnitAtATime : 1; /// Unused. For mirroring GCC optimization 63 /// selection. 64 unsigned UnrollLoops : 1; /// Control whether loops are unrolled. 65 unsigned UnwindTables : 1; /// Emit unwind tables. 66 unsigned VerifyModule : 1; /// Control whether the module should be run 67 /// through the LLVM Verifier. 68 69 /// The code model to use (-mcmodel). 70 std::string CodeModel; 71 72 /// Enable additional debugging information. 73 std::string DebugPass; 74 75 /// The string to embed in the debug information for the compile unit, if 76 /// non-empty. 77 std::string DwarfDebugFlags; 78 79 /// The ABI to use for passing floating point arguments. 80 std::string FloatABI; 81 82 /// The float precision limit to use, if non-empty. 83 std::string LimitFloatPrecision; 84 85 /// The kind of inlining to perform. 86 InliningMethod Inlining; 87 88 /// The user provided name for the "main file", if non-empty. This is useful 89 /// in situations where the input file name does not match the original input 90 /// file, for example with -save-temps. 91 std::string MainFileName; 92 93 /// The name of the relocation model to use. 94 std::string RelocationModel; 95 96public: 97 CodeGenOptions() { 98 AsmVerbose = 0; 99 CXAAtExit = 1; 100 CXXCtorDtorAliases = 0; 101 DataSections = 0; 102 DebugInfo = 0; 103 DisableFPElim = 0; 104 DisableLLVMOpts = 0; 105 DisableRedZone = 0; 106 FunctionSections = 0; 107 MergeAllConstants = 1; 108 NoCommon = 0; 109 NoImplicitFloat = 0; 110 NoZeroInitializedInBSS = 0; 111 ObjCDispatchMethod = Legacy; 112 OptimizationLevel = 0; 113 OptimizeSize = 0; 114 RelaxAll = 0; 115 SimplifyLibCalls = 1; 116 SoftFloat = 0; 117 TimePasses = 0; 118 UnitAtATime = 1; 119 UnrollLoops = 0; 120 UnwindTables = 0; 121 VerifyModule = 1; 122 123 Inlining = NoInlining; 124 RelocationModel = "pic"; 125 } 126 127 ObjCDispatchMethodKind getObjCDispatchMethod() const { 128 return ObjCDispatchMethodKind(ObjCDispatchMethod); 129 } 130}; 131 132} // end namespace clang 133 134#endif 135