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 const MCSection *getDataRelSection() const { return DataRelSection; }
62 /// getSectionForConstant - Given a constant with the SectionKind, return a
63 /// section that it should be placed in.
64 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
67 virtual const MCSection *
68 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
69 Mangler *Mang, const TargetMachine &TM) const;
71 virtual const MCSection *
72 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
73 Mangler *Mang, const TargetMachine &TM) const;
75 /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference
76 /// to the specified global variable from exception handling information.
78 virtual const MCExpr *
79 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
80 MachineModuleInfo *MMI, unsigned Encoding,
81 MCStreamer &Streamer) const;
86 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
87 /// TLSDataSection - Section for thread local data.
89 const MCSection *TLSDataSection; // Defaults to ".tdata".
91 /// TLSBSSSection - Section for thread local uninitialized data.
93 const MCSection *TLSBSSSection; // Defaults to ".tbss".
95 /// TLSTLVSection - Section for thread local structure infomation.
96 /// Contains the source code name of the variable, visibility and a pointer
97 /// to the initial value (.tdata or .tbss).
98 const MCSection *TLSTLVSection; // Defaults to ".tlv".
100 /// TLSThreadInitSection - Section for thread local data initialization
102 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
104 const MCSection *CStringSection;
105 const MCSection *UStringSection;
106 const MCSection *TextCoalSection;
107 const MCSection *ConstTextCoalSection;
108 const MCSection *ConstDataSection;
109 const MCSection *DataCoalSection;
110 const MCSection *DataCommonSection;
111 const MCSection *DataBSSSection;
112 const MCSection *FourByteConstantSection;
113 const MCSection *EightByteConstantSection;
114 const MCSection *SixteenByteConstantSection;
116 const MCSection *LazySymbolPointerSection;
117 const MCSection *NonLazySymbolPointerSection;
119 TargetLoweringObjectFileMachO() {}
120 ~TargetLoweringObjectFileMachO() {}
122 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
124 virtual const MCSection *
125 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
126 Mangler *Mang, const TargetMachine &TM) const;
128 virtual const MCSection *
129 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
130 Mangler *Mang, const TargetMachine &TM) const;
132 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
134 /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
135 /// decide not to emit the UsedDirective for some symbols in llvm.used.
136 /// FIXME: REMOVE this (rdar://7071300)
137 virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
140 /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
141 /// text symbols into.
142 const MCSection *getTextCoalSection() const {
143 return TextCoalSection;
146 /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
147 /// we put weak read-only symbols into.
148 const MCSection *getConstTextCoalSection() const {
149 return ConstTextCoalSection;
152 /// getLazySymbolPointerSection - Return the section corresponding to
153 /// the .lazy_symbol_pointer directive.
154 const MCSection *getLazySymbolPointerSection() const {
155 return LazySymbolPointerSection;
158 /// getNonLazySymbolPointerSection - Return the section corresponding to
159 /// the .non_lazy_symbol_pointer directive.
160 const MCSection *getNonLazySymbolPointerSection() const {
161 return NonLazySymbolPointerSection;
164 /// getExprForDwarfGlobalReference - The mach-o version of this method
165 /// defaults to returning a stub reference.
166 virtual const MCExpr *
167 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
168 MachineModuleInfo *MMI, unsigned Encoding,
169 MCStreamer &Streamer) const;
171 virtual unsigned getPersonalityEncoding() const;
172 virtual unsigned getLSDAEncoding() const;
173 virtual unsigned getFDEEncoding() const;
174 virtual unsigned getTTypeEncoding() const;
179 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
180 const MCSection *DrectveSection;
182 TargetLoweringObjectFileCOFF() {}
183 ~TargetLoweringObjectFileCOFF() {}
185 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
187 virtual const MCSection *getDrectveSection() const { return DrectveSection; }
189 virtual const MCSection *
190 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
191 Mangler *Mang, const TargetMachine &TM) const;
193 virtual const MCSection *
194 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
195 Mangler *Mang, const TargetMachine &TM) const;
198 } // end namespace llvm