1 //==-- llvm/CodeGen/TargetLoweringObjectFileImpl.h - Object Info -*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements classes used to handle lowerings specific to common
11 // object file formats.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
16 #define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/SectionKind.h"
20 #include "llvm/Target/TargetLoweringObjectFile.h"
23 class MachineModuleInfo;
35 class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
37 /// TLSDataSection - Section directive for Thread Local data.
39 const MCSection *TLSDataSection; // Defaults to ".tdata".
41 /// TLSBSSSection - Section directive for Thread Local uninitialized data.
42 /// Null if this target doesn't support a BSS section.
44 const MCSection *TLSBSSSection; // Defaults to ".tbss".
46 const MCSection *DataRelSection;
47 const MCSection *DataRelLocalSection;
48 const MCSection *DataRelROSection;
49 const MCSection *DataRelROLocalSection;
51 const MCSection *MergeableConst4Section;
52 const MCSection *MergeableConst8Section;
53 const MCSection *MergeableConst16Section;
55 TargetLoweringObjectFileELF() {}
56 ~TargetLoweringObjectFileELF() {}
58 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
60 virtual const MCSection *getEHFrameSection() const;
61 virtual const MCSection *getWin64EHFuncTableSection() const { return NULL; }
62 virtual const MCSection *getWin64EHTableSection() const { return NULL; }
64 virtual void emitPersonalityValue(MCStreamer &Streamer,
65 const TargetMachine &TM,
66 const MCSymbol *Sym) const;
68 const MCSection *getDataRelSection() const { return DataRelSection; }
70 /// getSectionForConstant - Given a constant with the SectionKind, return a
71 /// section that it should be placed in.
72 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
75 virtual const MCSection *
76 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
77 Mangler *Mang, const TargetMachine &TM) const;
79 virtual const MCSection *
80 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
81 Mangler *Mang, const TargetMachine &TM) const;
83 /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference
84 /// to the specified global variable from exception handling information.
86 virtual const MCExpr *
87 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
88 MachineModuleInfo *MMI, unsigned Encoding,
89 MCStreamer &Streamer) const;
91 // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
93 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
94 MachineModuleInfo *MMI) const;
99 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
100 /// TLSDataSection - Section for thread local data.
102 const MCSection *TLSDataSection; // Defaults to ".tdata".
104 /// TLSBSSSection - Section for thread local uninitialized data.
106 const MCSection *TLSBSSSection; // Defaults to ".tbss".
108 /// TLSTLVSection - Section for thread local structure information.
109 /// Contains the source code name of the variable, visibility and a pointer
110 /// to the initial value (.tdata or .tbss).
111 const MCSection *TLSTLVSection; // Defaults to ".tlv".
113 /// TLSThreadInitSection - Section for thread local data initialization
115 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
117 const MCSection *CStringSection;
118 const MCSection *UStringSection;
119 const MCSection *TextCoalSection;
120 const MCSection *ConstTextCoalSection;
121 const MCSection *ConstDataSection;
122 const MCSection *DataCoalSection;
123 const MCSection *DataCommonSection;
124 const MCSection *DataBSSSection;
125 const MCSection *FourByteConstantSection;
126 const MCSection *EightByteConstantSection;
127 const MCSection *SixteenByteConstantSection;
129 const MCSection *LazySymbolPointerSection;
130 const MCSection *NonLazySymbolPointerSection;
132 TargetLoweringObjectFileMachO() {}
133 ~TargetLoweringObjectFileMachO() {}
135 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
137 virtual const MCSection *getEHFrameSection() const;
138 virtual const MCSection *getWin64EHFuncTableSection() const { return NULL; }
139 virtual const MCSection *getWin64EHTableSection() const { return NULL; }
141 virtual const MCSection *
142 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
143 Mangler *Mang, const TargetMachine &TM) const;
145 virtual const MCSection *
146 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
147 Mangler *Mang, const TargetMachine &TM) const;
149 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
151 /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
152 /// decide not to emit the UsedDirective for some symbols in llvm.used.
153 /// FIXME: REMOVE this (rdar://7071300)
154 virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
157 /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
158 /// text symbols into.
159 const MCSection *getTextCoalSection() const {
160 return TextCoalSection;
163 /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
164 /// we put weak read-only symbols into.
165 const MCSection *getConstTextCoalSection() const {
166 return ConstTextCoalSection;
169 /// getLazySymbolPointerSection - Return the section corresponding to
170 /// the .lazy_symbol_pointer directive.
171 const MCSection *getLazySymbolPointerSection() const {
172 return LazySymbolPointerSection;
175 /// getNonLazySymbolPointerSection - Return the section corresponding to
176 /// the .non_lazy_symbol_pointer directive.
177 const MCSection *getNonLazySymbolPointerSection() const {
178 return NonLazySymbolPointerSection;
181 /// getExprForDwarfGlobalReference - The mach-o version of this method
182 /// defaults to returning a stub reference.
183 virtual const MCExpr *
184 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
185 MachineModuleInfo *MMI, unsigned Encoding,
186 MCStreamer &Streamer) const;
188 // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
190 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
191 MachineModuleInfo *MMI) const;
193 virtual unsigned getPersonalityEncoding() const;
194 virtual unsigned getLSDAEncoding() const;
195 virtual unsigned getFDEEncoding(bool CFI) const;
196 virtual unsigned getTTypeEncoding() const;
201 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
202 const MCSection *DrectveSection;
203 const MCSection *PDataSection;
204 const MCSection *XDataSection;
206 TargetLoweringObjectFileCOFF() {}
207 ~TargetLoweringObjectFileCOFF() {}
209 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
211 virtual const MCSection *getEHFrameSection() const;
212 virtual const MCSection *getWin64EHFuncTableSection() const {
215 virtual const MCSection *getWin64EHTableSection() const {return XDataSection;}
217 virtual const MCSection *getDrectveSection() const { return DrectveSection; }
219 virtual const MCSection *
220 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
221 Mangler *Mang, const TargetMachine &TM) const;
223 virtual const MCSection *
224 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
225 Mangler *Mang, const TargetMachine &TM) const;
228 } // end namespace llvm