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;
62 virtual void emitPersonalityValue(MCStreamer &Streamer,
63 const TargetMachine &TM,
64 const MCSymbol *Sym) const;
66 const MCSection *getDataRelSection() const { return DataRelSection; }
68 /// getSectionForConstant - Given a constant with the SectionKind, return a
69 /// section that it should be placed in.
70 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
73 virtual const MCSection *
74 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
75 Mangler *Mang, const TargetMachine &TM) const;
77 virtual const MCSection *
78 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
79 Mangler *Mang, const TargetMachine &TM) const;
81 /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference
82 /// to the specified global variable from exception handling information.
84 virtual const MCExpr *
85 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
86 MachineModuleInfo *MMI, unsigned Encoding,
87 MCStreamer &Streamer) const;
89 // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
91 getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding,
92 Mangler *Mang, MachineModuleInfo *MMI) const;
97 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
98 /// TLSDataSection - Section for thread local data.
100 const MCSection *TLSDataSection; // Defaults to ".tdata".
102 /// TLSBSSSection - Section for thread local uninitialized data.
104 const MCSection *TLSBSSSection; // Defaults to ".tbss".
106 /// TLSTLVSection - Section for thread local structure information.
107 /// Contains the source code name of the variable, visibility and a pointer
108 /// to the initial value (.tdata or .tbss).
109 const MCSection *TLSTLVSection; // Defaults to ".tlv".
111 /// TLSThreadInitSection - Section for thread local data initialization
113 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
115 const MCSection *CStringSection;
116 const MCSection *UStringSection;
117 const MCSection *TextCoalSection;
118 const MCSection *ConstTextCoalSection;
119 const MCSection *ConstDataSection;
120 const MCSection *DataCoalSection;
121 const MCSection *DataCommonSection;
122 const MCSection *DataBSSSection;
123 const MCSection *FourByteConstantSection;
124 const MCSection *EightByteConstantSection;
125 const MCSection *SixteenByteConstantSection;
127 const MCSection *LazySymbolPointerSection;
128 const MCSection *NonLazySymbolPointerSection;
130 TargetLoweringObjectFileMachO() {}
131 ~TargetLoweringObjectFileMachO() {}
133 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
135 virtual const MCSection *getEHFrameSection() const;
137 virtual const MCSection *
138 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
139 Mangler *Mang, const TargetMachine &TM) const;
141 virtual const MCSection *
142 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
143 Mangler *Mang, const TargetMachine &TM) const;
145 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
147 /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
148 /// decide not to emit the UsedDirective for some symbols in llvm.used.
149 /// FIXME: REMOVE this (rdar://7071300)
150 virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
153 /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
154 /// text symbols into.
155 const MCSection *getTextCoalSection() const {
156 return TextCoalSection;
159 /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
160 /// we put weak read-only symbols into.
161 const MCSection *getConstTextCoalSection() const {
162 return ConstTextCoalSection;
165 /// getLazySymbolPointerSection - Return the section corresponding to
166 /// the .lazy_symbol_pointer directive.
167 const MCSection *getLazySymbolPointerSection() const {
168 return LazySymbolPointerSection;
171 /// getNonLazySymbolPointerSection - Return the section corresponding to
172 /// the .non_lazy_symbol_pointer directive.
173 const MCSection *getNonLazySymbolPointerSection() const {
174 return NonLazySymbolPointerSection;
177 /// getExprForDwarfGlobalReference - The mach-o version of this method
178 /// defaults to returning a stub reference.
179 virtual const MCExpr *
180 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
181 MachineModuleInfo *MMI, unsigned Encoding,
182 MCStreamer &Streamer) const;
184 // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
186 getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding,
187 Mangler *Mang, MachineModuleInfo *MMI) const;
189 virtual unsigned getPersonalityEncoding() const;
190 virtual unsigned getLSDAEncoding() const;
191 virtual unsigned getFDEEncoding() const;
192 virtual unsigned getTTypeEncoding() const;
197 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
198 const MCSection *DrectveSection;
200 TargetLoweringObjectFileCOFF() {}
201 ~TargetLoweringObjectFileCOFF() {}
203 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
205 virtual const MCSection *getEHFrameSection() const;
207 virtual const MCSection *getDrectveSection() const { return DrectveSection; }
209 virtual const MCSection *
210 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
211 Mangler *Mang, const TargetMachine &TM) const;
213 virtual const MCSection *
214 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
215 Mangler *Mang, const TargetMachine &TM) const;
218 } // end namespace llvm