Add the support code to enable the dwarf accelerator tables. Upcoming patches
[oota-llvm.git] / include / llvm / MC / MCObjectFileInfo.h
1 //===-- llvm/MC/MCObjectFileInfo.h - Object File Info -----------*- 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 describes common object file formats.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_MC_MCBJECTFILEINFO_H
15 #define LLVM_MC_MCBJECTFILEINFO_H
16
17 #include "llvm/MC/MCCodeGenInfo.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/SectionKind.h"
20
21 namespace llvm {
22 class MCContext;
23 class MCSection;
24 class Triple;
25   
26 class MCObjectFileInfo {  
27 protected:
28   /// CommDirectiveSupportsAlignment - True if .comm supports alignment.  This
29   /// is a hack for as long as we support 10.4 Tiger, whose assembler doesn't
30   /// support alignment on comm.
31   bool CommDirectiveSupportsAlignment;
32   
33   /// SupportsWeakEmptyEHFrame - True if target object file supports a
34   /// weak_definition of constant 0 for an omitted EH frame.
35   bool SupportsWeakOmittedEHFrame;
36   
37   /// IsFunctionEHFrameSymbolPrivate - This flag is set to true if the
38   /// "EH_frame" symbol for EH information should be an assembler temporary (aka
39   /// private linkage, aka an L or .L label) or false if it should be a normal
40   /// non-.globl label.  This defaults to true.
41   bool IsFunctionEHFrameSymbolPrivate;
42
43   /// PersonalityEncoding, LSDAEncoding, FDEEncoding, TTypeEncoding - Some
44   /// encoding values for EH.
45   unsigned PersonalityEncoding;
46   unsigned LSDAEncoding;
47   unsigned FDEEncoding;
48   unsigned FDECFIEncoding;
49   unsigned TTypeEncoding;
50
51   /// TextSection - Section directive for standard text.
52   ///
53   const MCSection *TextSection;
54   
55   /// DataSection - Section directive for standard data.
56   ///
57   const MCSection *DataSection;
58   
59   /// BSSSection - Section that is default initialized to zero.
60   const MCSection *BSSSection;
61   
62   /// ReadOnlySection - Section that is readonly and can contain arbitrary
63   /// initialized data.  Targets are not required to have a readonly section.
64   /// If they don't, various bits of code will fall back to using the data
65   /// section for constants.
66   const MCSection *ReadOnlySection;
67   
68   /// StaticCtorSection - This section contains the static constructor pointer
69   /// list.
70   const MCSection *StaticCtorSection;
71
72   /// StaticDtorSection - This section contains the static destructor pointer
73   /// list.
74   const MCSection *StaticDtorSection;
75   
76   /// LSDASection - If exception handling is supported by the target, this is
77   /// the section the Language Specific Data Area information is emitted to.
78   const MCSection *LSDASection;
79
80   /// CompactUnwindSection - If exception handling is supported by the target
81   /// and the target can support a compact representation of the CIE and FDE,
82   /// this is the section to emit them into.
83   const MCSection *CompactUnwindSection;
84
85   /// DwarfAccelNamesSection, DwarfAccelObjCSection
86   /// If we use the DWARF accelerated hash tables then we want toe emit these
87   /// sections.
88   const MCSection *DwarfAccelNamesSection;
89   const MCSection *DwarfAccelObjCSection;
90   const MCSection *DwarfAccelNamespaceSection;
91   const MCSection *DwarfAccelTypesSection;
92
93   // Dwarf sections for debug info.  If a target supports debug info, these must
94   // be set.
95   const MCSection *DwarfAbbrevSection;
96   const MCSection *DwarfInfoSection;
97   const MCSection *DwarfLineSection;
98   const MCSection *DwarfFrameSection;
99   const MCSection *DwarfPubNamesSection;
100   const MCSection *DwarfPubTypesSection;
101   const MCSection *DwarfDebugInlineSection;
102   const MCSection *DwarfStrSection;
103   const MCSection *DwarfLocSection;
104   const MCSection *DwarfARangesSection;
105   const MCSection *DwarfRangesSection;
106   const MCSection *DwarfMacroInfoSection;
107
108   // Extra TLS Variable Data section.  If the target needs to put additional
109   // information for a TLS variable, it'll go here.
110   const MCSection *TLSExtraDataSection;
111   
112   /// TLSDataSection - Section directive for Thread Local data.
113   /// ELF and MachO only.
114   const MCSection *TLSDataSection;        // Defaults to ".tdata".
115
116   /// TLSBSSSection - Section directive for Thread Local uninitialized data.
117   /// Null if this target doesn't support a BSS section.
118   /// ELF and MachO only.
119   const MCSection *TLSBSSSection;         // Defaults to ".tbss".
120
121
122   /// EHFrameSection - EH frame section. It is initialized on demand so it
123   /// can be overwritten (with uniquing).
124   const MCSection *EHFrameSection;
125
126   /// ELF specific sections.
127   ///
128   const MCSection *DataRelSection;
129   const MCSection *DataRelLocalSection;
130   const MCSection *DataRelROSection;
131   const MCSection *DataRelROLocalSection;
132   const MCSection *MergeableConst4Section;
133   const MCSection *MergeableConst8Section;
134   const MCSection *MergeableConst16Section;
135
136   /// MachO specific sections.
137   ///
138
139   /// TLSTLVSection - Section for thread local structure information.
140   /// Contains the source code name of the variable, visibility and a pointer
141   /// to the initial value (.tdata or .tbss).
142   const MCSection *TLSTLVSection;         // Defaults to ".tlv".
143   
144   /// TLSThreadInitSection - Section for thread local data initialization
145   /// functions.
146   const MCSection *TLSThreadInitSection;  // Defaults to ".thread_init_func".
147   
148   const MCSection *CStringSection;
149   const MCSection *UStringSection;
150   const MCSection *TextCoalSection;
151   const MCSection *ConstTextCoalSection;
152   const MCSection *ConstDataSection;
153   const MCSection *DataCoalSection;
154   const MCSection *DataCommonSection;
155   const MCSection *DataBSSSection;
156   const MCSection *FourByteConstantSection;
157   const MCSection *EightByteConstantSection;
158   const MCSection *SixteenByteConstantSection;
159   const MCSection *LazySymbolPointerSection;
160   const MCSection *NonLazySymbolPointerSection;
161
162   /// COFF specific sections.
163   ///
164   const MCSection *DrectveSection;
165   const MCSection *PDataSection;
166   const MCSection *XDataSection;
167   
168 public:
169   void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
170                             MCContext &ctx);
171   
172   bool isFunctionEHFrameSymbolPrivate() const {
173     return IsFunctionEHFrameSymbolPrivate;
174   }
175   bool getSupportsWeakOmittedEHFrame() const {
176     return SupportsWeakOmittedEHFrame;
177   }
178   bool getCommDirectiveSupportsAlignment() const {
179     return CommDirectiveSupportsAlignment;
180   }
181
182   unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
183   unsigned getLSDAEncoding() const { return LSDAEncoding; }
184   unsigned getFDEEncoding(bool CFI) const {
185     return CFI ? FDECFIEncoding : FDEEncoding;
186   }
187   unsigned getTTypeEncoding() const { return TTypeEncoding; }
188
189   const MCSection *getTextSection() const { return TextSection; }
190   const MCSection *getDataSection() const { return DataSection; }
191   const MCSection *getBSSSection() const { return BSSSection; }
192   const MCSection *getStaticCtorSection() const { return StaticCtorSection; }
193   const MCSection *getStaticDtorSection() const { return StaticDtorSection; }
194   const MCSection *getLSDASection() const { return LSDASection; }
195   const MCSection *getCompactUnwindSection() const{
196     return CompactUnwindSection;
197   }
198   const MCSection *getDwarfAccelNamesSection() const {
199     return DwarfAccelNamesSection;
200   }
201   const MCSection *getDwarfAccelObjCSection() const {
202     return DwarfAccelObjCSection;
203   }
204   const MCSection *getDwarfAccelNamespaceSection() const {
205     return DwarfAccelNamespaceSection;
206   }
207   const MCSection *getDwarfAccelTypesSection() const {
208     return DwarfAccelTypesSection;
209   }
210   const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
211   const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
212   const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
213   const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
214   const MCSection *getDwarfPubNamesSection() const{return DwarfPubNamesSection;}
215   const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
216   const MCSection *getDwarfDebugInlineSection() const {
217     return DwarfDebugInlineSection;
218   }
219   const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
220   const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
221   const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
222   const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
223   const MCSection *getDwarfMacroInfoSection() const {
224     return DwarfMacroInfoSection;
225   }
226   const MCSection *getTLSExtraDataSection() const {
227     return TLSExtraDataSection;
228   }
229   const MCSection *getTLSDataSection() const { return TLSDataSection; }
230   const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
231
232   /// ELF specific sections.
233   ///
234   const MCSection *getDataRelSection() const { return DataRelSection; }
235   const MCSection *getDataRelLocalSection() const {
236     return DataRelLocalSection;
237   }
238   const MCSection *getDataRelROSection() const { return DataRelROSection; }
239   const MCSection *getDataRelROLocalSection() const {
240     return DataRelROLocalSection;
241   }
242   const MCSection *getMergeableConst4Section() const {
243     return MergeableConst4Section;
244   }
245   const MCSection *getMergeableConst8Section() const {
246     return MergeableConst8Section;
247   }
248   const MCSection *getMergeableConst16Section() const {
249     return MergeableConst16Section;
250   }
251
252   /// MachO specific sections.
253   ///
254   const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
255   const MCSection *getTLSThreadInitSection() const {
256     return TLSThreadInitSection;
257   }
258   const MCSection *getCStringSection() const { return CStringSection; }
259   const MCSection *getUStringSection() const { return UStringSection; }
260   const MCSection *getTextCoalSection() const { return TextCoalSection; }
261   const MCSection *getConstTextCoalSection() const {
262     return ConstTextCoalSection;
263   }
264   const MCSection *getConstDataSection() const { return ConstDataSection; }
265   const MCSection *getDataCoalSection() const { return DataCoalSection; }
266   const MCSection *getDataCommonSection() const { return DataCommonSection; }
267   const MCSection *getDataBSSSection() const { return DataBSSSection; }
268   const MCSection *getFourByteConstantSection() const {
269     return FourByteConstantSection;
270   }
271   const MCSection *getEightByteConstantSection() const {
272     return EightByteConstantSection;
273   }
274   const MCSection *getSixteenByteConstantSection() const {
275     return SixteenByteConstantSection;
276   }
277   const MCSection *getLazySymbolPointerSection() const {
278     return LazySymbolPointerSection;
279   }
280   const MCSection *getNonLazySymbolPointerSection() const {
281     return NonLazySymbolPointerSection;
282   }
283
284   /// COFF specific sections.
285   ///
286   const MCSection *getDrectveSection() const { return DrectveSection; }
287   const MCSection *getPDataSection() const { return PDataSection; }
288   const MCSection *getXDataSection() const { return XDataSection; }
289
290   const MCSection *getEHFrameSection() {
291     if (!EHFrameSection)
292       InitEHFrameSection();
293     return EHFrameSection;
294   }
295
296 private:
297   enum Environment { IsMachO, IsELF, IsCOFF };
298   Environment Env;
299   Reloc::Model RelocM;
300   CodeModel::Model CMModel;
301   MCContext *Ctx;
302
303   void InitMachOMCObjectFileInfo(Triple T);
304   void InitELFMCObjectFileInfo(Triple T);
305   void InitCOFFMCObjectFileInfo(Triple T);
306
307   /// InitEHFrameSection - Initialize EHFrameSection on demand.
308   ///
309   void InitEHFrameSection();
310 };
311
312 } // end namespace llvm
313
314 #endif