]> granicus.if.org Git - clang/blob - include/clang/Frontend/CodeGenOptions.h
Implement mcount profiling, enabled via -pg.
[clang] / include / clang / Frontend / CodeGenOptions.h
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
19 namespace clang {
20
21 /// CodeGenOptions - Track various options which control how the code
22 /// is optimized and passed to the backend.
23 class CodeGenOptions {
24 public:
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 LimitDebugInfo    : 1; /// Limit generated debug info to reduce size.
44   unsigned DisableFPElim     : 1; /// Set when -fomit-frame-pointer is enabled.
45   unsigned DisableLLVMOpts   : 1; /// Don't run any optimizations, for use in
46                                   /// getting .bc files that correspond to the
47                                   /// internal state before optimizations are
48                                   /// done.
49   unsigned DisableRedZone    : 1; /// Set when -mno-red-zone is enabled.
50   unsigned EmitDeclMetadata  : 1; /// Emit special metadata indicating what
51                                   /// Decl* various IR entities came from.  Only
52                                   /// useful when running CodeGen as a
53                                   /// subroutine.
54   unsigned FunctionSections  : 1; /// Set when -ffunction-sections is enabled
55   unsigned HiddenWeakTemplateVTables : 1; /// Emit weak vtables and RTTI for
56                                   /// template classes with hidden visibility
57   unsigned HiddenWeakVTables : 1; /// Emit weak vtables, RTTI, and thunks with
58                                   /// hidden visibility.
59   unsigned InstrumentFunctions : 1; /// Set when -finstrument-functions is
60                                     /// enabled.
61   unsigned InstrumentForProfiling : 1; /// Set when -pg is enabled
62   unsigned LessPreciseFPMAD  : 1; /// Enable less precise MAD instructions to be
63                                   /// generated.
64   unsigned MergeAllConstants : 1; /// Merge identical constants.
65   unsigned NoCommon          : 1; /// Set when -fno-common or C++ is enabled.
66   unsigned NoImplicitFloat   : 1; /// Set when -mno-implicit-float is enabled.
67   unsigned NoInfsFPMath      : 1; /// Assume FP arguments, results not +-Inf.
68   unsigned NoNaNsFPMath      : 1; /// Assume FP arguments, results not NaN.
69   unsigned NoZeroInitializedInBSS : 1; /// -fno-zero-initialized-in-bss
70   unsigned ObjCDispatchMethod : 2; /// Method of Objective-C dispatch to use.
71   unsigned OmitLeafFramePointer : 1; /// Set when -momit-leaf-frame-pointer is
72                                      /// enabled.
73   unsigned OptimizationLevel : 3; /// The -O[0-4] option specified.
74   unsigned OptimizeSize      : 1; /// If -Os is specified.
75   unsigned RelaxAll          : 1; /// Relax all machine code instructions.
76   unsigned RelaxedAliasing   : 1; /// Set when -fno-strict-aliasing is enabled.
77   unsigned SimplifyLibCalls  : 1; /// Set when -fbuiltin is enabled.
78   unsigned SoftFloat         : 1; /// -soft-float.
79   unsigned TimePasses        : 1; /// Set when -ftime-report is enabled.
80   unsigned UnitAtATime       : 1; /// Unused. For mirroring GCC optimization
81                                   /// selection.
82   unsigned UnrollLoops       : 1; /// Control whether loops are unrolled.
83   unsigned UnsafeFPMath      : 1; /// Allow unsafe floating point optzns.
84   unsigned UnwindTables      : 1; /// Emit unwind tables.
85   unsigned VerifyModule      : 1; /// Control whether the module should be run
86                                   /// through the LLVM Verifier.
87
88   /// The code model to use (-mcmodel).
89   std::string CodeModel;
90
91   /// Enable additional debugging information.
92   std::string DebugPass;
93
94   /// The string to embed in the debug information for the compile unit, if
95   /// non-empty.
96   std::string DwarfDebugFlags;
97
98   /// The ABI to use for passing floating point arguments.
99   std::string FloatABI;
100
101   /// The float precision limit to use, if non-empty.
102   std::string LimitFloatPrecision;
103
104   /// The kind of inlining to perform.
105   InliningMethod Inlining;
106
107   /// The user provided name for the "main file", if non-empty. This is useful
108   /// in situations where the input file name does not match the original input
109   /// file, for example with -save-temps.
110   std::string MainFileName;
111
112   /// The name of the relocation model to use.
113   std::string RelocationModel;
114
115   /// The user specified number of registers to be used for integral arguments,
116   /// or 0 if unspecified.
117   unsigned NumRegisterParameters;
118
119 public:
120   CodeGenOptions() {
121     AsmVerbose = 0;
122     CXAAtExit = 1;
123     CXXCtorDtorAliases = 0;
124     DataSections = 0;
125     DebugInfo = 0;
126     LimitDebugInfo = 0;
127     DisableFPElim = 0;
128     DisableLLVMOpts = 0;
129     DisableRedZone = 0;
130     EmitDeclMetadata = 0;
131     FunctionSections = 0;
132     HiddenWeakTemplateVTables = 0;
133     HiddenWeakVTables = 0;
134     InstrumentFunctions = 0;
135     InstrumentForProfiling = 0;
136     LessPreciseFPMAD = 0;
137     MergeAllConstants = 1;
138     NoCommon = 0;
139     NoImplicitFloat = 0;
140     NoInfsFPMath = 0;
141     NoNaNsFPMath = 0;
142     NoZeroInitializedInBSS = 0;
143     NumRegisterParameters = 0;
144     ObjCDispatchMethod = Legacy;
145     OmitLeafFramePointer = 0;
146     OptimizationLevel = 0;
147     OptimizeSize = 0;
148     RelaxAll = 0;
149     RelaxedAliasing = 0;
150     SimplifyLibCalls = 1;
151     SoftFloat = 0;
152     TimePasses = 0;
153     UnitAtATime = 1;
154     UnrollLoops = 0;
155     UnsafeFPMath = 0;
156     UnwindTables = 0;
157     VerifyModule = 1;
158
159     Inlining = NoInlining;
160     RelocationModel = "pic";
161   }
162
163   ObjCDispatchMethodKind getObjCDispatchMethod() const {
164     return ObjCDispatchMethodKind(ObjCDispatchMethod);
165   }
166 };
167
168 }  // end namespace clang
169
170 #endif