Replace string GNU Triples with llvm::Triple in InitMCObjectFileInfo. NFC.
[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   /// Some encoding values for EH.
39   unsigned PersonalityEncoding;
40   unsigned LSDAEncoding;
41   unsigned FDECFIEncoding;
42   unsigned TTypeEncoding;
43
44   /// Section flags for eh_frame
45   unsigned EHSectionType;
46   unsigned EHSectionFlags;
47
48   /// Compact unwind encoding indicating that we should emit only an EH frame.
49   unsigned CompactUnwindDwarfEHFrameOnly;
50
51   /// Section directive for standard text.
52   MCSection *TextSection;
53
54   /// Section directive for standard data.
55   MCSection *DataSection;
56
57   /// Section that is default initialized to zero.
58   MCSection *BSSSection;
59
60   /// Section that is readonly and can contain arbitrary initialized data.
61   /// Targets are not required to have a readonly section. If they don't,
62   /// various bits of code will fall back to using the data section for
63   /// constants.
64   MCSection *ReadOnlySection;
65
66   /// This section contains the static constructor pointer list.
67   MCSection *StaticCtorSection;
68
69   /// This section contains the static destructor pointer list.
70   MCSection *StaticDtorSection;
71
72   /// If exception handling is supported by the target, this is the section the
73   /// Language Specific Data Area information is emitted to.
74   MCSection *LSDASection;
75
76   /// If exception handling is supported by the target and the target can
77   /// support a compact representation of the CIE and FDE, this is the section
78   /// to emit them into.
79   MCSection *CompactUnwindSection;
80
81   // Dwarf sections for debug info.  If a target supports debug info, these must
82   // be set.
83   MCSection *DwarfAbbrevSection;
84   MCSection *DwarfInfoSection;
85   MCSection *DwarfLineSection;
86   MCSection *DwarfFrameSection;
87   MCSection *DwarfPubTypesSection;
88   const MCSection *DwarfDebugInlineSection;
89   MCSection *DwarfStrSection;
90   MCSection *DwarfLocSection;
91   MCSection *DwarfARangesSection;
92   MCSection *DwarfRangesSection;
93   // The pubnames section is no longer generated by default.  The generation
94   // can be enabled by a compiler flag.
95   MCSection *DwarfPubNamesSection;
96
97   /// DWARF5 Experimental Debug Info Sections
98   /// DwarfAccelNamesSection, DwarfAccelObjCSection,
99   /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
100   /// If we use the DWARF accelerated hash tables then we want to emit these
101   /// sections.
102   MCSection *DwarfAccelNamesSection;
103   MCSection *DwarfAccelObjCSection;
104   MCSection *DwarfAccelNamespaceSection;
105   MCSection *DwarfAccelTypesSection;
106
107   // These are used for the Fission separate debug information files.
108   MCSection *DwarfInfoDWOSection;
109   MCSection *DwarfTypesDWOSection;
110   MCSection *DwarfAbbrevDWOSection;
111   MCSection *DwarfStrDWOSection;
112   MCSection *DwarfLineDWOSection;
113   MCSection *DwarfLocDWOSection;
114   MCSection *DwarfStrOffDWOSection;
115   MCSection *DwarfAddrSection;
116
117   /// Section for newer gnu pubnames.
118   MCSection *DwarfGnuPubNamesSection;
119   /// Section for newer gnu pubtypes.
120   MCSection *DwarfGnuPubTypesSection;
121
122   MCSection *COFFDebugSymbolsSection;
123
124   /// Extra TLS Variable Data section.
125   ///
126   /// If the target needs to put additional information for a TLS variable,
127   /// it'll go here.
128   MCSection *TLSExtraDataSection;
129
130   /// Section directive for Thread Local data. ELF, MachO and COFF.
131   MCSection *TLSDataSection; // Defaults to ".tdata".
132
133   /// Section directive for Thread Local uninitialized data.
134   ///
135   /// Null if this target doesn't support a BSS section. ELF and MachO only.
136   MCSection *TLSBSSSection; // Defaults to ".tbss".
137
138   /// StackMap section.
139   MCSection *StackMapSection;
140
141   /// EH frame section.
142   ///
143   /// It is initialized on demand so it can be overwritten (with uniquing).
144   MCSection *EHFrameSection;
145
146   // ELF specific sections.
147   MCSection *DataRelSection;
148   const MCSection *DataRelLocalSection;
149   MCSection *DataRelROSection;
150   MCSection *DataRelROLocalSection;
151   MCSection *MergeableConst4Section;
152   MCSection *MergeableConst8Section;
153   MCSection *MergeableConst16Section;
154
155   // MachO specific sections.
156
157   /// Section for thread local structure information.
158   ///
159   /// Contains the source code name of the variable, visibility and a pointer to
160   /// the initial value (.tdata or .tbss).
161   MCSection *TLSTLVSection; // Defaults to ".tlv".
162
163   /// Section for thread local data initialization functions.
164   const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
165
166   MCSection *CStringSection;
167   MCSection *UStringSection;
168   MCSection *TextCoalSection;
169   MCSection *ConstTextCoalSection;
170   MCSection *ConstDataSection;
171   MCSection *DataCoalSection;
172   MCSection *DataCommonSection;
173   MCSection *DataBSSSection;
174   MCSection *FourByteConstantSection;
175   MCSection *EightByteConstantSection;
176   MCSection *SixteenByteConstantSection;
177   MCSection *LazySymbolPointerSection;
178   MCSection *NonLazySymbolPointerSection;
179
180   /// COFF specific sections.
181   MCSection *DrectveSection;
182   MCSection *PDataSection;
183   MCSection *XDataSection;
184   MCSection *SXDataSection;
185
186 public:
187   void InitMCObjectFileInfo(const Triple &TT, Reloc::Model RM,
188                             CodeModel::Model CM, MCContext &ctx);
189   LLVM_ATTRIBUTE_DEPRECATED(
190       void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM,
191                                 CodeModel::Model CM, MCContext &ctx),
192       "StringRef GNU Triple argument replaced by a llvm::Triple object");
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
269   // ELF specific sections.
270   MCSection *getDataRelSection() const { return DataRelSection; }
271   const MCSection *getDataRelLocalSection() const {
272     return DataRelLocalSection;
273   }
274   MCSection *getDataRelROSection() const { return DataRelROSection; }
275   MCSection *getDataRelROLocalSection() const { return DataRelROLocalSection; }
276   const MCSection *getMergeableConst4Section() const {
277     return MergeableConst4Section;
278   }
279   const MCSection *getMergeableConst8Section() const {
280     return MergeableConst8Section;
281   }
282   const MCSection *getMergeableConst16Section() const {
283     return MergeableConst16Section;
284   }
285
286   // MachO specific sections.
287   const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
288   const MCSection *getTLSThreadInitSection() const {
289     return TLSThreadInitSection;
290   }
291   const MCSection *getCStringSection() const { return CStringSection; }
292   const MCSection *getUStringSection() const { return UStringSection; }
293   MCSection *getTextCoalSection() const { return TextCoalSection; }
294   const MCSection *getConstTextCoalSection() const {
295     return ConstTextCoalSection;
296   }
297   const MCSection *getConstDataSection() const { return ConstDataSection; }
298   const MCSection *getDataCoalSection() const { return DataCoalSection; }
299   const MCSection *getDataCommonSection() const { return DataCommonSection; }
300   MCSection *getDataBSSSection() const { return DataBSSSection; }
301   const MCSection *getFourByteConstantSection() const {
302     return FourByteConstantSection;
303   }
304   const MCSection *getEightByteConstantSection() const {
305     return EightByteConstantSection;
306   }
307   const MCSection *getSixteenByteConstantSection() const {
308     return SixteenByteConstantSection;
309   }
310   MCSection *getLazySymbolPointerSection() const {
311     return LazySymbolPointerSection;
312   }
313   MCSection *getNonLazySymbolPointerSection() const {
314     return NonLazySymbolPointerSection;
315   }
316
317   // COFF specific sections.
318   MCSection *getDrectveSection() const { return DrectveSection; }
319   MCSection *getPDataSection() const { return PDataSection; }
320   MCSection *getXDataSection() const { return XDataSection; }
321   MCSection *getSXDataSection() const { return SXDataSection; }
322
323   MCSection *getEHFrameSection() {
324     if (!EHFrameSection)
325       InitEHFrameSection();
326     return EHFrameSection;
327   }
328
329   enum Environment { IsMachO, IsELF, IsCOFF };
330   Environment getObjectFileType() const { return Env; }
331
332   Reloc::Model getRelocM() const { return RelocM; }
333
334 private:
335   Environment Env;
336   Reloc::Model RelocM;
337   CodeModel::Model CMModel;
338   MCContext *Ctx;
339   Triple TT;
340
341   void initMachOMCObjectFileInfo(Triple T);
342   void initELFMCObjectFileInfo(Triple T);
343   void initCOFFMCObjectFileInfo(Triple T);
344
345   /// Initialize EHFrameSection on demand.
346   void InitEHFrameSection();
347
348 public:
349   const Triple &getTargetTriple() const { return TT; }
350 };
351
352 } // end namespace llvm
353
354 #endif