Add a parameter to the Win64 EH section getters to get a section with a
[oota-llvm.git] / include / llvm / Target / TargetLoweringObjectFile.h
1 //===-- llvm/Target/TargetLoweringObjectFile.h - Object Info ----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements classes used to handle lowerings specific to common
11 // object file formats.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H
16 #define LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H
17
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/SectionKind.h"
20
21 namespace llvm {
22   class MachineModuleInfo;
23   class Mangler;
24   class MCAsmInfo;
25   class MCContext;
26   class MCExpr;
27   class MCSection;
28   class MCSectionMachO;
29   class MCSymbol;
30   class MCStreamer;
31   class GlobalValue;
32   class TargetMachine;
33   
34 class TargetLoweringObjectFile {
35   MCContext *Ctx;
36   
37   TargetLoweringObjectFile(const TargetLoweringObjectFile&); // DO NOT IMPLEMENT
38   void operator=(const TargetLoweringObjectFile&);           // DO NOT IMPLEMENT
39 protected:
40   
41   TargetLoweringObjectFile();
42   
43   /// TextSection - Section directive for standard text.
44   ///
45   const MCSection *TextSection;
46   
47   /// DataSection - Section directive for standard data.
48   ///
49   const MCSection *DataSection;
50   
51   /// BSSSection - Section that is default initialized to zero.
52   const MCSection *BSSSection;
53   
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;
59   
60   /// StaticCtorSection - This section contains the static constructor pointer
61   /// list.
62   const MCSection *StaticCtorSection;
63
64   /// StaticDtorSection - This section contains the static destructor pointer
65   /// list.
66   const MCSection *StaticDtorSection;
67   
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;
71   
72   // Dwarf sections for debug info.  If a target supports debug info, these must
73   // be set.
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;
86   
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;
90   
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;
95   
96   /// SupportsWeakEmptyEHFrame - True if target object file supports a
97   /// weak_definition of constant 0 for an omitted EH frame.
98   bool SupportsWeakOmittedEHFrame;
99   
100   /// IsFunctionEHFrameSymbolPrivate - This flag is set to true if the
101   /// "EH_frame" symbol for EH information should be an assembler temporary (aka
102   /// private linkage, aka an L or .L label) or false if it should be a normal
103   /// non-.globl label.  This defaults to true.
104   bool IsFunctionEHFrameSymbolPrivate;
105 public:
106   
107   MCContext &getContext() const { return *Ctx; }
108   
109   virtual ~TargetLoweringObjectFile();
110   
111   /// Initialize - this method must be called before any actual lowering is
112   /// done.  This specifies the current context for codegen, and gives the
113   /// lowering implementations a chance to set up their default sections.
114   virtual void Initialize(MCContext &ctx, const TargetMachine &TM) {
115     Ctx = &ctx;
116   }
117   
118   bool isFunctionEHFrameSymbolPrivate() const {
119     return IsFunctionEHFrameSymbolPrivate;
120   }
121   bool getSupportsWeakOmittedEHFrame() const {
122     return SupportsWeakOmittedEHFrame;
123   }
124   
125   bool getCommDirectiveSupportsAlignment() const {
126     return CommDirectiveSupportsAlignment;
127   }
128
129   const MCSection *getTextSection() const { return TextSection; }
130   const MCSection *getDataSection() const { return DataSection; }
131   const MCSection *getBSSSection() const { return BSSSection; }
132   const MCSection *getStaticCtorSection() const { return StaticCtorSection; }
133   const MCSection *getStaticDtorSection() const { return StaticDtorSection; }
134   const MCSection *getLSDASection() const { return LSDASection; }
135   virtual const MCSection *getEHFrameSection() const = 0;
136   virtual void emitPersonalityValue(MCStreamer &Streamer,
137                                     const TargetMachine &TM,
138                                     const MCSymbol *Sym) const;
139   const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
140   const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
141   const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
142   const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
143   const MCSection *getDwarfPubNamesSection() const{return DwarfPubNamesSection;}
144   const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
145   const MCSection *getDwarfDebugInlineSection() const {
146     return DwarfDebugInlineSection;
147   }
148   const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
149   const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
150   const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
151   const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
152   const MCSection *getDwarfMacroInfoSection() const {
153     return DwarfMacroInfoSection;
154   }
155   const MCSection *getTLSExtraDataSection() const {
156     return TLSExtraDataSection;
157   }
158   virtual const MCSection *getWin64EHFuncTableSection(StringRef suffix)const=0;
159   virtual const MCSection *getWin64EHTableSection(StringRef suffix) const = 0;
160   
161   /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
162   /// decide not to emit the UsedDirective for some symbols in llvm.used.
163   /// FIXME: REMOVE this (rdar://7071300)
164   virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
165                                           Mangler *) const {
166     return GV != 0;
167   }
168   
169   /// getSectionForConstant - Given a constant with the SectionKind, return a
170   /// section that it should be placed in.
171   virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
172   
173   /// getKindForGlobal - Classify the specified global variable into a set of
174   /// target independent categories embodied in SectionKind.
175   static SectionKind getKindForGlobal(const GlobalValue *GV,
176                                       const TargetMachine &TM);
177   
178   /// SectionForGlobal - This method computes the appropriate section to emit
179   /// the specified global variable or function definition.  This should not
180   /// be passed external (or available externally) globals.
181   const MCSection *SectionForGlobal(const GlobalValue *GV,
182                                     SectionKind Kind, Mangler *Mang,
183                                     const TargetMachine &TM) const;
184   
185   /// SectionForGlobal - This method computes the appropriate section to emit
186   /// the specified global variable or function definition.  This should not
187   /// be passed external (or available externally) globals.
188   const MCSection *SectionForGlobal(const GlobalValue *GV,
189                                     Mangler *Mang,
190                                     const TargetMachine &TM) const {
191     return SectionForGlobal(GV, getKindForGlobal(GV, TM), Mang, TM);
192   }
193   
194   
195   
196   /// getExplicitSectionGlobal - Targets should implement this method to assign
197   /// a section to globals with an explicit section specfied.  The
198   /// implementation of this method can assume that GV->hasSection() is true.
199   virtual const MCSection *
200   getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, 
201                            Mangler *Mang, const TargetMachine &TM) const = 0;
202   
203   /// getSpecialCasedSectionGlobals - Allow the target to completely override
204   /// section assignment of a global.
205   virtual const MCSection *
206   getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang,
207                                 SectionKind Kind) const {
208     return 0;
209   }
210   
211   /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference
212   /// to the specified global variable from exception handling information.
213   ///
214   virtual const MCExpr *
215   getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
216                                  MachineModuleInfo *MMI, unsigned Encoding,
217                                  MCStreamer &Streamer) const;
218
219   // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
220   virtual MCSymbol *
221   getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
222                           MachineModuleInfo *MMI) const;
223
224   /// 
225   const MCExpr *
226   getExprForDwarfReference(const MCSymbol *Sym, unsigned Encoding,
227                            MCStreamer &Streamer) const;
228   
229   virtual unsigned getPersonalityEncoding() const;
230   virtual unsigned getLSDAEncoding() const;
231   virtual unsigned getFDEEncoding(bool CFI) const;
232   virtual unsigned getTTypeEncoding() const;
233
234 protected:
235   virtual const MCSection *
236   SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
237                          Mangler *Mang, const TargetMachine &TM) const;
238 };
239
240 } // end namespace llvm
241
242 #endif