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