]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/llvm/include/llvm/MC/MCObjectFileInfo.h
MFC r244628:
[FreeBSD/stable/9.git] / contrib / llvm / 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 EHSectionType;
51   unsigned EHSectionFlags;
52
53   /// TextSection - Section directive for standard text.
54   ///
55   const MCSection *TextSection;
56
57   /// DataSection - Section directive for standard data.
58   ///
59   const MCSection *DataSection;
60
61   /// BSSSection - Section that is default initialized to zero.
62   const MCSection *BSSSection;
63
64   /// ReadOnlySection - Section that is readonly and can contain arbitrary
65   /// initialized data.  Targets are not required to have a readonly section.
66   /// If they don't, various bits of code will fall back to using the data
67   /// section for constants.
68   const MCSection *ReadOnlySection;
69
70   /// StaticCtorSection - This section contains the static constructor pointer
71   /// list.
72   const MCSection *StaticCtorSection;
73
74   /// StaticDtorSection - This section contains the static destructor pointer
75   /// list.
76   const MCSection *StaticDtorSection;
77
78   /// LSDASection - If exception handling is supported by the target, this is
79   /// the section the Language Specific Data Area information is emitted to.
80   const MCSection *LSDASection;
81
82   /// CompactUnwindSection - If exception handling is supported by the target
83   /// and the target can support a compact representation of the CIE and FDE,
84   /// this is the section to emit them into.
85   const MCSection *CompactUnwindSection;
86
87   /// DwarfAccelNamesSection, DwarfAccelObjCSection,
88   /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
89   /// If we use the DWARF accelerated hash tables then we want toe emit these
90   /// sections.
91   const MCSection *DwarfAccelNamesSection;
92   const MCSection *DwarfAccelObjCSection;
93   const MCSection *DwarfAccelNamespaceSection;
94   const MCSection *DwarfAccelTypesSection;
95
96   // Dwarf sections for debug info.  If a target supports debug info, these must
97   // be set.
98   const MCSection *DwarfAbbrevSection;
99   const MCSection *DwarfInfoSection;
100   const MCSection *DwarfLineSection;
101   const MCSection *DwarfFrameSection;
102   const MCSection *DwarfPubTypesSection;
103   const MCSection *DwarfDebugInlineSection;
104   const MCSection *DwarfStrSection;
105   const MCSection *DwarfLocSection;
106   const MCSection *DwarfARangesSection;
107   const MCSection *DwarfRangesSection;
108   const MCSection *DwarfMacroInfoSection;
109
110   // Extra TLS Variable Data section.  If the target needs to put additional
111   // information for a TLS variable, it'll go here.
112   const MCSection *TLSExtraDataSection;
113
114   /// TLSDataSection - Section directive for Thread Local data.
115   /// ELF, MachO and COFF.
116   const MCSection *TLSDataSection;        // Defaults to ".tdata".
117
118   /// TLSBSSSection - Section directive for Thread Local uninitialized data.
119   /// Null if this target doesn't support a BSS section.
120   /// ELF and MachO only.
121   const MCSection *TLSBSSSection;         // Defaults to ".tbss".
122
123
124   /// EHFrameSection - EH frame section. It is initialized on demand so it
125   /// can be overwritten (with uniquing).
126   const MCSection *EHFrameSection;
127
128   /// ELF specific sections.
129   ///
130   const MCSection *DataRelSection;
131   const MCSection *DataRelLocalSection;
132   const MCSection *DataRelROSection;
133   const MCSection *DataRelROLocalSection;
134   const MCSection *MergeableConst4Section;
135   const MCSection *MergeableConst8Section;
136   const MCSection *MergeableConst16Section;
137
138   /// MachO specific sections.
139   ///
140
141   /// TLSTLVSection - Section for thread local structure information.
142   /// Contains the source code name of the variable, visibility and a pointer
143   /// to the initial value (.tdata or .tbss).
144   const MCSection *TLSTLVSection;         // Defaults to ".tlv".
145
146   /// TLSThreadInitSection - Section for thread local data initialization
147   /// functions.
148   const MCSection *TLSThreadInitSection;  // Defaults to ".thread_init_func".
149
150   const MCSection *CStringSection;
151   const MCSection *UStringSection;
152   const MCSection *TextCoalSection;
153   const MCSection *ConstTextCoalSection;
154   const MCSection *ConstDataSection;
155   const MCSection *DataCoalSection;
156   const MCSection *DataCommonSection;
157   const MCSection *DataBSSSection;
158   const MCSection *FourByteConstantSection;
159   const MCSection *EightByteConstantSection;
160   const MCSection *SixteenByteConstantSection;
161   const MCSection *LazySymbolPointerSection;
162   const MCSection *NonLazySymbolPointerSection;
163
164   /// COFF specific sections.
165   ///
166   const MCSection *DrectveSection;
167   const MCSection *PDataSection;
168   const MCSection *XDataSection;
169
170 public:
171   void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
172                             MCContext &ctx);
173
174   bool isFunctionEHFrameSymbolPrivate() const {
175     return IsFunctionEHFrameSymbolPrivate;
176   }
177   bool getSupportsWeakOmittedEHFrame() const {
178     return SupportsWeakOmittedEHFrame;
179   }
180   bool getCommDirectiveSupportsAlignment() const {
181     return CommDirectiveSupportsAlignment;
182   }
183
184   unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
185   unsigned getLSDAEncoding() const { return LSDAEncoding; }
186   unsigned getFDEEncoding(bool CFI) const {
187     return CFI ? FDECFIEncoding : FDEEncoding;
188   }
189   unsigned getTTypeEncoding() const { return TTypeEncoding; }
190
191   const MCSection *getTextSection() const { return TextSection; }
192   const MCSection *getDataSection() const { return DataSection; }
193   const MCSection *getBSSSection() const { return BSSSection; }
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 *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
215   const MCSection *getDwarfDebugInlineSection() const {
216     return DwarfDebugInlineSection;
217   }
218   const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
219   const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
220   const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
221   const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
222   const MCSection *getDwarfMacroInfoSection() const {
223     return DwarfMacroInfoSection;
224   }
225   const MCSection *getTLSExtraDataSection() const {
226     return TLSExtraDataSection;
227   }
228   const MCSection *getTLSDataSection() const { return TLSDataSection; }
229   const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
230
231   /// ELF specific sections.
232   ///
233   const MCSection *getDataRelSection() const { return DataRelSection; }
234   const MCSection *getDataRelLocalSection() const {
235     return DataRelLocalSection;
236   }
237   const MCSection *getDataRelROSection() const { return DataRelROSection; }
238   const MCSection *getDataRelROLocalSection() const {
239     return DataRelROLocalSection;
240   }
241   const MCSection *getMergeableConst4Section() const {
242     return MergeableConst4Section;
243   }
244   const MCSection *getMergeableConst8Section() const {
245     return MergeableConst8Section;
246   }
247   const MCSection *getMergeableConst16Section() const {
248     return MergeableConst16Section;
249   }
250
251   /// MachO specific sections.
252   ///
253   const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
254   const MCSection *getTLSThreadInitSection() const {
255     return TLSThreadInitSection;
256   }
257   const MCSection *getCStringSection() const { return CStringSection; }
258   const MCSection *getUStringSection() const { return UStringSection; }
259   const MCSection *getTextCoalSection() const { return TextCoalSection; }
260   const MCSection *getConstTextCoalSection() const {
261     return ConstTextCoalSection;
262   }
263   const MCSection *getConstDataSection() const { return ConstDataSection; }
264   const MCSection *getDataCoalSection() const { return DataCoalSection; }
265   const MCSection *getDataCommonSection() const { return DataCommonSection; }
266   const MCSection *getDataBSSSection() const { return DataBSSSection; }
267   const MCSection *getFourByteConstantSection() const {
268     return FourByteConstantSection;
269   }
270   const MCSection *getEightByteConstantSection() const {
271     return EightByteConstantSection;
272   }
273   const MCSection *getSixteenByteConstantSection() const {
274     return SixteenByteConstantSection;
275   }
276   const MCSection *getLazySymbolPointerSection() const {
277     return LazySymbolPointerSection;
278   }
279   const MCSection *getNonLazySymbolPointerSection() const {
280     return NonLazySymbolPointerSection;
281   }
282
283   /// COFF specific sections.
284   ///
285   const MCSection *getDrectveSection() const { return DrectveSection; }
286   const MCSection *getPDataSection() const { return PDataSection; }
287   const MCSection *getXDataSection() const { return XDataSection; }
288
289   const MCSection *getEHFrameSection() {
290     if (!EHFrameSection)
291       InitEHFrameSection();
292     return EHFrameSection;
293   }
294
295 private:
296   enum Environment { IsMachO, IsELF, IsCOFF };
297   Environment Env;
298   Reloc::Model RelocM;
299   CodeModel::Model CMModel;
300   MCContext *Ctx;
301
302   void InitMachOMCObjectFileInfo(Triple T);
303   void InitELFMCObjectFileInfo(Triple T);
304   void InitCOFFMCObjectFileInfo(Triple T);
305
306   /// InitEHFrameSection - Initialize EHFrameSection on demand.
307   ///
308   void InitEHFrameSection();
309 };
310
311 } // end namespace llvm
312
313 #endif