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 directive for Thread Local data.
89 const MCSection *TLSDataSection; // Defaults to ".tdata".
91 /// TLSBSSSection - Section directive for Thread Local uninitialized data.
93 const MCSection *TLSBSSSection; // Defaults to ".tbss".
95 /// TLSTLVSection - Section directive 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 const MCSection *CStringSection;
101 const MCSection *UStringSection;
102 const MCSection *TextCoalSection;
103 const MCSection *ConstTextCoalSection;
104 const MCSection *ConstDataCoalSection;
105 const MCSection *ConstDataSection;
106 const MCSection *DataCoalSection;
107 const MCSection *DataCommonSection;
108 const MCSection *DataBSSSection;
109 const MCSection *FourByteConstantSection;
110 const MCSection *EightByteConstantSection;
111 const MCSection *SixteenByteConstantSection;
113 const MCSection *LazySymbolPointerSection;
114 const MCSection *NonLazySymbolPointerSection;
116 TargetLoweringObjectFileMachO() {}
117 ~TargetLoweringObjectFileMachO() {}
119 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
121 virtual const MCSection *
122 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
123 Mangler *Mang, const TargetMachine &TM) const;
125 virtual const MCSection *
126 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
127 Mangler *Mang, const TargetMachine &TM) const;
129 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
131 /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
132 /// decide not to emit the UsedDirective for some symbols in llvm.used.
133 /// FIXME: REMOVE this (rdar://7071300)
134 virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
137 /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
138 /// text symbols into.
139 const MCSection *getTextCoalSection() const {
140 return TextCoalSection;
143 /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
144 /// we put weak read-only symbols into.
145 const MCSection *getConstTextCoalSection() const {
146 return ConstTextCoalSection;
149 /// getLazySymbolPointerSection - Return the section corresponding to
150 /// the .lazy_symbol_pointer directive.
151 const MCSection *getLazySymbolPointerSection() const {
152 return LazySymbolPointerSection;
155 /// getNonLazySymbolPointerSection - Return the section corresponding to
156 /// the .non_lazy_symbol_pointer directive.
157 const MCSection *getNonLazySymbolPointerSection() const {
158 return NonLazySymbolPointerSection;
161 /// getExprForDwarfGlobalReference - The mach-o version of this method
162 /// defaults to returning a stub reference.
163 virtual const MCExpr *
164 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
165 MachineModuleInfo *MMI, unsigned Encoding,
166 MCStreamer &Streamer) const;
168 virtual unsigned getPersonalityEncoding() const;
169 virtual unsigned getLSDAEncoding() const;
170 virtual unsigned getFDEEncoding() const;
171 virtual unsigned getTTypeEncoding() const;
176 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
177 const MCSection *DrectveSection;
179 TargetLoweringObjectFileCOFF() {}
180 ~TargetLoweringObjectFileCOFF() {}
182 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
184 virtual const MCSection *getDrectveSection() const { return DrectveSection; }
186 virtual const MCSection *
187 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
188 Mangler *Mang, const TargetMachine &TM) const;
190 virtual const MCSection *
191 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
192 Mangler *Mang, const TargetMachine &TM) const;
195 } // end namespace llvm