c43a0a6c7020f538d97fd2207aa467b5ca30d061
[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   void emitPersonalityValue(MCStreamer &Streamer, const TargetMachine &TM,
42                             const MCSymbol *Sym) const LLVM_OVERRIDE;
43
44   /// Given a constant with the SectionKind, return a section that it should be
45   /// placed in.
46   const MCSection *getSectionForConstant(SectionKind Kind) const LLVM_OVERRIDE;
47
48   const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
49                                             SectionKind Kind, Mangler &Mang,
50                                             const TargetMachine &TM) const
51       LLVM_OVERRIDE;
52
53   const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
54                                           SectionKind Kind, Mangler &Mang,
55                                           const TargetMachine &TM) const
56       LLVM_OVERRIDE;
57
58   /// Return an MCExpr to use for a reference to the specified type info global
59   /// variable from exception handling information.
60   const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
61                                         MachineModuleInfo *MMI,
62                                         unsigned Encoding,
63                                         MCStreamer &Streamer) const
64       LLVM_OVERRIDE;
65
66   // The symbol that gets passed to .cfi_personality.
67   MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
68                                     MachineModuleInfo *MMI) const LLVM_OVERRIDE;
69
70   void InitializeELF(bool UseInitArray_);
71   const MCSection *getStaticCtorSection(unsigned Priority = 65535) const
72       LLVM_OVERRIDE;
73   const MCSection *getStaticDtorSection(unsigned Priority = 65535) const
74       LLVM_OVERRIDE;
75 };
76
77
78
79 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
80 public:
81   virtual ~TargetLoweringObjectFileMachO() {}
82
83   /// Extract the dependent library name from a linker option string. Returns
84   /// StringRef() if the option does not specify a library.
85   StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const LLVM_OVERRIDE;
86
87   /// Emit the module flags that specify the garbage collection information.
88   void emitModuleFlags(MCStreamer &Streamer,
89                        ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
90                        Mangler &Mang, const TargetMachine &TM) const
91       LLVM_OVERRIDE;
92
93   const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
94                                           SectionKind Kind, Mangler &Mang,
95                                           const TargetMachine &TM) const
96       LLVM_OVERRIDE;
97
98   const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
99                                             SectionKind Kind, Mangler &Mang,
100                                             const TargetMachine &TM) const
101       LLVM_OVERRIDE;
102
103   const MCSection *getSectionForConstant(SectionKind Kind) const LLVM_OVERRIDE;
104
105   /// This hook allows targets to selectively decide not to emit the
106   /// UsedDirective for some symbols in llvm.used.
107   /// FIXME: REMOVE this (rdar://7071300)
108   bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler &Mang) const
109       LLVM_OVERRIDE;
110
111   /// The mach-o version of this method defaults to returning a stub reference.
112   const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
113                                         MachineModuleInfo *MMI,
114                                         unsigned Encoding,
115                                         MCStreamer &Streamer) const
116       LLVM_OVERRIDE;
117
118   // The symbol that gets passed to .cfi_personality.
119   MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
120                                     MachineModuleInfo *MMI) const LLVM_OVERRIDE;
121 };
122
123
124
125 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
126 public:
127   virtual ~TargetLoweringObjectFileCOFF() {}
128
129   const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
130                                             SectionKind Kind, Mangler &Mang,
131                                             const TargetMachine &TM) const
132       LLVM_OVERRIDE;
133
134   const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
135                                           SectionKind Kind, Mangler &Mang,
136                                           const TargetMachine &TM) const
137       LLVM_OVERRIDE;
138
139   /// Extract the dependent library name from a linker option string. Returns
140   /// StringRef() if the option does not specify a library.
141   StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const LLVM_OVERRIDE;
142
143   /// Emit Obj-C garbage collection and linker options. Only linker option
144   /// emission is implemented for COFF.
145   void emitModuleFlags(MCStreamer &Streamer,
146                        ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
147                        Mangler &Mang, const TargetMachine &TM) const
148       LLVM_OVERRIDE;
149 };
150
151 } // end namespace llvm
152
153 #endif