fba3e48c475e895cb83953cacb2d77dac86790e7
[oota-llvm.git] / include / llvm / CodeGen / TargetLoweringObjectFileImpl.h
1 //==-- llvm/CodeGen/TargetLoweringObjectFileImpl.h - Object 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 implements classes used to handle lowerings specific to common
11 // object file formats.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
16 #define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
17
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/SectionKind.h"
20 #include "llvm/Target/TargetLoweringObjectFile.h"
21
22 namespace llvm {
23   class MachineModuleInfo;
24   class Mangler;
25   class MCAsmInfo;
26   class MCExpr;
27   class MCSection;
28   class MCSectionMachO;
29   class MCSymbol;
30   class MCContext;
31   class GlobalValue;
32   class TargetMachine;
33
34
35 class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
36 protected:
37   /// TLSDataSection - Section directive for Thread Local data.
38   ///
39   const MCSection *TLSDataSection;        // Defaults to ".tdata".
40
41   /// TLSBSSSection - Section directive for Thread Local uninitialized data.
42   /// Null if this target doesn't support a BSS section.
43   ///
44   const MCSection *TLSBSSSection;         // Defaults to ".tbss".
45
46   const MCSection *DataRelSection;
47   const MCSection *DataRelLocalSection;
48   const MCSection *DataRelROSection;
49   const MCSection *DataRelROLocalSection;
50
51   const MCSection *MergeableConst4Section;
52   const MCSection *MergeableConst8Section;
53   const MCSection *MergeableConst16Section;
54 public:
55   TargetLoweringObjectFileELF() {}
56   ~TargetLoweringObjectFileELF() {}
57
58   virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
59
60   virtual const MCSection *getEHFrameSection() const;
61
62   const MCSection *getDataRelSection() const { return DataRelSection; }
63
64   /// getSectionForConstant - Given a constant with the SectionKind, return a
65   /// section that it should be placed in.
66   virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
67
68
69   virtual const MCSection *
70   getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
71                            Mangler *Mang, const TargetMachine &TM) const;
72
73   virtual const MCSection *
74   SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
75                          Mangler *Mang, const TargetMachine &TM) const;
76
77   /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference
78   /// to the specified global variable from exception handling information.
79   ///
80   virtual const MCExpr *
81   getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
82                                  MachineModuleInfo *MMI, unsigned Encoding,
83                                  MCStreamer &Streamer) const;
84 };
85
86
87
88 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
89   /// TLSDataSection - Section for thread local data.
90   ///
91   const MCSection *TLSDataSection;        // Defaults to ".tdata".
92
93   /// TLSBSSSection - Section for thread local uninitialized data.
94   ///
95   const MCSection *TLSBSSSection;         // Defaults to ".tbss".
96   
97   /// TLSTLVSection - Section for thread local structure infomation.
98   /// Contains the source code name of the variable, visibility and a pointer
99   /// to the initial value (.tdata or .tbss).
100   const MCSection *TLSTLVSection;         // Defaults to ".tlv".
101   
102   /// TLSThreadInitSection - Section for thread local data initialization
103   /// functions.
104   const MCSection *TLSThreadInitSection;  // Defaults to ".thread_init_func".
105   
106   const MCSection *CStringSection;
107   const MCSection *UStringSection;
108   const MCSection *TextCoalSection;
109   const MCSection *ConstTextCoalSection;
110   const MCSection *ConstDataSection;
111   const MCSection *DataCoalSection;
112   const MCSection *DataCommonSection;
113   const MCSection *DataBSSSection;
114   const MCSection *FourByteConstantSection;
115   const MCSection *EightByteConstantSection;
116   const MCSection *SixteenByteConstantSection;
117
118   const MCSection *LazySymbolPointerSection;
119   const MCSection *NonLazySymbolPointerSection;
120 public:
121   TargetLoweringObjectFileMachO() {}
122   ~TargetLoweringObjectFileMachO() {}
123
124   virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
125
126   virtual const MCSection *getEHFrameSection() const;
127
128   virtual const MCSection *
129   SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
130                          Mangler *Mang, const TargetMachine &TM) const;
131
132   virtual const MCSection *
133   getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
134                            Mangler *Mang, const TargetMachine &TM) const;
135
136   virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
137
138   /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
139   /// decide not to emit the UsedDirective for some symbols in llvm.used.
140   /// FIXME: REMOVE this (rdar://7071300)
141   virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
142                                           Mangler *) const;
143
144   /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
145   /// text symbols into.
146   const MCSection *getTextCoalSection() const {
147     return TextCoalSection;
148   }
149
150   /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
151   /// we put weak read-only symbols into.
152   const MCSection *getConstTextCoalSection() const {
153     return ConstTextCoalSection;
154   }
155
156   /// getLazySymbolPointerSection - Return the section corresponding to
157   /// the .lazy_symbol_pointer directive.
158   const MCSection *getLazySymbolPointerSection() const {
159     return LazySymbolPointerSection;
160   }
161
162   /// getNonLazySymbolPointerSection - Return the section corresponding to
163   /// the .non_lazy_symbol_pointer directive.
164   const MCSection *getNonLazySymbolPointerSection() const {
165     return NonLazySymbolPointerSection;
166   }
167
168   /// getExprForDwarfGlobalReference - The mach-o version of this method
169   /// defaults to returning a stub reference.
170   virtual const MCExpr *
171   getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
172                                  MachineModuleInfo *MMI, unsigned Encoding,
173                                  MCStreamer &Streamer) const;
174
175   virtual unsigned getPersonalityEncoding() const;
176   virtual unsigned getLSDAEncoding() const;
177   virtual unsigned getFDEEncoding() const;
178   virtual unsigned getTTypeEncoding() const;
179 };
180
181
182
183 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
184   const MCSection *DrectveSection;
185 public:
186   TargetLoweringObjectFileCOFF() {}
187   ~TargetLoweringObjectFileCOFF() {}
188
189   virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
190
191   virtual const MCSection *getEHFrameSection() const;
192
193   virtual const MCSection *getDrectveSection() const { return DrectveSection; }
194
195   virtual const MCSection *
196   getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
197                            Mangler *Mang, const TargetMachine &TM) const;
198
199   virtual const MCSection *
200   SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
201                          Mangler *Mang, const TargetMachine &TM) const;
202 };
203
204 } // end namespace llvm
205
206 #endif