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 <memory> 00018 #include <string> 00019 #include <vector> 00020 #include "llvm/Support/Regex.h" 00021 00022 namespace clang { 00023 00024 /// \brief Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure 00025 /// that this large collection of bitfields is a trivial class type. 00026 class CodeGenOptionsBase { 00027 public: 00028 #define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits; 00029 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) 00030 #include "clang/Frontend/CodeGenOptions.def" 00031 00032 protected: 00033 #define CODEGENOPT(Name, Bits, Default) 00034 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits; 00035 #include "clang/Frontend/CodeGenOptions.def" 00036 }; 00037 00038 /// CodeGenOptions - Track various options which control how the code 00039 /// is optimized and passed to the backend. 00040 class CodeGenOptions : public CodeGenOptionsBase { 00041 public: 00042 enum InliningMethod { 00043 NoInlining, // Perform no inlining whatsoever. 00044 NormalInlining, // Use the standard function inlining pass. 00045 OnlyAlwaysInlining // Only run the always inlining pass. 00046 }; 00047 00048 enum ObjCDispatchMethodKind { 00049 Legacy = 0, 00050 NonLegacy = 1, 00051 Mixed = 2 00052 }; 00053 00054 enum DebugInfoKind { 00055 NoDebugInfo, /// Don't generate debug info. 00056 00057 LocTrackingOnly, /// Emit location information but do not generate 00058 /// debug info in the output. This is useful in 00059 /// cases where the backend wants to track source 00060 /// locations for instructions without actually 00061 /// emitting debug info for them (e.g., when -Rpass 00062 /// is used). 00063 00064 DebugLineTablesOnly, /// Emit only debug info necessary for generating 00065 /// line number tables (-gline-tables-only). 00066 00067 LimitedDebugInfo, /// Limit generated debug info to reduce size 00068 /// (-fno-standalone-debug). This emits 00069 /// forward decls for types that could be 00070 /// replaced with forward decls in the source 00071 /// code. For dynamic C++ classes type info 00072 /// is only emitted int the module that 00073 /// contains the classe's vtable. 00074 00075 FullDebugInfo /// Generate complete debug info. 00076 }; 00077 00078 enum TLSModel { 00079 GeneralDynamicTLSModel, 00080 LocalDynamicTLSModel, 00081 InitialExecTLSModel, 00082 LocalExecTLSModel 00083 }; 00084 00085 enum FPContractModeKind { 00086 FPC_Off, // Form fused FP ops only where result will not be affected. 00087 FPC_On, // Form fused FP ops according to FP_CONTRACT rules. 00088 FPC_Fast // Aggressively fuse FP ops (E.g. FMA). 00089 }; 00090 00091 enum StructReturnConventionKind { 00092 SRCK_Default, // No special option was passed. 00093 SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return). 00094 SRCK_InRegs // Small structs in registers (-freg-struct-return). 00095 }; 00096 00097 /// The code model to use (-mcmodel). 00098 std::string CodeModel; 00099 00100 /// The filename with path we use for coverage files. The extension will be 00101 /// replaced. 00102 std::string CoverageFile; 00103 00104 /// The version string to put into coverage files. 00105 char CoverageVersion[4]; 00106 00107 /// Enable additional debugging information. 00108 std::string DebugPass; 00109 00110 /// The string to embed in debug information as the current working directory. 00111 std::string DebugCompilationDir; 00112 00113 /// The string to embed in the debug information for the compile unit, if 00114 /// non-empty. 00115 std::string DwarfDebugFlags; 00116 00117 /// The ABI to use for passing floating point arguments. 00118 std::string FloatABI; 00119 00120 /// The float precision limit to use, if non-empty. 00121 std::string LimitFloatPrecision; 00122 00123 /// The name of the bitcode file to link before optzns. 00124 std::string LinkBitcodeFile; 00125 00126 /// The user provided name for the "main file", if non-empty. This is useful 00127 /// in situations where the input file name does not match the original input 00128 /// file, for example with -save-temps. 00129 std::string MainFileName; 00130 00131 /// The name for the split debug info file that we'll break out. This is used 00132 /// in the backend for setting the name in the skeleton cu. 00133 std::string SplitDwarfFile; 00134 00135 /// The name of the relocation model to use. 00136 std::string RelocationModel; 00137 00138 /// The thread model to use 00139 std::string ThreadModel; 00140 00141 /// If not an empty string, trap intrinsics are lowered to calls to this 00142 /// function instead of to trap instructions. 00143 std::string TrapFuncName; 00144 00145 /// A list of command-line options to forward to the LLVM backend. 00146 std::vector<std::string> BackendOptions; 00147 00148 /// A list of dependent libraries. 00149 std::vector<std::string> DependentLibraries; 00150 00151 /// Name of the profile file to use with -fprofile-sample-use. 00152 std::string SampleProfileFile; 00153 00154 /// Name of the profile file to use as input for -fprofile-instr-use 00155 std::string InstrProfileInput; 00156 00157 /// Regular expression to select optimizations for which we should enable 00158 /// optimization remarks. Transformation passes whose name matches this 00159 /// expression (and support this feature), will emit a diagnostic 00160 /// whenever they perform a transformation. This is enabled by the 00161 /// -Rpass=regexp flag. 00162 std::shared_ptr<llvm::Regex> OptimizationRemarkPattern; 00163 00164 /// Regular expression to select optimizations for which we should enable 00165 /// missed optimization remarks. Transformation passes whose name matches this 00166 /// expression (and support this feature), will emit a diagnostic 00167 /// whenever they tried but failed to perform a transformation. This is 00168 /// enabled by the -Rpass-missed=regexp flag. 00169 std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern; 00170 00171 /// Regular expression to select optimizations for which we should enable 00172 /// optimization analyses. Transformation passes whose name matches this 00173 /// expression (and support this feature), will emit a diagnostic 00174 /// whenever they want to explain why they decided to apply or not apply 00175 /// a given transformation. This is enabled by the -Rpass-analysis=regexp 00176 /// flag. 00177 std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern; 00178 00179 public: 00180 // Define accessors/mutators for code generation options of enumeration type. 00181 #define CODEGENOPT(Name, Bits, Default) 00182 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \ 00183 Type get##Name() const { return static_cast<Type>(Name); } \ 00184 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } 00185 #include "clang/Frontend/CodeGenOptions.def" 00186 00187 CodeGenOptions(); 00188 }; 00189 00190 } // end namespace clang 00191 00192 #endif