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(StringRef) const {
64 virtual const MCSection *getWin64EHTableSection(StringRef) const{return NULL;}
66 virtual void emitPersonalityValue(MCStreamer &Streamer,
67 const TargetMachine &TM,
68 const MCSymbol *Sym) const;
70 const MCSection *getDataRelSection() const { return DataRelSection; }
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;
77 virtual const MCSection *
78 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
79 Mangler *Mang, const TargetMachine &TM) const;
81 virtual const MCSection *
82 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
83 Mangler *Mang, const TargetMachine &TM) const;
85 /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference
86 /// to the specified global variable from exception handling information.
88 virtual const MCExpr *
89 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
90 MachineModuleInfo *MMI, unsigned Encoding,
91 MCStreamer &Streamer) const;
93 // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
95 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
96 MachineModuleInfo *MMI) const;
101 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
102 /// TLSDataSection - Section for thread local data.
104 const MCSection *TLSDataSection; // Defaults to ".tdata".
106 /// TLSBSSSection - Section for thread local uninitialized data.
108 const MCSection *TLSBSSSection; // Defaults to ".tbss".
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".
115 /// TLSThreadInitSection - Section for thread local data initialization
117 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
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;
131 const MCSection *LazySymbolPointerSection;
132 const MCSection *NonLazySymbolPointerSection;
134 TargetLoweringObjectFileMachO();
135 ~TargetLoweringObjectFileMachO() {}
137 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
139 virtual const MCSection *getEHFrameSection() const;
140 virtual const MCSection *getWin64EHFuncTableSection(StringRef) const {
143 virtual const MCSection *getWin64EHTableSection(StringRef) const{return NULL;}
145 virtual const MCSection *
146 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
147 Mangler *Mang, const TargetMachine &TM) const;
149 virtual const MCSection *
150 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
151 Mangler *Mang, const TargetMachine &TM) const;
153 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
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,
161 /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
162 /// text symbols into.
163 const MCSection *getTextCoalSection() const {
164 return TextCoalSection;
167 /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
168 /// we put weak read-only symbols into.
169 const MCSection *getConstTextCoalSection() const {
170 return ConstTextCoalSection;
173 /// getLazySymbolPointerSection - Return the section corresponding to
174 /// the .lazy_symbol_pointer directive.
175 const MCSection *getLazySymbolPointerSection() const {
176 return LazySymbolPointerSection;
179 /// getNonLazySymbolPointerSection - Return the section corresponding to
180 /// the .non_lazy_symbol_pointer directive.
181 const MCSection *getNonLazySymbolPointerSection() const {
182 return NonLazySymbolPointerSection;
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;
192 // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
194 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
195 MachineModuleInfo *MMI) const;
197 virtual unsigned getPersonalityEncoding() const;
198 virtual unsigned getLSDAEncoding() const;
199 virtual unsigned getFDEEncoding(bool CFI) const;
200 virtual unsigned getTTypeEncoding() const;
205 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
206 const MCSection *DrectveSection;
207 const MCSection *PDataSection;
208 const MCSection *XDataSection;
210 TargetLoweringObjectFileCOFF();
211 ~TargetLoweringObjectFileCOFF() {}
213 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
215 virtual const MCSection *getEHFrameSection() const;
216 virtual const MCSection *getWin64EHFuncTableSection(StringRef) const;
217 virtual const MCSection *getWin64EHTableSection(StringRef) const;
219 virtual const MCSection *getDrectveSection() const { return DrectveSection; }
221 virtual const MCSection *
222 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
223 Mangler *Mang, const TargetMachine &TM) const;
225 virtual const MCSection *
226 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
227 Mangler *Mang, const TargetMachine &TM) const;
230 } // end namespace llvm