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 {
36
mutable void *UniquingMap;
38
/// TLSDataSection - Section directive for Thread Local data.
40
const MCSection *TLSDataSection; // Defaults to ".tdata".
42
/// TLSBSSSection - Section directive for Thread Local uninitialized data.
43
/// Null if this target doesn't support a BSS section.
45
const MCSection *TLSBSSSection; // Defaults to ".tbss".
47
const MCSection *DataRelSection;
48
const MCSection *DataRelLocalSection;
49
const MCSection *DataRelROSection;
50
const MCSection *DataRelROLocalSection;
52
const MCSection *MergeableConst4Section;
53
const MCSection *MergeableConst8Section;
54
const MCSection *MergeableConst16Section;
57
const MCSection *getELFSection(StringRef Section, unsigned Type,
58
unsigned Flags, SectionKind Kind,
59
bool IsExplicit = false) const;
61
TargetLoweringObjectFileELF() : UniquingMap(0) {}
62
~TargetLoweringObjectFileELF();
64
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
66
const MCSection *getDataRelSection() const { return DataRelSection; }
68
/// getSectionForConstant - Given a constant with the SectionKind, return a
69
/// section that it should be placed in.
70
virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
73
virtual const MCSection *
74
getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
75
Mangler *Mang, const TargetMachine &TM) const;
77
virtual const MCSection *
78
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
79
Mangler *Mang, const TargetMachine &TM) const;
81
/// getSymbolForDwarfGlobalReference - Return an MCExpr to use for a reference
82
/// to the specified global variable from exception handling information.
84
virtual const MCExpr *
85
getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
86
MachineModuleInfo *MMI, unsigned Encoding) const;
91
class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
92
mutable void *UniquingMap;
94
const MCSection *CStringSection;
95
const MCSection *UStringSection;
96
const MCSection *TextCoalSection;
97
const MCSection *ConstTextCoalSection;
98
const MCSection *ConstDataCoalSection;
99
const MCSection *ConstDataSection;
100
const MCSection *DataCoalSection;
101
const MCSection *DataCommonSection;
102
const MCSection *DataBSSSection;
103
const MCSection *FourByteConstantSection;
104
const MCSection *EightByteConstantSection;
105
const MCSection *SixteenByteConstantSection;
107
const MCSection *LazySymbolPointerSection;
108
const MCSection *NonLazySymbolPointerSection;
110
TargetLoweringObjectFileMachO() : UniquingMap(0) {}
111
~TargetLoweringObjectFileMachO();
113
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
115
virtual const MCSection *
116
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
117
Mangler *Mang, const TargetMachine &TM) const;
119
virtual const MCSection *
120
getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
121
Mangler *Mang, const TargetMachine &TM) const;
123
virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
125
/// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
126
/// decide not to emit the UsedDirective for some symbols in llvm.used.
127
/// FIXME: REMOVE this (rdar://7071300)
128
virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
131
/// getMachOSection - Return the MCSection for the specified mach-o section.
132
/// This requires the operands to be valid.
133
const MCSectionMachO *getMachOSection(StringRef Segment,
135
unsigned TypeAndAttributes,
136
SectionKind K) const {
137
return getMachOSection(Segment, Section, TypeAndAttributes, 0, K);
139
const MCSectionMachO *getMachOSection(StringRef Segment,
141
unsigned TypeAndAttributes,
143
SectionKind K) const;
145
/// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
146
/// text symbols into.
147
const MCSection *getTextCoalSection() const {
148
return TextCoalSection;
151
/// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
152
/// we put weak read-only symbols into.
153
const MCSection *getConstTextCoalSection() const {
154
return ConstTextCoalSection;
157
/// getLazySymbolPointerSection - Return the section corresponding to
158
/// the .lazy_symbol_pointer directive.
159
const MCSection *getLazySymbolPointerSection() const {
160
return LazySymbolPointerSection;
163
/// getNonLazySymbolPointerSection - Return the section corresponding to
164
/// the .non_lazy_symbol_pointer directive.
165
const MCSection *getNonLazySymbolPointerSection() const {
166
return NonLazySymbolPointerSection;
169
/// getSymbolForDwarfGlobalReference - The mach-o version of this method
170
/// defaults to returning a stub reference.
171
virtual const MCExpr *
172
getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
173
MachineModuleInfo *MMI, unsigned Encoding) 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
mutable void *UniquingMap;
186
TargetLoweringObjectFileCOFF() : UniquingMap(0) {}
187
~TargetLoweringObjectFileCOFF();
189
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
191
virtual const MCSection *
192
getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
193
Mangler *Mang, const TargetMachine &TM) const;
195
virtual const MCSection *
196
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
197
Mangler *Mang, const TargetMachine &TM) const;
199
/// getCOFFSection - Return the MCSection for the specified COFF section.
200
/// FIXME: Switch this to a semantic view eventually.
201
const MCSection *getCOFFSection(StringRef Name, bool isDirective,
202
SectionKind K) const;
205
} // end namespace llvm