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