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