LLVM  8.0.1
TargetLoweringObjectFileImpl.h
Go to the documentation of this file.
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/IR/Module.h"
19 #include "llvm/MC/MCExpr.h"
21 
22 namespace llvm {
23 
24 class GlobalValue;
25 class MachineModuleInfo;
26 class Mangler;
27 class MCContext;
28 class MCSection;
29 class MCSymbol;
30 class TargetMachine;
31 
33  bool UseInitArray = false;
34  mutable unsigned NextUniqueID = 1; // ID 0 is reserved for execute-only sections
35 
36 protected:
39  const TargetMachine *TM;
40 
41 public:
42  TargetLoweringObjectFileELF() = default;
43  ~TargetLoweringObjectFileELF() override = default;
44 
45  void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
46 
47  /// Emit Obj-C garbage collection and linker options.
48  void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override;
49 
50  void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &DL,
51  const MCSymbol *Sym) const override;
52 
53  /// Given a constant with the SectionKind, return a section that it should be
54  /// placed in.
56  const Constant *C,
57  unsigned &Align) const override;
58 
60  const TargetMachine &TM) const override;
61 
63  const TargetMachine &TM) const override;
64 
66  const TargetMachine &TM) const override;
67 
68  bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
69  const Function &F) const override;
70 
71  /// Return an MCExpr to use for a reference to the specified type info global
72  /// variable from exception handling information.
74  unsigned Encoding,
75  const TargetMachine &TM,
76  MachineModuleInfo *MMI,
77  MCStreamer &Streamer) const override;
78 
79  // The symbol that gets passed to .cfi_personality.
81  const TargetMachine &TM,
82  MachineModuleInfo *MMI) const override;
83 
84  void InitializeELF(bool UseInitArray_);
85  MCSection *getStaticCtorSection(unsigned Priority,
86  const MCSymbol *KeySym) const override;
87  MCSection *getStaticDtorSection(unsigned Priority,
88  const MCSymbol *KeySym) const override;
89 
90  const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
91  const GlobalValue *RHS,
92  const TargetMachine &TM) const override;
93 
94  MCSection *getSectionForCommandLines() const override;
95 };
96 
98 public:
100  ~TargetLoweringObjectFileMachO() override = default;
101 
102  void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
103 
104  /// Emit the module flags that specify the garbage collection information.
105  void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override;
106 
108  const TargetMachine &TM) const override;
109 
111  const TargetMachine &TM) const override;
112 
114  const Constant *C,
115  unsigned &Align) const override;
116 
117  /// The mach-o version of this method defaults to returning a stub reference.
118  const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
119  unsigned Encoding,
120  const TargetMachine &TM,
121  MachineModuleInfo *MMI,
122  MCStreamer &Streamer) const override;
123 
124  // The symbol that gets passed to .cfi_personality.
126  const TargetMachine &TM,
127  MachineModuleInfo *MMI) const override;
128 
129  /// Get MachO PC relative GOT entry relocation
130  const MCExpr *getIndirectSymViaGOTPCRel(const MCSymbol *Sym,
131  const MCValue &MV, int64_t Offset,
132  MachineModuleInfo *MMI,
133  MCStreamer &Streamer) const override;
134 
135  void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
136  const TargetMachine &TM) const override;
137 };
138 
140  mutable unsigned NextUniqueID = 0;
141 
142 public:
143  ~TargetLoweringObjectFileCOFF() override = default;
144 
145  void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
147  const TargetMachine &TM) const override;
148 
150  const TargetMachine &TM) const override;
151 
152  void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
153  const TargetMachine &TM) const override;
154 
156  const TargetMachine &TM) const override;
157 
158  /// Emit Obj-C garbage collection and linker options.
159  void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override;
160 
161  MCSection *getStaticCtorSection(unsigned Priority,
162  const MCSymbol *KeySym) const override;
163  MCSection *getStaticDtorSection(unsigned Priority,
164  const MCSymbol *KeySym) const override;
165 
167  const GlobalValue *GV) const override;
168 
170  const GlobalValue *GV) const override;
171 
172  const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
173  const GlobalValue *RHS,
174  const TargetMachine &TM) const override;
175 
176  /// Given a mergeable constant with the specified size and relocation
177  /// information, return a section that it should be placed in.
179  const Constant *C,
180  unsigned &Align) const override;
181 };
182 
184  mutable unsigned NextUniqueID = 0;
185 
186 public:
187  TargetLoweringObjectFileWasm() = default;
188  ~TargetLoweringObjectFileWasm() override = default;
189 
191  const TargetMachine &TM) const override;
192 
194  const TargetMachine &TM) const override;
195 
196  bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
197  const Function &F) const override;
198 
199  void InitializeWasm();
200  MCSection *getStaticCtorSection(unsigned Priority,
201  const MCSymbol *KeySym) const override;
202  MCSection *getStaticDtorSection(unsigned Priority,
203  const MCSymbol *KeySym) const override;
204 
205  const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
206  const GlobalValue *RHS,
207  const TargetMachine &TM) const override;
208 };
209 
210 } // end namespace llvm
211 
212 #endif // LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
uint64_t CallInst * C
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
This class represents lattice values for constants.
Definition: AllocatorList.h:24
This represents an "assembler immediate".
Definition: MCValue.h:40
void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym) const override
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit Obj-C garbage collection and linker options.
F(f)
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, unsigned &Align) const override
Given a constant with the SectionKind, return a section that it should be placed in.
virtual void emitLinkerFlagsForUsed(raw_ostream &OS, const GlobalValue *GV) const
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Context object for machine code objects.
Definition: MCContext.h:63
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Streaming machine code generation interface.
Definition: MCStreamer.h:189
MCSection * getSectionForCommandLines() const override
If supported, return the section to use for the llvm.commandline metadata.
virtual void emitLinkerFlagsForGlobal(raw_ostream &OS, const GlobalValue *GV) const
This is an important base class in LLVM.
Definition: Constant.h:42
const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
Return an MCExpr to use for a reference to the specified type info global variable from exception han...
~TargetLoweringObjectFileELF() override=default
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:23
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
virtual const MCExpr * getIndirectSymViaGOTPCRel(const MCSymbol *Sym, const MCValue &MV, int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const
Get the target specific PC relative GOT entry relocation.
Module.h This file contains the declarations for the Module class.
MCSymbolRefExpr::VariantKind PLTRelativeVariantKind
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
virtual void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const
const unsigned Kind
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:59
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
This class contains meta information specific to a module.