1210008Srdivacky//===--- CodeGenOptions.h ---------------------------------------*- C++ -*-===//
2210008Srdivacky//
3210008Srdivacky//                     The LLVM Compiler Infrastructure
4210008Srdivacky//
5210008Srdivacky// This file is distributed under the University of Illinois Open Source
6210008Srdivacky// License. See LICENSE.TXT for details.
7210008Srdivacky//
8210008Srdivacky//===----------------------------------------------------------------------===//
9210008Srdivacky//
10210008Srdivacky//  This file defines the CodeGenOptions interface.
11210008Srdivacky//
12210008Srdivacky//===----------------------------------------------------------------------===//
13210008Srdivacky
14210008Srdivacky#ifndef LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
15210008Srdivacky#define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
16210008Srdivacky
17210008Srdivacky#include <string>
18221345Sdim#include <vector>
19210008Srdivacky
20210008Srdivackynamespace clang {
21210008Srdivacky
22243830Sdim/// \brief Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure
23243830Sdim/// that this large collection of bitfields is a trivial class type.
24243830Sdimclass CodeGenOptionsBase {
25243830Sdimpublic:
26243830Sdim#define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
27243830Sdim#define ENUM_CODEGENOPT(Name, Type, Bits, Default)
28243830Sdim#include "clang/Frontend/CodeGenOptions.def"
29243830Sdim
30243830Sdimprotected:
31243830Sdim#define CODEGENOPT(Name, Bits, Default)
32243830Sdim#define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
33243830Sdim#include "clang/Frontend/CodeGenOptions.def"
34243830Sdim};
35243830Sdim
36210008Srdivacky/// CodeGenOptions - Track various options which control how the code
37210008Srdivacky/// is optimized and passed to the backend.
38243830Sdimclass CodeGenOptions : public CodeGenOptionsBase {
39210008Srdivackypublic:
40210008Srdivacky  enum InliningMethod {
41210008Srdivacky    NoInlining,         // Perform no inlining whatsoever.
42210008Srdivacky    NormalInlining,     // Use the standard function inlining pass.
43210008Srdivacky    OnlyAlwaysInlining  // Only run the always inlining pass.
44210008Srdivacky  };
45210008Srdivacky
46210008Srdivacky  enum ObjCDispatchMethodKind {
47210008Srdivacky    Legacy = 0,
48210008Srdivacky    NonLegacy = 1,
49210008Srdivacky    Mixed = 2
50210008Srdivacky  };
51210008Srdivacky
52239462Sdim  enum DebugInfoKind {
53269011Semaste    NoDebugInfo,          /// Don't generate debug info.
54269011Semaste
55269011Semaste    DebugLineTablesOnly,  /// Emit only debug info necessary for generating
56269011Semaste                          /// line number tables (-gline-tables-only).
57269011Semaste
58269011Semaste    LimitedDebugInfo,     /// Limit generated debug info to reduce size
59269011Semaste                          /// (-fno-standalone-debug). This emits
60269011Semaste                          /// forward decls for types that could be
61269011Semaste                          /// replaced with forward decls in the source
62269011Semaste                          /// code. For dynamic C++ classes type info
63269011Semaste                          /// is only emitted int the module that
64269011Semaste                          /// contains the classe's vtable.
65269011Semaste
66269011Semaste    FullDebugInfo         /// Generate complete debug info.
67239462Sdim  };
68224145Sdim
69239462Sdim  enum TLSModel {
70239462Sdim    GeneralDynamicTLSModel,
71239462Sdim    LocalDynamicTLSModel,
72239462Sdim    InitialExecTLSModel,
73239462Sdim    LocalExecTLSModel
74239462Sdim  };
75239462Sdim
76249423Sdim  enum FPContractModeKind {
77249423Sdim    FPC_Off,        // Form fused FP ops only where result will not be affected.
78249423Sdim    FPC_On,         // Form fused FP ops according to FP_CONTRACT rules.
79249423Sdim    FPC_Fast        // Aggressively fuse FP ops (E.g. FMA).
80249423Sdim  };
81249423Sdim
82263508Sdim  enum StructReturnConventionKind {
83263508Sdim    SRCK_Default,  // No special option was passed.
84263508Sdim    SRCK_OnStack,  // Small structs on the stack (-fpcc-struct-return).
85263508Sdim    SRCK_InRegs    // Small structs in registers (-freg-struct-return).
86263508Sdim  };
87263508Sdim
88210008Srdivacky  /// The code model to use (-mcmodel).
89210008Srdivacky  std::string CodeModel;
90210008Srdivacky
91223017Sdim  /// The filename with path we use for coverage files. The extension will be
92223017Sdim  /// replaced.
93223017Sdim  std::string CoverageFile;
94223017Sdim
95249423Sdim  /// The version string to put into coverage files.
96249423Sdim  char CoverageVersion[4];
97249423Sdim
98210008Srdivacky  /// Enable additional debugging information.
99210008Srdivacky  std::string DebugPass;
100210008Srdivacky
101234353Sdim  /// The string to embed in debug information as the current working directory.
102234353Sdim  std::string DebugCompilationDir;
103234353Sdim
104210008Srdivacky  /// The string to embed in the debug information for the compile unit, if
105210008Srdivacky  /// non-empty.
106210008Srdivacky  std::string DwarfDebugFlags;
107210008Srdivacky
108210008Srdivacky  /// The ABI to use for passing floating point arguments.
109210008Srdivacky  std::string FloatABI;
110210008Srdivacky
111210008Srdivacky  /// The float precision limit to use, if non-empty.
112210008Srdivacky  std::string LimitFloatPrecision;
113210008Srdivacky
114234353Sdim  /// The name of the bitcode file to link before optzns.
115234353Sdim  std::string LinkBitcodeFile;
116234353Sdim
117210008Srdivacky  /// The user provided name for the "main file", if non-empty. This is useful
118210008Srdivacky  /// in situations where the input file name does not match the original input
119210008Srdivacky  /// file, for example with -save-temps.
120210008Srdivacky  std::string MainFileName;
121210008Srdivacky
122249423Sdim  /// The name for the split debug info file that we'll break out. This is used
123249423Sdim  /// in the backend for setting the name in the skeleton cu.
124249423Sdim  std::string SplitDwarfFile;
125249423Sdim
126210008Srdivacky  /// The name of the relocation model to use.
127210008Srdivacky  std::string RelocationModel;
128210008Srdivacky
129249423Sdim  /// Path to blacklist file for sanitizers.
130249423Sdim  std::string SanitizerBlacklistFile;
131249423Sdim
132234353Sdim  /// If not an empty string, trap intrinsics are lowered to calls to this
133234353Sdim  /// function instead of to trap instructions.
134234353Sdim  std::string TrapFuncName;
135234353Sdim
136221345Sdim  /// A list of command-line options to forward to the LLVM backend.
137221345Sdim  std::vector<std::string> BackendOptions;
138221345Sdim
139263508Sdim  /// A list of dependent libraries.
140263508Sdim  std::vector<std::string> DependentLibraries;
141263508Sdim
142263508Sdim  /// Name of the profile file to use with -fprofile-sample-use.
143263508Sdim  std::string SampleProfileFile;
144263508Sdim
145243830Sdimpublic:
146243830Sdim  // Define accessors/mutators for code generation options of enumeration type.
147243830Sdim#define CODEGENOPT(Name, Bits, Default)
148243830Sdim#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
149243830Sdim  Type get##Name() const { return static_cast<Type>(Name); } \
150243830Sdim  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
151243830Sdim#include "clang/Frontend/CodeGenOptions.def"
152218893Sdim
153210008Srdivacky  CodeGenOptions() {
154243830Sdim#define CODEGENOPT(Name, Bits, Default) Name = Default;
155243830Sdim#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
156243830Sdim  set##Name(Default);
157243830Sdim#include "clang/Frontend/CodeGenOptions.def"
158210008Srdivacky
159210008Srdivacky    RelocationModel = "pic";
160251662Sdim    memcpy(CoverageVersion, "402*", 4);
161210008Srdivacky  }
162210008Srdivacky};
163210008Srdivacky
164210008Srdivacky}  // end namespace clang
165210008Srdivacky
166210008Srdivacky#endif
167