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