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