CodeGenOptions.h revision 91ecfa6af51836d3ccc90beddab1193b0c060739
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 20namespace 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. 24class CodeGenOptionsBase { 25public: 26#define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits; 27#define ENUM_CODEGENOPT(Name, Type, Bits, Default) 28#include "clang/Frontend/CodeGenOptions.def" 29 30protected: 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. 38class CodeGenOptions : public CodeGenOptionsBase { 39public: 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 DebugLineTablesOnly, // Emit only debug info necessary for generating 55 // line number tables (-gline-tables-only). 56 LimitedDebugInfo, // Limit generated debug info to reduce size 57 // (-flimit-debug-info). 58 FullDebugInfo // Generate complete debug info. 59 }; 60 61 enum TLSModel { 62 GeneralDynamicTLSModel, 63 LocalDynamicTLSModel, 64 InitialExecTLSModel, 65 LocalExecTLSModel 66 }; 67 68 enum FPContractModeKind { 69 FPC_Off, // Form fused FP ops only where result will not be affected. 70 FPC_On, // Form fused FP ops according to FP_CONTRACT rules. 71 FPC_Fast // Aggressively fuse FP ops (E.g. FMA). 72 }; 73 74 /// The code model to use (-mcmodel). 75 std::string CodeModel; 76 77 /// The filename with path we use for coverage files. The extension will be 78 /// replaced. 79 std::string CoverageFile; 80 81 /// Enable additional debugging information. 82 std::string DebugPass; 83 84 /// The string to embed in debug information as the current working directory. 85 std::string DebugCompilationDir; 86 87 /// The string to embed in the debug information for the compile unit, if 88 /// non-empty. 89 std::string DwarfDebugFlags; 90 91 /// The ABI to use for passing floating point arguments. 92 std::string FloatABI; 93 94 /// The float precision limit to use, if non-empty. 95 std::string LimitFloatPrecision; 96 97 /// The name of the bitcode file to link before optzns. 98 std::string LinkBitcodeFile; 99 100 /// The user provided name for the "main file", if non-empty. This is useful 101 /// in situations where the input file name does not match the original input 102 /// file, for example with -save-temps. 103 std::string MainFileName; 104 105 /// The name of the relocation model to use. 106 std::string RelocationModel; 107 108 /// Path to blacklist file for sanitizers. 109 std::string SanitizerBlacklistFile; 110 111 /// If not an empty string, trap intrinsics are lowered to calls to this 112 /// function instead of to trap instructions. 113 std::string TrapFuncName; 114 115 /// A list of command-line options to forward to the LLVM backend. 116 std::vector<std::string> BackendOptions; 117 118public: 119 // Define accessors/mutators for code generation options of enumeration type. 120#define CODEGENOPT(Name, Bits, Default) 121#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \ 122 Type get##Name() const { return static_cast<Type>(Name); } \ 123 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } 124#include "clang/Frontend/CodeGenOptions.def" 125 126 CodeGenOptions() { 127#define CODEGENOPT(Name, Bits, Default) Name = Default; 128#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \ 129 set##Name(Default); 130#include "clang/Frontend/CodeGenOptions.def" 131 132 RelocationModel = "pic"; 133 } 134}; 135 136} // end namespace clang 137 138#endif 139