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