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 /// \brief Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure 23 /// that this large collection of bitfields is a trivial class type. 24 class CodeGenOptionsBase { 25 public: 26 #define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits; 27 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) 28 #include "clang/Frontend/CodeGenOptions.def" 29 30 protected: 31 #define CODEGENOPT(Name, Bits, Default) 32 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits; 33 #include "clang/Frontend/CodeGenOptions.def" 34 }; 35 36 /// CodeGenOptions - Track various options which control how the code 37 /// is optimized and passed to the backend. 38 class CodeGenOptions : public CodeGenOptionsBase { 39 public: 40 enum InliningMethod { 41 NoInlining, // Perform no inlining whatsoever. 42 NormalInlining, // Use the standard function inlining pass. 43 OnlyAlwaysInlining // Only run the always inlining pass. 44 }; 45 46 enum ObjCDispatchMethodKind { 47 Legacy = 0, 48 NonLegacy = 1, 49 Mixed = 2 50 }; 51 52 enum DebugInfoKind { 53 NoDebugInfo, /// Don't generate debug info. 54 55 DebugLineTablesOnly, /// Emit only debug info necessary for generating 56 /// line number tables (-gline-tables-only). 57 58 LimitedDebugInfo, /// Limit generated debug info to reduce size 59 /// (-fno-standalone-debug). This emits 60 /// forward decls for types that could be 61 /// replaced with forward decls in the source 62 /// code. For dynamic C++ classes type info 63 /// is only emitted int the module that 64 /// contains the classe's vtable. 65 66 FullDebugInfo /// Generate complete debug info. 67 }; 68 69 enum TLSModel { 70 GeneralDynamicTLSModel, 71 LocalDynamicTLSModel, 72 InitialExecTLSModel, 73 LocalExecTLSModel 74 }; 75 76 enum FPContractModeKind { 77 FPC_Off, // Form fused FP ops only where result will not be affected. 78 FPC_On, // Form fused FP ops according to FP_CONTRACT rules. 79 FPC_Fast // Aggressively fuse FP ops (E.g. FMA). 80 }; 81 82 enum StructReturnConventionKind { 83 SRCK_Default, // No special option was passed. 84 SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return). 85 SRCK_InRegs // Small structs in registers (-freg-struct-return). 86 }; 87 88 /// The code model to use (-mcmodel). 89 std::string CodeModel; 90 91 /// The filename with path we use for coverage files. The extension will be 92 /// replaced. 93 std::string CoverageFile; 94 95 /// The version string to put into coverage files. 96 char CoverageVersion[4]; 97 98 /// Enable additional debugging information. 99 std::string DebugPass; 100 101 /// The string to embed in debug information as the current working directory. 102 std::string DebugCompilationDir; 103 104 /// The string to embed in the debug information for the compile unit, if 105 /// non-empty. 106 std::string DwarfDebugFlags; 107 108 /// The ABI to use for passing floating point arguments. 109 std::string FloatABI; 110 111 /// The float precision limit to use, if non-empty. 112 std::string LimitFloatPrecision; 113 114 /// The name of the bitcode file to link before optzns. 115 std::string LinkBitcodeFile; 116 117 /// The user provided name for the "main file", if non-empty. This is useful 118 /// in situations where the input file name does not match the original input 119 /// file, for example with -save-temps. 120 std::string MainFileName; 121 122 /// The name for the split debug info file that we'll break out. This is used 123 /// in the backend for setting the name in the skeleton cu. 124 std::string SplitDwarfFile; 125 126 /// The name of the relocation model to use. 127 std::string RelocationModel; 128 129 /// Path to blacklist file for sanitizers. 130 std::string SanitizerBlacklistFile; 131 132 /// If not an empty string, trap intrinsics are lowered to calls to this 133 /// function instead of to trap instructions. 134 std::string TrapFuncName; 135 136 /// A list of command-line options to forward to the LLVM backend. 137 std::vector<std::string> BackendOptions; 138 139 /// A list of dependent libraries. 140 std::vector<std::string> DependentLibraries; 141 142 /// Name of the profile file to use with -fprofile-sample-use. 143 std::string SampleProfileFile; 144 145 public: 146 // Define accessors/mutators for code generation options of enumeration type. 147 #define CODEGENOPT(Name, Bits, Default) 148 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \ 149 Type get##Name() const { return static_cast<Type>(Name); } \ 150 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } 151 #include "clang/Frontend/CodeGenOptions.def" 152 CodeGenOptions()153 CodeGenOptions() { 154 #define CODEGENOPT(Name, Bits, Default) Name = Default; 155 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \ 156 set##Name(Default); 157 #include "clang/Frontend/CodeGenOptions.def" 158 159 RelocationModel = "pic"; 160 memcpy(CoverageVersion, "402*", 4); 161 } 162 }; 163 164 } // end namespace clang 165 166 #endif 167