]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
Import Amazon Elastic Network Adapter (ENA) HAL to sys/contrib/
[FreeBSD/FreeBSD.git] / contrib / llvm / 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/MC/MCExpr.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 MCSection;
27   class MCSectionMachO;
28   class MCSymbol;
29   class MCContext;
30   class GlobalValue;
31   class TargetMachine;
32
33
34 class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
35   bool UseInitArray;
36   mutable unsigned NextUniqueID = 1;  // ID 0 is reserved for execute-only sections
37
38 protected:
39   MCSymbolRefExpr::VariantKind PLTRelativeVariantKind =
40       MCSymbolRefExpr::VK_None;
41
42 public:
43   TargetLoweringObjectFileELF() : UseInitArray(false) {}
44
45   ~TargetLoweringObjectFileELF() override {}
46
47   void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM,
48                             const MCSymbol *Sym) const override;
49
50   /// Given a constant with the SectionKind, return a section that it should be
51   /// placed in.
52   MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
53                                    const Constant *C,
54                                    unsigned &Align) const override;
55
56   MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
57                                       const TargetMachine &TM) const override;
58
59   MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
60                                     const TargetMachine &TM) const override;
61
62   MCSection *getSectionForJumpTable(const Function &F,
63                                     const TargetMachine &TM) const override;
64
65   bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
66                                            const Function &F) const override;
67
68   /// Return an MCExpr to use for a reference to the specified type info global
69   /// variable from exception handling information.
70   const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
71                                         unsigned Encoding,
72                                         const TargetMachine &TM,
73                                         MachineModuleInfo *MMI,
74                                         MCStreamer &Streamer) const override;
75
76   // The symbol that gets passed to .cfi_personality.
77   MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
78                                     const TargetMachine &TM,
79                                     MachineModuleInfo *MMI) const override;
80
81   void InitializeELF(bool UseInitArray_);
82   MCSection *getStaticCtorSection(unsigned Priority,
83                                   const MCSymbol *KeySym) const override;
84   MCSection *getStaticDtorSection(unsigned Priority,
85                                   const MCSymbol *KeySym) const override;
86
87   const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
88                                        const GlobalValue *RHS,
89                                        const TargetMachine &TM) const override;
90 };
91
92
93
94 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
95 public:
96   ~TargetLoweringObjectFileMachO() override {}
97   TargetLoweringObjectFileMachO();
98
99   void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
100
101   /// Emit the module flags that specify the garbage collection information.
102   void emitModuleFlags(MCStreamer &Streamer,
103                        ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
104                        const TargetMachine &TM) const override;
105
106   MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
107                                     const TargetMachine &TM) const override;
108
109   MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
110                                       const TargetMachine &TM) const override;
111
112   MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
113                                    const Constant *C,
114                                    unsigned &Align) const override;
115
116   /// The mach-o version of this method defaults to returning a stub reference.
117   const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
118                                         unsigned Encoding,
119                                         const TargetMachine &TM,
120                                         MachineModuleInfo *MMI,
121                                         MCStreamer &Streamer) const override;
122
123   // The symbol that gets passed to .cfi_personality.
124   MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
125                                     const TargetMachine &TM,
126                                     MachineModuleInfo *MMI) const override;
127
128   /// Get MachO PC relative GOT entry relocation
129   const MCExpr *getIndirectSymViaGOTPCRel(const MCSymbol *Sym,
130                                           const MCValue &MV, int64_t Offset,
131                                           MachineModuleInfo *MMI,
132                                           MCStreamer &Streamer) const override;
133
134   void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
135                          const TargetMachine &TM) const override;
136 };
137
138
139
140 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
141   mutable unsigned NextUniqueID = 0;
142
143 public:
144   ~TargetLoweringObjectFileCOFF() override {}
145
146   void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
147   MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
148                                       const TargetMachine &TM) const override;
149
150   MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
151                                     const TargetMachine &TM) const override;
152
153   void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
154                          const TargetMachine &TM) const override;
155
156   MCSection *getSectionForJumpTable(const Function &F,
157                                     const TargetMachine &TM) const override;
158
159   /// Emit Obj-C garbage collection and linker options. Only linker option
160   /// emission is implemented for COFF.
161   void emitModuleFlags(MCStreamer &Streamer,
162                        ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
163                        const TargetMachine &TM) const override;
164
165   MCSection *getStaticCtorSection(unsigned Priority,
166                                   const MCSymbol *KeySym) const override;
167   MCSection *getStaticDtorSection(unsigned Priority,
168                                   const MCSymbol *KeySym) const override;
169
170   void emitLinkerFlagsForGlobal(raw_ostream &OS,
171                                 const GlobalValue *GV) const override;
172 };
173
174 } // end namespace llvm
175
176 #endif