[Orc] Add explicit move construction/assignment to RCMemoryManager.
[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_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   /// This section contains the static constructor pointer list.
69   MCSection *StaticCtorSection;
70
71   /// This section contains the static destructor pointer list.
72   MCSection *StaticDtorSection;
73
74   /// If exception handling is supported by the target, this is the section the
75   /// Language Specific Data Area information is emitted to.
76   MCSection *LSDASection;
77
78   /// If exception handling is supported by the target and the target can
79   /// support a compact representation of the CIE and FDE, this is the section
80   /// to emit them into.
81   MCSection *CompactUnwindSection;
82
83   // Dwarf sections for debug info.  If a target supports debug info, these must
84   // be set.
85   MCSection *DwarfAbbrevSection;
86   MCSection *DwarfInfoSection;
87   MCSection *DwarfLineSection;
88   MCSection *DwarfFrameSection;
89   MCSection *DwarfPubTypesSection;
90   const MCSection *DwarfDebugInlineSection;
91   MCSection *DwarfStrSection;
92   MCSection *DwarfLocSection;
93   MCSection *DwarfARangesSection;
94   MCSection *DwarfRangesSection;
95   MCSection *DwarfMacinfoSection;
96   // The pubnames section is no longer generated by default.  The generation
97   // can be enabled by a compiler flag.
98   MCSection *DwarfPubNamesSection;
99
100   /// DWARF5 Experimental Debug Info Sections
101   /// DwarfAccelNamesSection, DwarfAccelObjCSection,
102   /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
103   /// If we use the DWARF accelerated hash tables then we want to emit these
104   /// sections.
105   MCSection *DwarfAccelNamesSection;
106   MCSection *DwarfAccelObjCSection;
107   MCSection *DwarfAccelNamespaceSection;
108   MCSection *DwarfAccelTypesSection;
109
110   // These are used for the Fission separate debug information files.
111   MCSection *DwarfInfoDWOSection;
112   MCSection *DwarfTypesDWOSection;
113   MCSection *DwarfAbbrevDWOSection;
114   MCSection *DwarfStrDWOSection;
115   MCSection *DwarfLineDWOSection;
116   MCSection *DwarfLocDWOSection;
117   MCSection *DwarfStrOffDWOSection;
118   MCSection *DwarfAddrSection;
119
120   // These are for Fission DWP files.
121   MCSection *DwarfCUIndexSection;
122   MCSection *DwarfTUIndexSection;
123
124   /// Section for newer gnu pubnames.
125   MCSection *DwarfGnuPubNamesSection;
126   /// Section for newer gnu pubtypes.
127   MCSection *DwarfGnuPubTypesSection;
128
129   MCSection *COFFDebugSymbolsSection;
130
131   /// Extra TLS Variable Data section.
132   ///
133   /// If the target needs to put additional information for a TLS variable,
134   /// it'll go here.
135   MCSection *TLSExtraDataSection;
136
137   /// Section directive for Thread Local data. ELF, MachO and COFF.
138   MCSection *TLSDataSection; // Defaults to ".tdata".
139
140   /// Section directive for Thread Local uninitialized data.
141   ///
142   /// Null if this target doesn't support a BSS section. ELF and MachO only.
143   MCSection *TLSBSSSection; // Defaults to ".tbss".
144
145   /// StackMap section.
146   MCSection *StackMapSection;
147
148   /// FaultMap section.
149   MCSection *FaultMapSection;
150
151   /// EH frame section.
152   ///
153   /// It is initialized on demand so it can be overwritten (with uniquing).
154   MCSection *EHFrameSection;
155
156   // ELF specific sections.
157   MCSection *DataRelROSection;
158   MCSection *MergeableConst4Section;
159   MCSection *MergeableConst8Section;
160   MCSection *MergeableConst16Section;
161
162   // MachO specific sections.
163
164   /// Section for thread local structure information.
165   ///
166   /// Contains the source code name of the variable, visibility and a pointer to
167   /// the initial value (.tdata or .tbss).
168   MCSection *TLSTLVSection; // Defaults to ".tlv".
169
170   /// Section for thread local data initialization functions.
171   const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
172
173   MCSection *CStringSection;
174   MCSection *UStringSection;
175   MCSection *TextCoalSection;
176   MCSection *ConstTextCoalSection;
177   MCSection *ConstDataSection;
178   MCSection *DataCoalSection;
179   MCSection *DataCommonSection;
180   MCSection *DataBSSSection;
181   MCSection *FourByteConstantSection;
182   MCSection *EightByteConstantSection;
183   MCSection *SixteenByteConstantSection;
184   MCSection *LazySymbolPointerSection;
185   MCSection *NonLazySymbolPointerSection;
186
187   /// COFF specific sections.
188   MCSection *DrectveSection;
189   MCSection *PDataSection;
190   MCSection *XDataSection;
191   MCSection *SXDataSection;
192
193 public:
194   void InitMCObjectFileInfo(const Triple &TT, Reloc::Model RM,
195                             CodeModel::Model CM, MCContext &ctx);
196   LLVM_ATTRIBUTE_DEPRECATED(
197       void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM,
198                                 CodeModel::Model CM, MCContext &ctx),
199       "StringRef GNU Triple argument replaced by a llvm::Triple object");
200
201   bool getSupportsWeakOmittedEHFrame() const {
202     return SupportsWeakOmittedEHFrame;
203   }
204   bool getSupportsCompactUnwindWithoutEHFrame() const {
205     return SupportsCompactUnwindWithoutEHFrame;
206   }
207   bool getOmitDwarfIfHaveCompactUnwind() const {
208     return OmitDwarfIfHaveCompactUnwind;
209   }
210
211   bool getCommDirectiveSupportsAlignment() const {
212     return CommDirectiveSupportsAlignment;
213   }
214
215   unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
216   unsigned getLSDAEncoding() const { return LSDAEncoding; }
217   unsigned getFDEEncoding() const { return FDECFIEncoding; }
218   unsigned getTTypeEncoding() const { return TTypeEncoding; }
219
220   unsigned getCompactUnwindDwarfEHFrameOnly() const {
221     return CompactUnwindDwarfEHFrameOnly;
222   }
223
224   MCSection *getTextSection() const { return TextSection; }
225   MCSection *getDataSection() const { return DataSection; }
226   MCSection *getBSSSection() const { return BSSSection; }
227   MCSection *getReadOnlySection() const { return ReadOnlySection; }
228   MCSection *getLSDASection() const { return LSDASection; }
229   MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
230   MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
231   MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
232   MCSection *getDwarfLineSection() const { return DwarfLineSection; }
233   MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
234   MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
235   MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
236   MCSection *getDwarfGnuPubNamesSection() const {
237     return DwarfGnuPubNamesSection;
238   }
239   MCSection *getDwarfGnuPubTypesSection() const {
240     return DwarfGnuPubTypesSection;
241   }
242   const MCSection *getDwarfDebugInlineSection() const {
243     return DwarfDebugInlineSection;
244   }
245   MCSection *getDwarfStrSection() const { return DwarfStrSection; }
246   MCSection *getDwarfLocSection() const { return DwarfLocSection; }
247   MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
248   MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
249   MCSection *getDwarfMacinfoSection() const { return DwarfMacinfoSection; }
250
251   // DWARF5 Experimental Debug Info Sections
252   MCSection *getDwarfAccelNamesSection() const {
253     return DwarfAccelNamesSection;
254   }
255   MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
256   MCSection *getDwarfAccelNamespaceSection() const {
257     return DwarfAccelNamespaceSection;
258   }
259   MCSection *getDwarfAccelTypesSection() const {
260     return DwarfAccelTypesSection;
261   }
262   MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
263   MCSection *getDwarfTypesSection(uint64_t Hash) const;
264   MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
265   MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
266   MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
267   MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
268   MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
269   MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
270   MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
271   MCSection *getDwarfCUIndexSection() const { return DwarfCUIndexSection; }
272   MCSection *getDwarfTUIndexSection() const { return DwarfTUIndexSection; }
273
274   MCSection *getCOFFDebugSymbolsSection() const {
275     return COFFDebugSymbolsSection;
276   }
277
278   MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
279   const MCSection *getTLSDataSection() const { return TLSDataSection; }
280   MCSection *getTLSBSSSection() const { return TLSBSSSection; }
281
282   MCSection *getStackMapSection() const { return StackMapSection; }
283   MCSection *getFaultMapSection() const { return FaultMapSection; }
284
285   // ELF specific sections.
286   MCSection *getDataRelROSection() const { return DataRelROSection; }
287   const MCSection *getMergeableConst4Section() const {
288     return MergeableConst4Section;
289   }
290   const MCSection *getMergeableConst8Section() const {
291     return MergeableConst8Section;
292   }
293   const MCSection *getMergeableConst16Section() const {
294     return MergeableConst16Section;
295   }
296
297   // MachO specific sections.
298   const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
299   const MCSection *getTLSThreadInitSection() const {
300     return TLSThreadInitSection;
301   }
302   const MCSection *getCStringSection() const { return CStringSection; }
303   const MCSection *getUStringSection() const { return UStringSection; }
304   MCSection *getTextCoalSection() const { return TextCoalSection; }
305   const MCSection *getConstTextCoalSection() const {
306     return ConstTextCoalSection;
307   }
308   const MCSection *getConstDataSection() const { return ConstDataSection; }
309   const MCSection *getDataCoalSection() const { return DataCoalSection; }
310   const MCSection *getDataCommonSection() const { return DataCommonSection; }
311   MCSection *getDataBSSSection() const { return DataBSSSection; }
312   const MCSection *getFourByteConstantSection() const {
313     return FourByteConstantSection;
314   }
315   const MCSection *getEightByteConstantSection() const {
316     return EightByteConstantSection;
317   }
318   const MCSection *getSixteenByteConstantSection() const {
319     return SixteenByteConstantSection;
320   }
321   MCSection *getLazySymbolPointerSection() const {
322     return LazySymbolPointerSection;
323   }
324   MCSection *getNonLazySymbolPointerSection() const {
325     return NonLazySymbolPointerSection;
326   }
327
328   // COFF specific sections.
329   MCSection *getDrectveSection() const { return DrectveSection; }
330   MCSection *getPDataSection() const { return PDataSection; }
331   MCSection *getXDataSection() const { return XDataSection; }
332   MCSection *getSXDataSection() const { return SXDataSection; }
333
334   MCSection *getEHFrameSection() {
335     return EHFrameSection;
336   }
337
338   enum Environment { IsMachO, IsELF, IsCOFF };
339   Environment getObjectFileType() const { return Env; }
340
341   Reloc::Model getRelocM() const { return RelocM; }
342
343 private:
344   Environment Env;
345   Reloc::Model RelocM;
346   CodeModel::Model CMModel;
347   MCContext *Ctx;
348   Triple TT;
349
350   void initMachOMCObjectFileInfo(Triple T);
351   void initELFMCObjectFileInfo(Triple T);
352   void initCOFFMCObjectFileInfo(Triple T);
353
354 public:
355   const Triple &getTargetTriple() const { return TT; }
356 };
357
358 } // end namespace llvm
359
360 #endif