CodeGenOptions.h revision 279b5eb6910d64a293e9c0e2887a05c65d8737d7
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
19namespace clang {
20
21/// CodeGenOptions - Track various options which control how the code
22/// is optimized and passed to the backend.
23class CodeGenOptions {
24public:
25  enum InliningMethod {
26    NoInlining,         // Perform no inlining whatsoever.
27    NormalInlining,     // Use the standard function inlining pass.
28    OnlyAlwaysInlining  // Only run the always inlining pass.
29  };
30
31  enum ObjCDispatchMethodKind {
32    Legacy = 0,
33    NonLegacy = 1,
34    Mixed = 2
35  };
36
37  unsigned AsmVerbose        : 1; /// -dA, -fverbose-asm.
38  unsigned CXAAtExit         : 1; /// Use __cxa_atexit for calling destructors.
39  unsigned CXXCtorDtorAliases: 1; /// Emit complete ctors/dtors as linker
40                                  /// aliases to base ctors when possible.
41  unsigned DataSections      : 1; /// Set when -fdata-sections is enabled
42  unsigned DebugInfo         : 1; /// Should generate debug info (-g).
43  unsigned DisableFPElim     : 1; /// Set when -fomit-frame-pointer is enabled.
44  unsigned DisableLLVMOpts   : 1; /// Don't run any optimizations, for use in
45                                  /// getting .bc files that correspond to the
46                                  /// internal state before optimizations are
47                                  /// done.
48  unsigned DisableRedZone    : 1; /// Set when -mno-red-zone is enabled.
49  unsigned EmitDeclMetadata  : 1; /// Emit special metadata indicating what Decl*
50                                  /// various IR entities came from.  Only useful
51                                  /// when running CodeGen as a subroutine.
52  unsigned FunctionSections  : 1; /// Set when -ffunction-sections is enabled
53  unsigned HiddenWeakTemplateVTables : 1; /// Emit weak vtables and RTTI for
54                                  /// template classes with hidden visibility
55  unsigned HiddenWeakVTables : 1; /// Emit weak vtables, RTTI, and thunks with
56                                  /// hidden visibility
57  unsigned InstrumentFunctions : 1; /// Set when -finstrument-functions is enabled
58  unsigned MergeAllConstants : 1; /// Merge identical constants.
59  unsigned NoCommon          : 1; /// Set when -fno-common or C++ is enabled.
60  unsigned NoImplicitFloat   : 1; /// Set when -mno-implicit-float is enabled.
61  unsigned NoZeroInitializedInBSS : 1; /// -fno-zero-initialized-in-bss
62  unsigned ObjCDispatchMethod : 2; /// Method of Objective-C dispatch to use.
63  unsigned OmitLeafFramePointer : 1; /// Set when -momit-leaf-frame-pointer is
64                                     /// enabled.
65  unsigned OptimizationLevel : 3; /// The -O[0-4] option specified.
66  unsigned OptimizeSize      : 1; /// If -Os is specified.
67  unsigned RelaxAll          : 1; /// Relax all machine code instructions.
68  unsigned SimplifyLibCalls  : 1; /// Set when -fbuiltin is enabled.
69  unsigned SoftFloat         : 1; /// -soft-float.
70  unsigned TimePasses        : 1; /// Set when -ftime-report is enabled.
71  unsigned UnitAtATime       : 1; /// Unused. For mirroring GCC optimization
72                                  /// selection.
73  unsigned UnrollLoops       : 1; /// Control whether loops are unrolled.
74  unsigned UnwindTables      : 1; /// Emit unwind tables.
75  unsigned VerifyModule      : 1; /// Control whether the module should be run
76                                  /// through the LLVM Verifier.
77
78  /// The code model to use (-mcmodel).
79  std::string CodeModel;
80
81  /// Enable additional debugging information.
82  std::string DebugPass;
83
84  /// The string to embed in the debug information for the compile unit, if
85  /// non-empty.
86  std::string DwarfDebugFlags;
87
88  /// The ABI to use for passing floating point arguments.
89  std::string FloatABI;
90
91  /// The float precision limit to use, if non-empty.
92  std::string LimitFloatPrecision;
93
94  /// The kind of inlining to perform.
95  InliningMethod Inlining;
96
97  /// The user provided name for the "main file", if non-empty. This is useful
98  /// in situations where the input file name does not match the original input
99  /// file, for example with -save-temps.
100  std::string MainFileName;
101
102  /// The name of the relocation model to use.
103  std::string RelocationModel;
104
105public:
106  CodeGenOptions() {
107    AsmVerbose = 0;
108    CXAAtExit = 1;
109    CXXCtorDtorAliases = 0;
110    DataSections = 0;
111    DebugInfo = 0;
112    DisableFPElim = 0;
113    DisableLLVMOpts = 0;
114    DisableRedZone = 0;
115    EmitDeclMetadata = 0;
116    FunctionSections = 0;
117    HiddenWeakTemplateVTables = 0;
118    HiddenWeakVTables = 0;
119    MergeAllConstants = 1;
120    NoCommon = 0;
121    NoImplicitFloat = 0;
122    NoZeroInitializedInBSS = 0;
123    ObjCDispatchMethod = Legacy;
124    OmitLeafFramePointer = 0;
125    OptimizationLevel = 0;
126    OptimizeSize = 0;
127    RelaxAll = 0;
128    SimplifyLibCalls = 1;
129    SoftFloat = 0;
130    TimePasses = 0;
131    UnitAtATime = 1;
132    UnrollLoops = 0;
133    UnwindTables = 0;
134    VerifyModule = 1;
135
136    Inlining = NoInlining;
137    RelocationModel = "pic";
138  }
139
140  ObjCDispatchMethodKind getObjCDispatchMethod() const {
141    return ObjCDispatchMethodKind(ObjCDispatchMethod);
142  }
143};
144
145}  // end namespace clang
146
147#endif
148