CodeGenOptions.h revision 9f084a3166b684573ba49df28fc5792bc37d92e1
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/// CodeGenOptions - Track various options which control how the code
23/// is optimized and passed to the backend.
24class CodeGenOptions {
25public:
26  enum InliningMethod {
27    NoInlining,         // Perform no inlining whatsoever.
28    NormalInlining,     // Use the standard function inlining pass.
29    OnlyAlwaysInlining  // Only run the always inlining pass.
30  };
31
32  enum ObjCDispatchMethodKind {
33    Legacy = 0,
34    NonLegacy = 1,
35    Mixed = 2
36  };
37
38  unsigned AsmVerbose        : 1; /// -dA, -fverbose-asm.
39  unsigned ObjCAutoRefCountExceptions : 1; /// Whether ARC should be EH-safe.
40  unsigned CXAAtExit         : 1; /// Use __cxa_atexit for calling destructors.
41  unsigned CXXCtorDtorAliases: 1; /// Emit complete ctors/dtors as linker
42                                  /// aliases to base ctors when possible.
43  unsigned DataSections      : 1; /// Set when -fdata-sections is enabled
44  unsigned DebugInfo         : 1; /// Should generate debug info (-g).
45  unsigned LimitDebugInfo    : 1; /// Limit generated debug info to reduce size.
46  unsigned DisableFPElim     : 1; /// Set when -fomit-frame-pointer is enabled.
47  unsigned DisableLLVMOpts   : 1; /// Don't run any optimizations, for use in
48                                  /// getting .bc files that correspond to the
49                                  /// internal state before optimizations are
50                                  /// done.
51  unsigned DisableRedZone    : 1; /// Set when -mno-red-zone is enabled.
52  unsigned EmitDeclMetadata  : 1; /// Emit special metadata indicating what
53                                  /// Decl* various IR entities came from.  Only
54                                  /// useful when running CodeGen as a
55                                  /// subroutine.
56  unsigned EmitGcovArcs      : 1; /// Emit coverage data files, aka. GCDA.
57  unsigned EmitGcovNotes     : 1; /// Emit coverage "notes" files, aka GCNO.
58  unsigned ForbidGuardVariables : 1; /// Issue errors if C++ guard variables
59                                  /// are required
60  unsigned FunctionSections  : 1; /// Set when -ffunction-sections is enabled
61  unsigned HiddenWeakTemplateVTables : 1; /// Emit weak vtables and RTTI for
62                                  /// template classes with hidden visibility
63  unsigned HiddenWeakVTables : 1; /// Emit weak vtables, RTTI, and thunks with
64                                  /// hidden visibility.
65  unsigned InstrumentFunctions : 1; /// Set when -finstrument-functions is
66                                    /// enabled.
67  unsigned InstrumentForProfiling : 1; /// Set when -pg is enabled
68  unsigned LessPreciseFPMAD  : 1; /// Enable less precise MAD instructions to be
69                                  /// generated.
70  unsigned MergeAllConstants : 1; /// Merge identical constants.
71  unsigned NoCommon          : 1; /// Set when -fno-common or C++ is enabled.
72  unsigned NoDwarf2CFIAsm    : 1; /// Set when -fno-dwarf2-cfi-asm is enabled.
73  unsigned NoExecStack       : 1; /// Set when -Wa,--noexecstack is enabled.
74  unsigned NoImplicitFloat   : 1; /// Set when -mno-implicit-float is enabled.
75  unsigned NoInfsFPMath      : 1; /// Assume FP arguments, results not +-Inf.
76  unsigned NoNaNsFPMath      : 1; /// Assume FP arguments, results not NaN.
77  unsigned NoZeroInitializedInBSS : 1; /// -fno-zero-initialized-in-bss
78  unsigned ObjCDispatchMethod : 2; /// Method of Objective-C dispatch to use.
79  unsigned ObjCRuntimeHasARC : 1; /// The target runtime supports ARC natively
80  unsigned OmitLeafFramePointer : 1; /// Set when -momit-leaf-frame-pointer is
81                                     /// enabled.
82  unsigned OptimizationLevel : 3; /// The -O[0-4] option specified.
83  unsigned OptimizeSize      : 2; /// If -Os (==1) or -Oz (==2) is specified.
84  unsigned RelaxAll          : 1; /// Relax all machine code instructions.
85  unsigned RelaxedAliasing   : 1; /// Set when -fno-strict-aliasing is enabled.
86  unsigned SaveTempLabels    : 1; /// Save temporary labels.
87  unsigned SimplifyLibCalls  : 1; /// Set when -fbuiltin is enabled.
88  unsigned SoftFloat         : 1; /// -soft-float.
89  unsigned TimePasses        : 1; /// Set when -ftime-report is enabled.
90  unsigned UnitAtATime       : 1; /// Unused. For mirroring GCC optimization
91                                  /// selection.
92  unsigned UnrollLoops       : 1; /// Control whether loops are unrolled.
93  unsigned UnsafeFPMath      : 1; /// Allow unsafe floating point optzns.
94  unsigned UnwindTables      : 1; /// Emit unwind tables.
95
96  /// Attempt to use register sized accesses to bit-fields in structures, when
97  /// possible.
98  unsigned UseRegisterSizedBitfieldAccess : 1;
99
100  unsigned VerifyModule      : 1; /// Control whether the module should be run
101                                  /// through the LLVM Verifier.
102
103  /// The code model to use (-mcmodel).
104  std::string CodeModel;
105
106  /// The filename with path we use for coverage files. The extension will be
107  /// replaced.
108  std::string CoverageFile;
109
110  /// Enable additional debugging information.
111  std::string DebugPass;
112
113  /// The string to embed in the debug information for the compile unit, if
114  /// non-empty.
115  std::string DwarfDebugFlags;
116
117  /// The ABI to use for passing floating point arguments.
118  std::string FloatABI;
119
120  /// The float precision limit to use, if non-empty.
121  std::string LimitFloatPrecision;
122
123  /// The kind of inlining to perform.
124  InliningMethod Inlining;
125
126  /// The user provided name for the "main file", if non-empty. This is useful
127  /// in situations where the input file name does not match the original input
128  /// file, for example with -save-temps.
129  std::string MainFileName;
130
131  /// The name of the relocation model to use.
132  std::string RelocationModel;
133
134  /// A list of command-line options to forward to the LLVM backend.
135  std::vector<std::string> BackendOptions;
136
137  /// The user specified number of registers to be used for integral arguments,
138  /// or 0 if unspecified.
139  unsigned NumRegisterParameters;
140
141public:
142  CodeGenOptions() {
143    AsmVerbose = 0;
144    ObjCAutoRefCountExceptions = 0;
145    CXAAtExit = 1;
146    CXXCtorDtorAliases = 0;
147    DataSections = 0;
148    DebugInfo = 0;
149    LimitDebugInfo = 0;
150    DisableFPElim = 0;
151    DisableLLVMOpts = 0;
152    DisableRedZone = 0;
153    EmitDeclMetadata = 0;
154    EmitGcovArcs = 0;
155    EmitGcovNotes = 0;
156    ForbidGuardVariables = 0;
157    FunctionSections = 0;
158    HiddenWeakTemplateVTables = 0;
159    HiddenWeakVTables = 0;
160    InstrumentFunctions = 0;
161    InstrumentForProfiling = 0;
162    LessPreciseFPMAD = 0;
163    MergeAllConstants = 1;
164    NoCommon = 0;
165    NoDwarf2CFIAsm = 0;
166    NoImplicitFloat = 0;
167    NoInfsFPMath = 0;
168    NoNaNsFPMath = 0;
169    NoZeroInitializedInBSS = 0;
170    NumRegisterParameters = 0;
171    ObjCDispatchMethod = Legacy;
172    OmitLeafFramePointer = 0;
173    OptimizationLevel = 0;
174    OptimizeSize = 0;
175    RelaxAll = 0;
176    RelaxedAliasing = 0;
177    SaveTempLabels = 0;
178    SimplifyLibCalls = 1;
179    SoftFloat = 0;
180    TimePasses = 0;
181    UnitAtATime = 1;
182    UnrollLoops = 0;
183    UnsafeFPMath = 0;
184    UnwindTables = 0;
185    UseRegisterSizedBitfieldAccess = 0;
186    VerifyModule = 1;
187
188    Inlining = NoInlining;
189    RelocationModel = "pic";
190  }
191
192  ObjCDispatchMethodKind getObjCDispatchMethod() const {
193    return ObjCDispatchMethodKind(ObjCDispatchMethod);
194  }
195};
196
197}  // end namespace clang
198
199#endif
200