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;
56 const MCSection *getELFSection(StringRef Section, unsigned Type,
57 unsigned Flags, SectionKind Kind,
58 bool IsExplicit = false) const;
60 TargetLoweringObjectFileELF() {}
61 ~TargetLoweringObjectFileELF() {}
63 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
65 const MCSection *getDataRelSection() const { return DataRelSection; }
67 /// getSectionForConstant - Given a constant with the SectionKind, return a
68 /// section that it should be placed in.
69 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
72 virtual const MCSection *
73 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
74 Mangler *Mang, const TargetMachine &TM) const;
76 virtual const MCSection *
77 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
78 Mangler *Mang, const TargetMachine &TM) const;
80 /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference
81 /// to the specified global variable from exception handling information.
83 virtual const MCExpr *
84 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
85 MachineModuleInfo *MMI, unsigned Encoding,
86 MCStreamer &Streamer) const;
91 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
92 const MCSection *CStringSection;
93 const MCSection *UStringSection;
94 const MCSection *TextCoalSection;
95 const MCSection *ConstTextCoalSection;
96 const MCSection *ConstDataCoalSection;
97 const MCSection *ConstDataSection;
98 const MCSection *DataCoalSection;
99 const MCSection *DataCommonSection;
100 const MCSection *DataBSSSection;
101 const MCSection *FourByteConstantSection;
102 const MCSection *EightByteConstantSection;
103 const MCSection *SixteenByteConstantSection;
105 const MCSection *LazySymbolPointerSection;
106 const MCSection *NonLazySymbolPointerSection;
108 TargetLoweringObjectFileMachO() {}
109 ~TargetLoweringObjectFileMachO() {}
111 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
113 virtual const MCSection *
114 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
115 Mangler *Mang, const TargetMachine &TM) const;
117 virtual const MCSection *
118 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
119 Mangler *Mang, const TargetMachine &TM) const;
121 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
123 /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
124 /// decide not to emit the UsedDirective for some symbols in llvm.used.
125 /// FIXME: REMOVE this (rdar://7071300)
126 virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
129 /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
130 /// text symbols into.
131 const MCSection *getTextCoalSection() const {
132 return TextCoalSection;
135 /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
136 /// we put weak read-only symbols into.
137 const MCSection *getConstTextCoalSection() const {
138 return ConstTextCoalSection;
141 /// getLazySymbolPointerSection - Return the section corresponding to
142 /// the .lazy_symbol_pointer directive.
143 const MCSection *getLazySymbolPointerSection() const {
144 return LazySymbolPointerSection;
147 /// getNonLazySymbolPointerSection - Return the section corresponding to
148 /// the .non_lazy_symbol_pointer directive.
149 const MCSection *getNonLazySymbolPointerSection() const {
150 return NonLazySymbolPointerSection;
153 /// getExprForDwarfGlobalReference - The mach-o version of this method
154 /// defaults to returning a stub reference.
155 virtual const MCExpr *
156 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
157 MachineModuleInfo *MMI, unsigned Encoding,
158 MCStreamer &Streamer) const;
160 virtual unsigned getPersonalityEncoding() const;
161 virtual unsigned getLSDAEncoding() const;
162 virtual unsigned getFDEEncoding() const;
163 virtual unsigned getTTypeEncoding() const;
168 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
169 mutable void *UniquingMap;
171 TargetLoweringObjectFileCOFF() : UniquingMap(0) {}
172 ~TargetLoweringObjectFileCOFF();
174 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
176 virtual const MCSection *
177 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
178 Mangler *Mang, const TargetMachine &TM) const;
180 virtual const MCSection *
181 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
182 Mangler *Mang, const TargetMachine &TM) const;
184 /// getCOFFSection - Return the MCSection for the specified COFF section.
185 /// FIXME: Switch this to a semantic view eventually.
186 const MCSection *getCOFFSection(StringRef Name, bool isDirective,
187 SectionKind K) const;
190 } // end namespace llvm