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