OSDN Git Service

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