]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
Copy head to stable/9 as part of 9.0-RELEASE release cycle.
[FreeBSD/stable/9.git] / contrib / llvm / 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   virtual const MCSection *getWin64EHFuncTableSection(StringRef) const {
62     return NULL;
63   }
64   virtual const MCSection *getWin64EHTableSection(StringRef) const{return NULL;}
65
66   virtual void emitPersonalityValue(MCStreamer &Streamer,
67                                     const TargetMachine &TM,
68                                     const MCSymbol *Sym) const;
69
70   const MCSection *getDataRelSection() const { return DataRelSection; }
71
72   /// getSectionForConstant - Given a constant with the SectionKind, return a
73   /// section that it should be placed in.
74   virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
75
76
77   virtual const MCSection *
78   getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
79                            Mangler *Mang, const TargetMachine &TM) const;
80
81   virtual const MCSection *
82   SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
83                          Mangler *Mang, const TargetMachine &TM) const;
84
85   /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference
86   /// to the specified global variable from exception handling information.
87   ///
88   virtual const MCExpr *
89   getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
90                                  MachineModuleInfo *MMI, unsigned Encoding,
91                                  MCStreamer &Streamer) const;
92
93   // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
94   virtual MCSymbol *
95   getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
96                           MachineModuleInfo *MMI) const;
97 };
98
99
100
101 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
102   /// TLSDataSection - Section for thread local data.
103   ///
104   const MCSection *TLSDataSection;        // Defaults to ".tdata".
105
106   /// TLSBSSSection - Section for thread local uninitialized data.
107   ///
108   const MCSection *TLSBSSSection;         // Defaults to ".tbss".
109   
110   /// TLSTLVSection - Section for thread local structure information.
111   /// Contains the source code name of the variable, visibility and a pointer
112   /// to the initial value (.tdata or .tbss).
113   const MCSection *TLSTLVSection;         // Defaults to ".tlv".
114   
115   /// TLSThreadInitSection - Section for thread local data initialization
116   /// functions.
117   const MCSection *TLSThreadInitSection;  // Defaults to ".thread_init_func".
118   
119   const MCSection *CStringSection;
120   const MCSection *UStringSection;
121   const MCSection *TextCoalSection;
122   const MCSection *ConstTextCoalSection;
123   const MCSection *ConstDataSection;
124   const MCSection *DataCoalSection;
125   const MCSection *DataCommonSection;
126   const MCSection *DataBSSSection;
127   const MCSection *FourByteConstantSection;
128   const MCSection *EightByteConstantSection;
129   const MCSection *SixteenByteConstantSection;
130
131   const MCSection *LazySymbolPointerSection;
132   const MCSection *NonLazySymbolPointerSection;
133 public:
134   TargetLoweringObjectFileMachO();
135   ~TargetLoweringObjectFileMachO() {}
136
137   virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
138
139   virtual const MCSection *getEHFrameSection() const;
140   virtual const MCSection *getWin64EHFuncTableSection(StringRef) const {
141     return NULL;
142   }
143   virtual const MCSection *getWin64EHTableSection(StringRef) const{return NULL;}
144
145   virtual const MCSection *
146   SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
147                          Mangler *Mang, const TargetMachine &TM) const;
148
149   virtual const MCSection *
150   getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
151                            Mangler *Mang, const TargetMachine &TM) const;
152
153   virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
154
155   /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
156   /// decide not to emit the UsedDirective for some symbols in llvm.used.
157   /// FIXME: REMOVE this (rdar://7071300)
158   virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
159                                           Mangler *) const;
160
161   /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
162   /// text symbols into.
163   const MCSection *getTextCoalSection() const {
164     return TextCoalSection;
165   }
166
167   /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
168   /// we put weak read-only symbols into.
169   const MCSection *getConstTextCoalSection() const {
170     return ConstTextCoalSection;
171   }
172
173   /// getLazySymbolPointerSection - Return the section corresponding to
174   /// the .lazy_symbol_pointer directive.
175   const MCSection *getLazySymbolPointerSection() const {
176     return LazySymbolPointerSection;
177   }
178
179   /// getNonLazySymbolPointerSection - Return the section corresponding to
180   /// the .non_lazy_symbol_pointer directive.
181   const MCSection *getNonLazySymbolPointerSection() const {
182     return NonLazySymbolPointerSection;
183   }
184
185   /// getExprForDwarfGlobalReference - The mach-o version of this method
186   /// defaults to returning a stub reference.
187   virtual const MCExpr *
188   getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
189                                  MachineModuleInfo *MMI, unsigned Encoding,
190                                  MCStreamer &Streamer) const;
191
192   // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
193   virtual MCSymbol *
194   getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
195                           MachineModuleInfo *MMI) const;
196
197   virtual unsigned getPersonalityEncoding() const;
198   virtual unsigned getLSDAEncoding() const;
199   virtual unsigned getFDEEncoding(bool CFI) const;
200   virtual unsigned getTTypeEncoding() const;
201 };
202
203
204
205 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
206   const MCSection *DrectveSection;
207   const MCSection *PDataSection;
208   const MCSection *XDataSection;
209 public:
210   TargetLoweringObjectFileCOFF();
211   ~TargetLoweringObjectFileCOFF() {}
212
213   virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
214
215   virtual const MCSection *getEHFrameSection() const;
216   virtual const MCSection *getWin64EHFuncTableSection(StringRef) const;
217   virtual const MCSection *getWin64EHTableSection(StringRef) const;
218
219   virtual const MCSection *getDrectveSection() const { return DrectveSection; }
220
221   virtual const MCSection *
222   getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
223                            Mangler *Mang, const TargetMachine &TM) const;
224
225   virtual const MCSection *
226   SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
227                          Mangler *Mang, const TargetMachine &TM) const;
228 };
229
230 } // end namespace llvm
231
232 #endif