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 "clang/Basic/Sanitizers.h" 18 #include "llvm/Support/Regex.h" 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 namespace clang { 24 25 /// \brief Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure 26 /// that this large collection of bitfields is a trivial class type. 27 class CodeGenOptionsBase { 28 public: 29 #define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits; 30 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) 31 #include "clang/Frontend/CodeGenOptions.def" 32 33 protected: 34 #define CODEGENOPT(Name, Bits, Default) 35 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits; 36 #include "clang/Frontend/CodeGenOptions.def" 37 }; 38 39 /// CodeGenOptions - Track various options which control how the code 40 /// is optimized and passed to the backend. 41 class CodeGenOptions : public CodeGenOptionsBase { 42 public: 43 enum InliningMethod { 44 NoInlining, // Perform no inlining whatsoever. 45 NormalInlining, // Use the standard function inlining pass. 46 OnlyAlwaysInlining // Only run the always inlining pass. 47 }; 48 49 enum ObjCDispatchMethodKind { 50 Legacy = 0, 51 NonLegacy = 1, 52 Mixed = 2 53 }; 54 55 enum DebugInfoKind { 56 NoDebugInfo, /// Don't generate debug info. 57 58 LocTrackingOnly, /// Emit location information but do not generate 59 /// debug info in the output. This is useful in 60 /// cases where the backend wants to track source 61 /// locations for instructions without actually 62 /// emitting debug info for them (e.g., when -Rpass 63 /// is used). 64 65 DebugLineTablesOnly, /// Emit only debug info necessary for generating 66 /// line number tables (-gline-tables-only). 67 68 LimitedDebugInfo, /// Limit generated debug info to reduce size 69 /// (-fno-standalone-debug). This emits 70 /// forward decls for types that could be 71 /// replaced with forward decls in the source 72 /// code. For dynamic C++ classes type info 73 /// is only emitted int the module that 74 /// contains the classe's vtable. 75 76 FullDebugInfo /// Generate complete debug info. 77 }; 78 79 enum TLSModel { 80 GeneralDynamicTLSModel, 81 LocalDynamicTLSModel, 82 InitialExecTLSModel, 83 LocalExecTLSModel 84 }; 85 86 enum FPContractModeKind { 87 FPC_Off, // Form fused FP ops only where result will not be affected. 88 FPC_On, // Form fused FP ops according to FP_CONTRACT rules. 89 FPC_Fast // Aggressively fuse FP ops (E.g. FMA). 90 }; 91 92 enum StructReturnConventionKind { 93 SRCK_Default, // No special option was passed. 94 SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return). 95 SRCK_InRegs // Small structs in registers (-freg-struct-return). 96 }; 97 98 /// The code model to use (-mcmodel). 99 std::string CodeModel; 100 101 /// The filename with path we use for coverage files. The extension will be 102 /// replaced. 103 std::string CoverageFile; 104 105 /// The version string to put into coverage files. 106 char CoverageVersion[4]; 107 108 /// Enable additional debugging information. 109 std::string DebugPass; 110 111 /// The string to embed in debug information as the current working directory. 112 std::string DebugCompilationDir; 113 114 /// The string to embed in the debug information for the compile unit, if 115 /// non-empty. 116 std::string DwarfDebugFlags; 117 118 /// The ABI to use for passing floating point arguments. 119 std::string FloatABI; 120 121 /// The float precision limit to use, if non-empty. 122 std::string LimitFloatPrecision; 123 124 /// The name of the bitcode file to link before optzns. 125 std::string LinkBitcodeFile; 126 127 /// The user provided name for the "main file", if non-empty. This is useful 128 /// in situations where the input file name does not match the original input 129 /// file, for example with -save-temps. 130 std::string MainFileName; 131 132 /// The name for the split debug info file that we'll break out. This is used 133 /// in the backend for setting the name in the skeleton cu. 134 std::string SplitDwarfFile; 135 136 /// The name of the relocation model to use. 137 std::string RelocationModel; 138 139 /// The thread model to use 140 std::string ThreadModel; 141 142 /// If not an empty string, trap intrinsics are lowered to calls to this 143 /// function instead of to trap instructions. 144 std::string TrapFuncName; 145 146 /// A list of command-line options to forward to the LLVM backend. 147 std::vector<std::string> BackendOptions; 148 149 /// A list of dependent libraries. 150 std::vector<std::string> DependentLibraries; 151 152 /// Name of the profile file to use with -fprofile-sample-use. 153 std::string SampleProfileFile; 154 155 /// Name of the profile file to use as input for -fprofile-instr-use 156 std::string InstrProfileInput; 157 158 /// Regular expression to select optimizations for which we should enable 159 /// optimization remarks. Transformation passes whose name matches this 160 /// expression (and support this feature), will emit a diagnostic 161 /// whenever they perform a transformation. This is enabled by the 162 /// -Rpass=regexp flag. 163 std::shared_ptr<llvm::Regex> OptimizationRemarkPattern; 164 165 /// Regular expression to select optimizations for which we should enable 166 /// missed optimization remarks. Transformation passes whose name matches this 167 /// expression (and support this feature), will emit a diagnostic 168 /// whenever they tried but failed to perform a transformation. This is 169 /// enabled by the -Rpass-missed=regexp flag. 170 std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern; 171 172 /// Regular expression to select optimizations for which we should enable 173 /// optimization analyses. Transformation passes whose name matches this 174 /// expression (and support this feature), will emit a diagnostic 175 /// whenever they want to explain why they decided to apply or not apply 176 /// a given transformation. This is enabled by the -Rpass-analysis=regexp 177 /// flag. 178 std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern; 179 180 /// Set of files definining the rules for the symbol rewriting. 181 std::vector<std::string> RewriteMapFiles; 182 183 /// Set of sanitizer checks that are non-fatal (i.e. execution should be 184 /// continued when possible). 185 SanitizerSet SanitizeRecover; 186 187 public: 188 // Define accessors/mutators for code generation options of enumeration type. 189 #define CODEGENOPT(Name, Bits, Default) 190 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \ 191 Type get##Name() const { return static_cast<Type>(Name); } \ 192 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } 193 #include "clang/Frontend/CodeGenOptions.def" 194 195 CodeGenOptions(); 196 }; 197 198 } // end namespace clang 199 200 #endif 201