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 const MCSection *getDataRelSection() const { return DataRelSection; }
64 /// getSectionForConstant - Given a constant with the SectionKind, return a
65 /// section that it should be placed in.
66 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
69 virtual const MCSection *
70 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
71 Mangler *Mang, const TargetMachine &TM) const;
73 virtual const MCSection *
74 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
75 Mangler *Mang, const TargetMachine &TM) const;
77 /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference
78 /// to the specified global variable from exception handling information.
80 virtual const MCExpr *
81 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
82 MachineModuleInfo *MMI, unsigned Encoding,
83 MCStreamer &Streamer) const;
88 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
89 /// TLSDataSection - Section for thread local data.
91 const MCSection *TLSDataSection; // Defaults to ".tdata".
93 /// TLSBSSSection - Section for thread local uninitialized data.
95 const MCSection *TLSBSSSection; // Defaults to ".tbss".
97 /// TLSTLVSection - Section for thread local structure infomation.
98 /// Contains the source code name of the variable, visibility and a pointer
99 /// to the initial value (.tdata or .tbss).
100 const MCSection *TLSTLVSection; // Defaults to ".tlv".
102 /// TLSThreadInitSection - Section for thread local data initialization
104 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
106 const MCSection *CStringSection;
107 const MCSection *UStringSection;
108 const MCSection *TextCoalSection;
109 const MCSection *ConstTextCoalSection;
110 const MCSection *ConstDataSection;
111 const MCSection *DataCoalSection;
112 const MCSection *DataCommonSection;
113 const MCSection *DataBSSSection;
114 const MCSection *FourByteConstantSection;
115 const MCSection *EightByteConstantSection;
116 const MCSection *SixteenByteConstantSection;
118 const MCSection *LazySymbolPointerSection;
119 const MCSection *NonLazySymbolPointerSection;
121 TargetLoweringObjectFileMachO() {}
122 ~TargetLoweringObjectFileMachO() {}
124 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
126 virtual const MCSection *getEHFrameSection() const;
128 virtual const MCSection *
129 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
130 Mangler *Mang, const TargetMachine &TM) const;
132 virtual const MCSection *
133 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
134 Mangler *Mang, const TargetMachine &TM) const;
136 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
138 /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
139 /// decide not to emit the UsedDirective for some symbols in llvm.used.
140 /// FIXME: REMOVE this (rdar://7071300)
141 virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
144 /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
145 /// text symbols into.
146 const MCSection *getTextCoalSection() const {
147 return TextCoalSection;
150 /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
151 /// we put weak read-only symbols into.
152 const MCSection *getConstTextCoalSection() const {
153 return ConstTextCoalSection;
156 /// getLazySymbolPointerSection - Return the section corresponding to
157 /// the .lazy_symbol_pointer directive.
158 const MCSection *getLazySymbolPointerSection() const {
159 return LazySymbolPointerSection;
162 /// getNonLazySymbolPointerSection - Return the section corresponding to
163 /// the .non_lazy_symbol_pointer directive.
164 const MCSection *getNonLazySymbolPointerSection() const {
165 return NonLazySymbolPointerSection;
168 /// getExprForDwarfGlobalReference - The mach-o version of this method
169 /// defaults to returning a stub reference.
170 virtual const MCExpr *
171 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
172 MachineModuleInfo *MMI, unsigned Encoding,
173 MCStreamer &Streamer) const;
175 virtual unsigned getPersonalityEncoding() const;
176 virtual unsigned getLSDAEncoding() const;
177 virtual unsigned getFDEEncoding() const;
178 virtual unsigned getTTypeEncoding() const;
183 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
184 const MCSection *DrectveSection;
186 TargetLoweringObjectFileCOFF() {}
187 ~TargetLoweringObjectFileCOFF() {}
189 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
191 virtual const MCSection *getEHFrameSection() const;
193 virtual const MCSection *getDrectveSection() const { return DrectveSection; }
195 virtual const MCSection *
196 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
197 Mangler *Mang, const TargetMachine &TM) const;
199 virtual const MCSection *
200 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
201 Mangler *Mang, const TargetMachine &TM) const;
204 } // end namespace llvm