1 //===-- llvm/Target/TargetLoweringObjectFile.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_TARGET_TARGETLOWERINGOBJECTFILE_H
16 #define LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/SectionKind.h"
22 class MachineModuleInfo;
34 class TargetLoweringObjectFile {
37 TargetLoweringObjectFile(const TargetLoweringObjectFile&); // DO NOT IMPLEMENT
38 void operator=(const TargetLoweringObjectFile&); // DO NOT IMPLEMENT
41 TargetLoweringObjectFile();
43 /// TextSection - Section directive for standard text.
45 const MCSection *TextSection;
47 /// DataSection - Section directive for standard data.
49 const MCSection *DataSection;
51 /// BSSSection - Section that is default initialized to zero.
52 const MCSection *BSSSection;
54 /// ReadOnlySection - Section that is readonly and can contain arbitrary
55 /// initialized data. Targets are not required to have a readonly section.
56 /// If they don't, various bits of code will fall back to using the data
57 /// section for constants.
58 const MCSection *ReadOnlySection;
60 /// StaticCtorSection - This section contains the static constructor pointer
62 const MCSection *StaticCtorSection;
64 /// StaticDtorSection - This section contains the static destructor pointer
66 const MCSection *StaticDtorSection;
68 /// LSDASection - If exception handling is supported by the target, this is
69 /// the section the Language Specific Data Area information is emitted to.
70 const MCSection *LSDASection;
72 // Dwarf sections for debug info. If a target supports debug info, these must
74 const MCSection *DwarfAbbrevSection;
75 const MCSection *DwarfInfoSection;
76 const MCSection *DwarfLineSection;
77 const MCSection *DwarfFrameSection;
78 const MCSection *DwarfPubNamesSection;
79 const MCSection *DwarfPubTypesSection;
80 const MCSection *DwarfDebugInlineSection;
81 const MCSection *DwarfStrSection;
82 const MCSection *DwarfLocSection;
83 const MCSection *DwarfARangesSection;
84 const MCSection *DwarfRangesSection;
85 const MCSection *DwarfMacroInfoSection;
87 // Extra TLS Variable Data section. If the target needs to put additional
88 // information for a TLS variable, it'll go here.
89 const MCSection *TLSExtraDataSection;
91 /// CommDirectiveSupportsAlignment - True if .comm supports alignment. This
92 /// is a hack for as long as we support 10.4 Tiger, whose assembler doesn't
93 /// support alignment on comm.
94 bool CommDirectiveSupportsAlignment;
96 /// SupportsWeakEmptyEHFrame - True if target object file supports a
97 /// weak_definition of constant 0 for an omitted EH frame.
98 bool SupportsWeakOmittedEHFrame;
100 /// IsFunctionEHSymbolGlobal - This flag is set to true if the ".eh" symbol
101 /// for a function should be marked .globl.
102 bool IsFunctionEHSymbolGlobal;
104 /// IsFunctionEHFrameSymbolPrivate - This flag is set to true if the
105 /// "EH_frame" symbol for EH information should be an assembler temporary (aka
106 /// private linkage, aka an L or .L label) or false if it should be a normal
107 /// non-.globl label. This defaults to true.
108 bool IsFunctionEHFrameSymbolPrivate;
111 MCContext &getContext() const { return *Ctx; }
113 virtual ~TargetLoweringObjectFile();
115 /// Initialize - this method must be called before any actual lowering is
116 /// done. This specifies the current context for codegen, and gives the
117 /// lowering implementations a chance to set up their default sections.
118 virtual void Initialize(MCContext &ctx, const TargetMachine &TM) {
122 bool isFunctionEHSymbolGlobal() const {
123 return IsFunctionEHSymbolGlobal;
125 bool isFunctionEHFrameSymbolPrivate() const {
126 return IsFunctionEHFrameSymbolPrivate;
128 bool getSupportsWeakOmittedEHFrame() const {
129 return SupportsWeakOmittedEHFrame;
132 bool getCommDirectiveSupportsAlignment() const {
133 return CommDirectiveSupportsAlignment;
136 const MCSection *getTextSection() const { return TextSection; }
137 const MCSection *getDataSection() const { return DataSection; }
138 const MCSection *getBSSSection() const { return BSSSection; }
139 const MCSection *getStaticCtorSection() const { return StaticCtorSection; }
140 const MCSection *getStaticDtorSection() const { return StaticDtorSection; }
141 const MCSection *getLSDASection() const { return LSDASection; }
142 virtual const MCSection *getEHFrameSection() const = 0;
143 virtual MCSymbol *getPersonalityPICSymbol(StringRef Name) const;
144 virtual void emitPersonalityValue(MCStreamer &Streamer,
145 const TargetMachine &TM,
146 const MCSymbol *Sym) const;
147 const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
148 const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
149 const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
150 const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
151 const MCSection *getDwarfPubNamesSection() const{return DwarfPubNamesSection;}
152 const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
153 const MCSection *getDwarfDebugInlineSection() const {
154 return DwarfDebugInlineSection;
156 const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
157 const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
158 const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
159 const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
160 const MCSection *getDwarfMacroInfoSection() const {
161 return DwarfMacroInfoSection;
163 const MCSection *getTLSExtraDataSection() const {
164 return TLSExtraDataSection;
167 /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
168 /// decide not to emit the UsedDirective for some symbols in llvm.used.
169 /// FIXME: REMOVE this (rdar://7071300)
170 virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
175 /// getSectionForConstant - Given a constant with the SectionKind, return a
176 /// section that it should be placed in.
177 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
179 /// getKindForGlobal - Classify the specified global variable into a set of
180 /// target independent categories embodied in SectionKind.
181 static SectionKind getKindForGlobal(const GlobalValue *GV,
182 const TargetMachine &TM);
184 /// SectionForGlobal - This method computes the appropriate section to emit
185 /// the specified global variable or function definition. This should not
186 /// be passed external (or available externally) globals.
187 const MCSection *SectionForGlobal(const GlobalValue *GV,
188 SectionKind Kind, Mangler *Mang,
189 const TargetMachine &TM) const;
191 /// SectionForGlobal - This method computes the appropriate section to emit
192 /// the specified global variable or function definition. This should not
193 /// be passed external (or available externally) globals.
194 const MCSection *SectionForGlobal(const GlobalValue *GV,
196 const TargetMachine &TM) const {
197 return SectionForGlobal(GV, getKindForGlobal(GV, TM), Mang, TM);
202 /// getExplicitSectionGlobal - Targets should implement this method to assign
203 /// a section to globals with an explicit section specfied. The
204 /// implementation of this method can assume that GV->hasSection() is true.
205 virtual const MCSection *
206 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
207 Mangler *Mang, const TargetMachine &TM) const = 0;
209 /// getSpecialCasedSectionGlobals - Allow the target to completely override
210 /// section assignment of a global.
211 virtual const MCSection *
212 getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang,
213 SectionKind Kind) const {
217 /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference
218 /// to the specified global variable from exception handling information.
220 virtual const MCExpr *
221 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
222 MachineModuleInfo *MMI, unsigned Encoding,
223 MCStreamer &Streamer) const;
227 getExprForDwarfReference(const MCSymbol *Sym, Mangler *Mang,
228 MachineModuleInfo *MMI, unsigned Encoding,
229 MCStreamer &Streamer) const;
231 virtual unsigned getPersonalityEncoding() const;
232 virtual unsigned getLSDAEncoding() const;
233 virtual unsigned getFDEEncoding() const;
234 virtual unsigned getTTypeEncoding() const;
237 virtual const MCSection *
238 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
239 Mangler *Mang, const TargetMachine &TM) const;
242 } // end namespace llvm