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 MCSymbol *getPersonalityPICSymbol(StringRef Name) const;
63 virtual void emitPersonalityValue(MCStreamer &Streamer,
64 const TargetMachine &TM,
65 const MCSymbol *Sym) const;
67 const MCSection *getDataRelSection() const { return DataRelSection; }
69 /// getSectionForConstant - Given a constant with the SectionKind, return a
70 /// section that it should be placed in.
71 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
74 virtual const MCSection *
75 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
76 Mangler *Mang, const TargetMachine &TM) const;
78 virtual const MCSection *
79 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
80 Mangler *Mang, const TargetMachine &TM) const;
82 /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference
83 /// to the specified global variable from exception handling information.
85 virtual const MCExpr *
86 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
87 MachineModuleInfo *MMI, unsigned Encoding,
88 MCStreamer &Streamer) const;
93 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
94 /// TLSDataSection - Section for thread local data.
96 const MCSection *TLSDataSection; // Defaults to ".tdata".
98 /// TLSBSSSection - Section for thread local uninitialized data.
100 const MCSection *TLSBSSSection; // Defaults to ".tbss".
102 /// TLSTLVSection - Section for thread local structure information.
103 /// Contains the source code name of the variable, visibility and a pointer
104 /// to the initial value (.tdata or .tbss).
105 const MCSection *TLSTLVSection; // Defaults to ".tlv".
107 /// TLSThreadInitSection - Section for thread local data initialization
109 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
111 const MCSection *CStringSection;
112 const MCSection *UStringSection;
113 const MCSection *TextCoalSection;
114 const MCSection *ConstTextCoalSection;
115 const MCSection *ConstDataSection;
116 const MCSection *DataCoalSection;
117 const MCSection *DataCommonSection;
118 const MCSection *DataBSSSection;
119 const MCSection *FourByteConstantSection;
120 const MCSection *EightByteConstantSection;
121 const MCSection *SixteenByteConstantSection;
123 const MCSection *LazySymbolPointerSection;
124 const MCSection *NonLazySymbolPointerSection;
126 TargetLoweringObjectFileMachO() {}
127 ~TargetLoweringObjectFileMachO() {}
129 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
131 virtual const MCSection *getEHFrameSection() const;
133 virtual const MCSection *
134 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
135 Mangler *Mang, const TargetMachine &TM) const;
137 virtual const MCSection *
138 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
139 Mangler *Mang, const TargetMachine &TM) const;
141 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
143 /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
144 /// decide not to emit the UsedDirective for some symbols in llvm.used.
145 /// FIXME: REMOVE this (rdar://7071300)
146 virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
149 /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
150 /// text symbols into.
151 const MCSection *getTextCoalSection() const {
152 return TextCoalSection;
155 /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
156 /// we put weak read-only symbols into.
157 const MCSection *getConstTextCoalSection() const {
158 return ConstTextCoalSection;
161 /// getLazySymbolPointerSection - Return the section corresponding to
162 /// the .lazy_symbol_pointer directive.
163 const MCSection *getLazySymbolPointerSection() const {
164 return LazySymbolPointerSection;
167 /// getNonLazySymbolPointerSection - Return the section corresponding to
168 /// the .non_lazy_symbol_pointer directive.
169 const MCSection *getNonLazySymbolPointerSection() const {
170 return NonLazySymbolPointerSection;
173 /// getExprForDwarfGlobalReference - The mach-o version of this method
174 /// defaults to returning a stub reference.
175 virtual const MCExpr *
176 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
177 MachineModuleInfo *MMI, unsigned Encoding,
178 MCStreamer &Streamer) const;
180 virtual unsigned getPersonalityEncoding() const;
181 virtual unsigned getLSDAEncoding() const;
182 virtual unsigned getFDEEncoding() const;
183 virtual unsigned getTTypeEncoding() const;
188 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
189 const MCSection *DrectveSection;
191 TargetLoweringObjectFileCOFF() {}
192 ~TargetLoweringObjectFileCOFF() {}
194 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
196 virtual const MCSection *getEHFrameSection() const;
198 virtual const MCSection *getDrectveSection() const { return DrectveSection; }
200 virtual const MCSection *
201 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
202 Mangler *Mang, const TargetMachine &TM) const;
204 virtual const MCSection *
205 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
206 Mangler *Mang, const TargetMachine &TM) const;
209 } // end namespace llvm