DebugInfo: PR14728: TLS support
[oota-llvm.git] / include / llvm / CodeGen / TargetLoweringObjectFileImpl.h
1 //==-- llvm/CodeGen/TargetLoweringObjectFileImpl.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_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
16 #define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
17
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/SectionKind.h"
20 #include "llvm/Target/TargetLoweringObjectFile.h"
21
22 namespace llvm {
23   class MachineModuleInfo;
24   class Mangler;
25   class MCAsmInfo;
26   class MCExpr;
27   class MCSection;
28   class MCSectionMachO;
29   class MCSymbol;
30   class MCContext;
31   class GlobalValue;
32   class TargetMachine;
33
34
35 class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
36   bool UseInitArray;
37
38 public:
39   virtual ~TargetLoweringObjectFileELF() {}
40
41   virtual void emitPersonalityValue(MCStreamer &Streamer,
42                                     const TargetMachine &TM,
43                                     const MCSymbol *Sym) const;
44
45   /// getSectionForConstant - Given a constant with the SectionKind, return a
46   /// section that it should be placed in.
47   virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
48
49
50   virtual const MCSection *
51   getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
52                            Mangler *Mang, const TargetMachine &TM) const;
53
54   virtual const MCSection *
55   SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
56                          Mangler *Mang, const TargetMachine &TM) const;
57
58   /// getTTypeGlobalReference - Return an MCExpr to use for a reference to the
59   /// specified type info global variable from exception handling information.
60   virtual const MCExpr *
61   getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
62                           MachineModuleInfo *MMI, unsigned Encoding,
63                           MCStreamer &Streamer) const;
64
65   // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
66   virtual MCSymbol *
67   getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
68                           MachineModuleInfo *MMI) const;
69
70   void InitializeELF(bool UseInitArray_);
71   virtual const MCSection *
72   getStaticCtorSection(unsigned Priority = 65535) const;
73   virtual const MCSection *
74   getStaticDtorSection(unsigned Priority = 65535) const;
75
76   /// \brief Describe a TLS variable address within debug info.
77   virtual const MCSymbolRefExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
78 };
79
80
81
82 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
83 public:
84   virtual ~TargetLoweringObjectFileMachO() {}
85
86   /// emitModuleFlags - Emit the module flags that specify the garbage
87   /// collection information.
88   virtual void emitModuleFlags(MCStreamer &Streamer,
89                                ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
90                                Mangler *Mang, const TargetMachine &TM) const;
91
92   virtual const MCSection *
93   SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
94                          Mangler *Mang, const TargetMachine &TM) const;
95
96   virtual const MCSection *
97   getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
98                            Mangler *Mang, const TargetMachine &TM) const;
99
100   virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
101
102   /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
103   /// decide not to emit the UsedDirective for some symbols in llvm.used.
104   /// FIXME: REMOVE this (rdar://7071300)
105   virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
106                                           Mangler *) const;
107
108   /// getTTypeGlobalReference - The mach-o version of this method
109   /// defaults to returning a stub reference.
110   virtual const MCExpr *
111   getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
112                           MachineModuleInfo *MMI, unsigned Encoding,
113                           MCStreamer &Streamer) const;
114
115   // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
116   virtual MCSymbol *
117   getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
118                           MachineModuleInfo *MMI) const;
119 };
120
121
122
123 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
124 public:
125   virtual ~TargetLoweringObjectFileCOFF() {}
126
127   virtual const MCSection *
128   getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
129                            Mangler *Mang, const TargetMachine &TM) const;
130
131   virtual const MCSection *
132   SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
133                          Mangler *Mang, const TargetMachine &TM) const;
134
135   /// emitModuleFlags - Emit Obj-C garbage collection and linker options.  Only
136   /// linker option emission is implemented for COFF.
137   virtual void emitModuleFlags(MCStreamer &Streamer,
138                                ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
139                                Mangler *Mang, const TargetMachine &TM) const;
140 };
141
142 } // end namespace llvm
143
144 #endif