Prune some includes and forward declarations.
[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   // Section flags for eh_frame
50   unsigned EHSectionFlags;
51
52   /// TextSection - Section directive for standard text.
53   ///
54   const MCSection *TextSection;
55   
56   /// DataSection - Section directive for standard data.
57   ///
58   const MCSection *DataSection;
59   
60   /// BSSSection - Section that is default initialized to zero.
61   const MCSection *BSSSection;
62   
63   /// ReadOnlySection - Section that is readonly and can contain arbitrary
64   /// initialized data.  Targets are not required to have a readonly section.
65   /// If they don't, various bits of code will fall back to using the data
66   /// section for constants.
67   const MCSection *ReadOnlySection;
68   
69   /// StaticCtorSection - This section contains the static constructor pointer
70   /// list.
71   const MCSection *StaticCtorSection;
72
73   /// StaticDtorSection - This section contains the static destructor pointer
74   /// list.
75   const MCSection *StaticDtorSection;
76   
77   /// LSDASection - If exception handling is supported by the target, this is
78   /// the section the Language Specific Data Area information is emitted to.
79   const MCSection *LSDASection;
80
81   /// CompactUnwindSection - If exception handling is supported by the target
82   /// and the target can support a compact representation of the CIE and FDE,
83   /// this is the section to emit them into.
84   const MCSection *CompactUnwindSection;
85
86   /// DwarfAccelNamesSection, DwarfAccelObjCSection
87   /// If we use the DWARF accelerated hash tables then we want toe emit these
88   /// sections.
89   const MCSection *DwarfAccelNamesSection;
90   const MCSection *DwarfAccelObjCSection;
91   const MCSection *DwarfAccelNamespaceSection;
92   const MCSection *DwarfAccelTypesSection;
93
94   // Dwarf sections for debug info.  If a target supports debug info, these must
95   // be set.
96   const MCSection *DwarfAbbrevSection;
97   const MCSection *DwarfInfoSection;
98   const MCSection *DwarfLineSection;
99   const MCSection *DwarfFrameSection;
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, MachO and COFF.
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 *getLSDASection() const { return LSDASection; }
193   const MCSection *getCompactUnwindSection() const{
194     return CompactUnwindSection;
195   }
196   const MCSection *getDwarfAccelNamesSection() const {
197     return DwarfAccelNamesSection;
198   }
199   const MCSection *getDwarfAccelObjCSection() const {
200     return DwarfAccelObjCSection;
201   }
202   const MCSection *getDwarfAccelNamespaceSection() const {
203     return DwarfAccelNamespaceSection;
204   }
205   const MCSection *getDwarfAccelTypesSection() const {
206     return DwarfAccelTypesSection;
207   }
208   const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
209   const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
210   const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
211   const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
212   const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
213   const MCSection *getDwarfDebugInlineSection() const {
214     return DwarfDebugInlineSection;
215   }
216   const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
217   const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
218   const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
219   const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
220   const MCSection *getDwarfMacroInfoSection() const {
221     return DwarfMacroInfoSection;
222   }
223   const MCSection *getTLSExtraDataSection() const {
224     return TLSExtraDataSection;
225   }
226   const MCSection *getTLSDataSection() const { return TLSDataSection; }
227   const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
228
229   /// ELF specific sections.
230   ///
231   const MCSection *getDataRelSection() const { return DataRelSection; }
232   const MCSection *getDataRelLocalSection() const {
233     return DataRelLocalSection;
234   }
235   const MCSection *getDataRelROSection() const { return DataRelROSection; }
236   const MCSection *getDataRelROLocalSection() const {
237     return DataRelROLocalSection;
238   }
239   const MCSection *getMergeableConst4Section() const {
240     return MergeableConst4Section;
241   }
242   const MCSection *getMergeableConst8Section() const {
243     return MergeableConst8Section;
244   }
245   const MCSection *getMergeableConst16Section() const {
246     return MergeableConst16Section;
247   }
248
249   /// MachO specific sections.
250   ///
251   const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
252   const MCSection *getTLSThreadInitSection() const {
253     return TLSThreadInitSection;
254   }
255   const MCSection *getCStringSection() const { return CStringSection; }
256   const MCSection *getUStringSection() const { return UStringSection; }
257   const MCSection *getTextCoalSection() const { return TextCoalSection; }
258   const MCSection *getConstTextCoalSection() const {
259     return ConstTextCoalSection;
260   }
261   const MCSection *getConstDataSection() const { return ConstDataSection; }
262   const MCSection *getDataCoalSection() const { return DataCoalSection; }
263   const MCSection *getDataCommonSection() const { return DataCommonSection; }
264   const MCSection *getDataBSSSection() const { return DataBSSSection; }
265   const MCSection *getFourByteConstantSection() const {
266     return FourByteConstantSection;
267   }
268   const MCSection *getEightByteConstantSection() const {
269     return EightByteConstantSection;
270   }
271   const MCSection *getSixteenByteConstantSection() const {
272     return SixteenByteConstantSection;
273   }
274   const MCSection *getLazySymbolPointerSection() const {
275     return LazySymbolPointerSection;
276   }
277   const MCSection *getNonLazySymbolPointerSection() const {
278     return NonLazySymbolPointerSection;
279   }
280
281   /// COFF specific sections.
282   ///
283   const MCSection *getDrectveSection() const { return DrectveSection; }
284   const MCSection *getPDataSection() const { return PDataSection; }
285   const MCSection *getXDataSection() const { return XDataSection; }
286
287   const MCSection *getEHFrameSection() {
288     if (!EHFrameSection)
289       InitEHFrameSection();
290     return EHFrameSection;
291   }
292
293 private:
294   enum Environment { IsMachO, IsELF, IsCOFF };
295   Environment Env;
296   Reloc::Model RelocM;
297   CodeModel::Model CMModel;
298   MCContext *Ctx;
299
300   void InitMachOMCObjectFileInfo(Triple T);
301   void InitELFMCObjectFileInfo(Triple T);
302   void InitCOFFMCObjectFileInfo(Triple T);
303
304   /// InitEHFrameSection - Initialize EHFrameSection on demand.
305   ///
306   void InitEHFrameSection();
307 };
308
309 } // end namespace llvm
310
311 #endif