DebugInfo: Move type units into the debug_types section with appropriate comdat group...
[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/Support/CodeGen.h"
18
19 namespace llvm {
20   class MCContext;
21   class MCSection;
22   class StringRef;
23   class Triple;
24
25 class MCObjectFileInfo {
26 protected:
27   /// CommDirectiveSupportsAlignment - True if .comm supports alignment.  This
28   /// is a hack for as long as we support 10.4 Tiger, whose assembler doesn't
29   /// support alignment on comm.
30   bool CommDirectiveSupportsAlignment;
31
32   /// SupportsWeakEmptyEHFrame - True if target object file supports a
33   /// weak_definition of constant 0 for an omitted EH frame.
34   bool SupportsWeakOmittedEHFrame;
35
36   /// IsFunctionEHFrameSymbolPrivate - This flag is set to true if the
37   /// "EH_frame" symbol for EH information should be an assembler temporary (aka
38   /// private linkage, aka an L or .L label) or false if it should be a normal
39   /// non-.globl label.  This defaults to true.
40   bool IsFunctionEHFrameSymbolPrivate;
41
42   /// PersonalityEncoding, LSDAEncoding, FDEEncoding, TTypeEncoding - Some
43   /// encoding values for EH.
44   unsigned PersonalityEncoding;
45   unsigned LSDAEncoding;
46   unsigned FDEEncoding;
47   unsigned FDECFIEncoding;
48   unsigned TTypeEncoding;
49
50   /// Section flags for eh_frame
51   unsigned EHSectionType;
52   unsigned EHSectionFlags;
53
54   /// CompactUnwindDwarfEHFrameOnly - Compact unwind encoding indicating that we
55   /// should emit only an EH frame.
56   unsigned CompactUnwindDwarfEHFrameOnly;
57
58   /// TextSection - Section directive for standard text.
59   ///
60   const MCSection *TextSection;
61
62   /// DataSection - Section directive for standard data.
63   ///
64   const MCSection *DataSection;
65
66   /// BSSSection - Section that is default initialized to zero.
67   const MCSection *BSSSection;
68
69   /// ReadOnlySection - Section that is readonly and can contain arbitrary
70   /// initialized data.  Targets are not required to have a readonly section.
71   /// If they don't, various bits of code will fall back to using the data
72   /// section for constants.
73   const MCSection *ReadOnlySection;
74
75   /// StaticCtorSection - This section contains the static constructor pointer
76   /// list.
77   const MCSection *StaticCtorSection;
78
79   /// StaticDtorSection - This section contains the static destructor pointer
80   /// list.
81   const MCSection *StaticDtorSection;
82
83   /// LSDASection - If exception handling is supported by the target, this is
84   /// the section the Language Specific Data Area information is emitted to.
85   const MCSection *LSDASection;
86
87   /// CompactUnwindSection - If exception handling is supported by the target
88   /// and the target can support a compact representation of the CIE and FDE,
89   /// this is the section to emit them into.
90   const MCSection *CompactUnwindSection;
91
92   // Dwarf sections for debug info.  If a target supports debug info, these must
93   // be set.
94   const MCSection *DwarfAbbrevSection;
95   const MCSection *DwarfInfoSection;
96   const MCSection *DwarfLineSection;
97   const MCSection *DwarfFrameSection;
98   const MCSection *DwarfPubTypesSection;
99   const MCSection *DwarfDebugInlineSection;
100   const MCSection *DwarfStrSection;
101   const MCSection *DwarfLocSection;
102   const MCSection *DwarfARangesSection;
103   const MCSection *DwarfRangesSection;
104   const MCSection *DwarfMacroInfoSection;
105   // The pubnames section is no longer generated by default.  The generation
106   // can be enabled by a compiler flag.
107   const MCSection *DwarfPubNamesSection;
108
109   // DWARF5 Experimental Debug Info Sections
110   /// DwarfAccelNamesSection, DwarfAccelObjCSection,
111   /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
112   /// If we use the DWARF accelerated hash tables then we want to emit these
113   /// sections.
114   const MCSection *DwarfAccelNamesSection;
115   const MCSection *DwarfAccelObjCSection;
116   const MCSection *DwarfAccelNamespaceSection;
117   const MCSection *DwarfAccelTypesSection;
118
119   /// These are used for the Fission separate debug information files.
120   const MCSection *DwarfInfoDWOSection;
121   const MCSection *DwarfAbbrevDWOSection;
122   const MCSection *DwarfStrDWOSection;
123   const MCSection *DwarfLineDWOSection;
124   const MCSection *DwarfLocDWOSection;
125   const MCSection *DwarfStrOffDWOSection;
126   const MCSection *DwarfAddrSection;
127
128   /// Sections for newer gnu pubnames and pubtypes.
129   const MCSection *DwarfGnuPubNamesSection;
130   const MCSection *DwarfGnuPubTypesSection;
131
132   // Extra TLS Variable Data section.  If the target needs to put additional
133   // information for a TLS variable, it'll go here.
134   const MCSection *TLSExtraDataSection;
135
136   /// TLSDataSection - Section directive for Thread Local data.
137   /// ELF, MachO and COFF.
138   const MCSection *TLSDataSection;        // Defaults to ".tdata".
139
140   /// TLSBSSSection - Section directive for Thread Local uninitialized data.
141   /// Null if this target doesn't support a BSS section.
142   /// ELF and MachO only.
143   const MCSection *TLSBSSSection;         // Defaults to ".tbss".
144
145   /// StackMap section.
146   const MCSection *StackMapSection;
147
148   /// EHFrameSection - EH frame section. It is initialized on demand so it
149   /// can be overwritten (with uniquing).
150   const MCSection *EHFrameSection;
151
152   /// ELF specific sections.
153   ///
154   const MCSection *DataRelSection;
155   const MCSection *DataRelLocalSection;
156   const MCSection *DataRelROSection;
157   const MCSection *DataRelROLocalSection;
158   const MCSection *MergeableConst4Section;
159   const MCSection *MergeableConst8Section;
160   const MCSection *MergeableConst16Section;
161
162   /// MachO specific sections.
163   ///
164
165   /// TLSTLVSection - Section for thread local structure information.
166   /// Contains the source code name of the variable, visibility and a pointer
167   /// to the initial value (.tdata or .tbss).
168   const MCSection *TLSTLVSection;         // Defaults to ".tlv".
169
170   /// TLSThreadInitSection - Section for thread local data initialization
171   /// functions.
172   const MCSection *TLSThreadInitSection;  // Defaults to ".thread_init_func".
173
174   const MCSection *CStringSection;
175   const MCSection *UStringSection;
176   const MCSection *TextCoalSection;
177   const MCSection *ConstTextCoalSection;
178   const MCSection *ConstDataSection;
179   const MCSection *DataCoalSection;
180   const MCSection *DataCommonSection;
181   const MCSection *DataBSSSection;
182   const MCSection *FourByteConstantSection;
183   const MCSection *EightByteConstantSection;
184   const MCSection *SixteenByteConstantSection;
185   const MCSection *LazySymbolPointerSection;
186   const MCSection *NonLazySymbolPointerSection;
187
188   /// COFF specific sections.
189   ///
190   const MCSection *DrectveSection;
191   const MCSection *PDataSection;
192   const MCSection *XDataSection;
193
194 public:
195   void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
196                             MCContext &ctx);
197
198   bool isFunctionEHFrameSymbolPrivate() const {
199     return IsFunctionEHFrameSymbolPrivate;
200   }
201   bool getSupportsWeakOmittedEHFrame() const {
202     return SupportsWeakOmittedEHFrame;
203   }
204   bool getCommDirectiveSupportsAlignment() const {
205     return CommDirectiveSupportsAlignment;
206   }
207
208   unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
209   unsigned getLSDAEncoding() const { return LSDAEncoding; }
210   unsigned getFDEEncoding(bool CFI) const {
211     return CFI ? FDECFIEncoding : FDEEncoding;
212   }
213   unsigned getTTypeEncoding() const { return TTypeEncoding; }
214
215   unsigned getCompactUnwindDwarfEHFrameOnly() const {
216     return CompactUnwindDwarfEHFrameOnly;
217   }
218
219   const MCSection *getTextSection() const { return TextSection; }
220   const MCSection *getDataSection() const { return DataSection; }
221   const MCSection *getBSSSection() const { return BSSSection; }
222   const MCSection *getLSDASection() const { return LSDASection; }
223   const MCSection *getCompactUnwindSection() const{
224     return CompactUnwindSection;
225   }
226   const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
227   const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
228   const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
229   const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
230   const MCSection *getDwarfPubNamesSection() const{return DwarfPubNamesSection;}
231   const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
232   const MCSection *getDwarfGnuPubNamesSection() const {
233     return DwarfGnuPubNamesSection;
234   }
235   const MCSection *getDwarfGnuPubTypesSection() const {
236     return DwarfGnuPubTypesSection;
237   }
238   const MCSection *getDwarfDebugInlineSection() const {
239     return DwarfDebugInlineSection;
240   }
241   const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
242   const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
243   const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
244   const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
245   const MCSection *getDwarfMacroInfoSection() const {
246     return DwarfMacroInfoSection;
247   }
248
249   // DWARF5 Experimental Debug Info Sections
250   const MCSection *getDwarfAccelNamesSection() const {
251     return DwarfAccelNamesSection;
252   }
253   const MCSection *getDwarfAccelObjCSection() const {
254     return DwarfAccelObjCSection;
255   }
256   const MCSection *getDwarfAccelNamespaceSection() const {
257     return DwarfAccelNamespaceSection;
258   }
259   const MCSection *getDwarfAccelTypesSection() const {
260     return DwarfAccelTypesSection;
261   }
262   const MCSection *getDwarfInfoDWOSection() const {
263     return DwarfInfoDWOSection;
264   }
265   const MCSection *getDwarfTypesSection(uint64_t Hash) const;
266   const MCSection *getDwarfTypesDWOSection(uint64_t Hash) const;
267   const MCSection *getDwarfAbbrevDWOSection() const {
268     return DwarfAbbrevDWOSection;
269   }
270   const MCSection *getDwarfStrDWOSection() const {
271     return DwarfStrDWOSection;
272   }
273   const MCSection *getDwarfLineDWOSection() const {
274     return DwarfLineDWOSection;
275   }
276   const MCSection *getDwarfLocDWOSection() const {
277     return DwarfLocDWOSection;
278   }
279   const MCSection *getDwarfStrOffDWOSection() const {
280     return DwarfStrOffDWOSection;
281   }
282   const MCSection *getDwarfAddrSection() const {
283     return DwarfAddrSection;
284   }
285
286   const MCSection *getTLSExtraDataSection() const {
287     return TLSExtraDataSection;
288   }
289   const MCSection *getTLSDataSection() const { return TLSDataSection; }
290   const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
291
292   const MCSection *getStackMapSection() const { return StackMapSection; }
293
294   /// ELF specific sections.
295   ///
296   const MCSection *getDataRelSection() const { return DataRelSection; }
297   const MCSection *getDataRelLocalSection() const {
298     return DataRelLocalSection;
299   }
300   const MCSection *getDataRelROSection() const { return DataRelROSection; }
301   const MCSection *getDataRelROLocalSection() const {
302     return DataRelROLocalSection;
303   }
304   const MCSection *getMergeableConst4Section() const {
305     return MergeableConst4Section;
306   }
307   const MCSection *getMergeableConst8Section() const {
308     return MergeableConst8Section;
309   }
310   const MCSection *getMergeableConst16Section() const {
311     return MergeableConst16Section;
312   }
313
314   /// MachO specific sections.
315   ///
316   const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
317   const MCSection *getTLSThreadInitSection() const {
318     return TLSThreadInitSection;
319   }
320   const MCSection *getCStringSection() const { return CStringSection; }
321   const MCSection *getUStringSection() const { return UStringSection; }
322   const MCSection *getTextCoalSection() const { return TextCoalSection; }
323   const MCSection *getConstTextCoalSection() const {
324     return ConstTextCoalSection;
325   }
326   const MCSection *getConstDataSection() const { return ConstDataSection; }
327   const MCSection *getDataCoalSection() const { return DataCoalSection; }
328   const MCSection *getDataCommonSection() const { return DataCommonSection; }
329   const MCSection *getDataBSSSection() const { return DataBSSSection; }
330   const MCSection *getFourByteConstantSection() const {
331     return FourByteConstantSection;
332   }
333   const MCSection *getEightByteConstantSection() const {
334     return EightByteConstantSection;
335   }
336   const MCSection *getSixteenByteConstantSection() const {
337     return SixteenByteConstantSection;
338   }
339   const MCSection *getLazySymbolPointerSection() const {
340     return LazySymbolPointerSection;
341   }
342   const MCSection *getNonLazySymbolPointerSection() const {
343     return NonLazySymbolPointerSection;
344   }
345
346   /// COFF specific sections.
347   ///
348   const MCSection *getDrectveSection() const { return DrectveSection; }
349   const MCSection *getPDataSection() const { return PDataSection; }
350   const MCSection *getXDataSection() const { return XDataSection; }
351
352   const MCSection *getEHFrameSection() {
353     if (!EHFrameSection)
354       InitEHFrameSection();
355     return EHFrameSection;
356   }
357
358   enum Environment { IsMachO, IsELF, IsCOFF };
359   Environment getObjectFileType() const {
360     return Env;
361   }
362
363 private:
364   Environment Env;
365   Reloc::Model RelocM;
366   CodeModel::Model CMModel;
367   MCContext *Ctx;
368
369   void InitMachOMCObjectFileInfo(Triple T);
370   void InitELFMCObjectFileInfo(Triple T);
371   void InitCOFFMCObjectFileInfo(Triple T);
372
373   /// InitEHFrameSection - Initialize EHFrameSection on demand.
374   ///
375   void InitEHFrameSection();
376 };
377
378 } // end namespace llvm
379
380 #endif