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 const MCSection *CStringSection;
88 const MCSection *UStringSection;
89 const MCSection *TextCoalSection;
90 const MCSection *ConstTextCoalSection;
91 const MCSection *ConstDataCoalSection;
92 const MCSection *ConstDataSection;
93 const MCSection *DataCoalSection;
94 const MCSection *DataCommonSection;
95 const MCSection *DataBSSSection;
96 const MCSection *FourByteConstantSection;
97 const MCSection *EightByteConstantSection;
98 const MCSection *SixteenByteConstantSection;
100 const MCSection *LazySymbolPointerSection;
101 const MCSection *NonLazySymbolPointerSection;
103 TargetLoweringObjectFileMachO() {}
104 ~TargetLoweringObjectFileMachO() {}
106 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
108 virtual const MCSection *
109 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
110 Mangler *Mang, const TargetMachine &TM) const;
112 virtual const MCSection *
113 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
114 Mangler *Mang, const TargetMachine &TM) const;
116 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
118 /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
119 /// decide not to emit the UsedDirective for some symbols in llvm.used.
120 /// FIXME: REMOVE this (rdar://7071300)
121 virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
124 /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
125 /// text symbols into.
126 const MCSection *getTextCoalSection() const {
127 return TextCoalSection;
130 /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
131 /// we put weak read-only symbols into.
132 const MCSection *getConstTextCoalSection() const {
133 return ConstTextCoalSection;
136 /// getLazySymbolPointerSection - Return the section corresponding to
137 /// the .lazy_symbol_pointer directive.
138 const MCSection *getLazySymbolPointerSection() const {
139 return LazySymbolPointerSection;
142 /// getNonLazySymbolPointerSection - Return the section corresponding to
143 /// the .non_lazy_symbol_pointer directive.
144 const MCSection *getNonLazySymbolPointerSection() const {
145 return NonLazySymbolPointerSection;
148 /// getExprForDwarfGlobalReference - The mach-o version of this method
149 /// defaults to returning a stub reference.
150 virtual const MCExpr *
151 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
152 MachineModuleInfo *MMI, unsigned Encoding,
153 MCStreamer &Streamer) const;
155 virtual unsigned getPersonalityEncoding() const;
156 virtual unsigned getLSDAEncoding() const;
157 virtual unsigned getFDEEncoding() const;
158 virtual unsigned getTTypeEncoding() const;
163 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
164 mutable void *UniquingMap;
166 TargetLoweringObjectFileCOFF() : UniquingMap(0) {}
167 ~TargetLoweringObjectFileCOFF();
169 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
171 virtual const MCSection *
172 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
173 Mangler *Mang, const TargetMachine &TM) const;
175 virtual const MCSection *
176 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
177 Mangler *Mang, const TargetMachine &TM) const;
179 /// getCOFFSection - Return the MCSection for the specified COFF section.
180 /// FIXME: Switch this to a semantic view eventually.
181 const MCSection *getCOFFSection(StringRef Name, bool isDirective,
182 SectionKind K) const;
185 } // end namespace llvm