Split the SDValue out of OutputArg so that SelectionDAG-independent
[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 for thread local data.
88   ///
89   const MCSection *TLSDataSection;        // Defaults to ".tdata".
90
91   /// TLSBSSSection - Section for thread local uninitialized data.
92   ///
93   const MCSection *TLSBSSSection;         // Defaults to ".tbss".
94   
95   /// TLSTLVSection - Section 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   /// TLSThreadInitSection - Section for thread local data initialization
101   /// functions.
102   const MCSection *TLSThreadInitSection;  // Defaults to ".thread_init_func".
103   
104   const MCSection *CStringSection;
105   const MCSection *UStringSection;
106   const MCSection *TextCoalSection;
107   const MCSection *ConstTextCoalSection;
108   const MCSection *ConstDataCoalSection;
109   const MCSection *ConstDataSection;
110   const MCSection *DataCoalSection;
111   const MCSection *DataCommonSection;
112   const MCSection *DataBSSSection;
113   const MCSection *FourByteConstantSection;
114   const MCSection *EightByteConstantSection;
115   const MCSection *SixteenByteConstantSection;
116
117   const MCSection *LazySymbolPointerSection;
118   const MCSection *NonLazySymbolPointerSection;
119 public:
120   TargetLoweringObjectFileMachO() {}
121   ~TargetLoweringObjectFileMachO() {}
122
123   virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
124
125   virtual const MCSection *
126   SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
127                          Mangler *Mang, const TargetMachine &TM) const;
128
129   virtual const MCSection *
130   getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
131                            Mangler *Mang, const TargetMachine &TM) const;
132
133   virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
134
135   /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
136   /// decide not to emit the UsedDirective for some symbols in llvm.used.
137   /// FIXME: REMOVE this (rdar://7071300)
138   virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
139                                           Mangler *) const;
140
141   /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
142   /// text symbols into.
143   const MCSection *getTextCoalSection() const {
144     return TextCoalSection;
145   }
146
147   /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
148   /// we put weak read-only symbols into.
149   const MCSection *getConstTextCoalSection() const {
150     return ConstTextCoalSection;
151   }
152
153   /// getLazySymbolPointerSection - Return the section corresponding to
154   /// the .lazy_symbol_pointer directive.
155   const MCSection *getLazySymbolPointerSection() const {
156     return LazySymbolPointerSection;
157   }
158
159   /// getNonLazySymbolPointerSection - Return the section corresponding to
160   /// the .non_lazy_symbol_pointer directive.
161   const MCSection *getNonLazySymbolPointerSection() const {
162     return NonLazySymbolPointerSection;
163   }
164
165   /// getExprForDwarfGlobalReference - The mach-o version of this method
166   /// defaults to returning a stub reference.
167   virtual const MCExpr *
168   getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
169                                  MachineModuleInfo *MMI, unsigned Encoding,
170                                  MCStreamer &Streamer) const;
171
172   virtual unsigned getPersonalityEncoding() const;
173   virtual unsigned getLSDAEncoding() const;
174   virtual unsigned getFDEEncoding() const;
175   virtual unsigned getTTypeEncoding() const;
176 };
177
178
179
180 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
181   const MCSection *DrectveSection;
182 public:
183   TargetLoweringObjectFileCOFF() {}
184   ~TargetLoweringObjectFileCOFF() {}
185
186   virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
187
188   virtual const MCSection *getDrectveSection() const { return DrectveSection; }
189
190   virtual const MCSection *
191   getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
192                            Mangler *Mang, const TargetMachine &TM) const;
193
194   virtual const MCSection *
195   SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
196                          Mangler *Mang, const TargetMachine &TM) const;
197 };
198
199 } // end namespace llvm
200
201 #endif