LLVM  4.0.0
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/MC/MCExpr.h"
19 #include "llvm/MC/SectionKind.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 
35  bool UseInitArray;
36  mutable unsigned NextUniqueID = 1; // ID 0 is reserved for execute-only sections
37 
38 protected:
41 
42 public:
43  TargetLoweringObjectFileELF() : UseInitArray(false) {}
44 
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.
53  const Constant *C,
54  unsigned &Align) const override;
55 
57  const TargetMachine &TM) const override;
58 
60  const TargetMachine &TM) const override;
61 
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.
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.
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 
95 public:
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,
104  const TargetMachine &TM) const override;
105 
107  const TargetMachine &TM) const override;
108 
110  const TargetMachine &TM) const override;
111 
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.
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 
141  mutable unsigned NextUniqueID = 0;
142 
143 public:
145 
146  void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
148  const TargetMachine &TM) const override;
149 
151  const TargetMachine &TM) const override;
152 
153  void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
154  const TargetMachine &TM) const override;
155 
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,
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 
171  const GlobalValue *GV) const override;
172 };
173 
174 } // end namespace llvm
175 
176 #endif
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:40
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:102
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
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
This represents an "assembler immediate".
Definition: MCValue.h:40
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
void emitLinkerFlagsForGlobal(raw_ostream &OS, const GlobalValue *GV) const override
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
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...
void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM, const MCSymbol *Sym) const override
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.
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
const MCExpr * getIndirectSymViaGOTPCRel(const MCSymbol *Sym, const MCValue &MV, int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
Get MachO PC relative GOT entry relocation.
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Context object for machine code objects.
Definition: MCContext.h:51
#define F(x, y, z)
Definition: MD5.cpp:51
Function Alias Analysis false
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
Streaming machine code generation interface.
Definition: MCStreamer.h:161
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...
uint32_t Offset
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:23
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.
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
The mach-o version of this method defaults to returning a stub reference.
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
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
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
void emitModuleFlags(MCStreamer &Streamer, ArrayRef< Module::ModuleFlagEntry > ModuleFlags, const TargetMachine &TM) const override
Emit Obj-C garbage collection and linker options.
const unsigned Kind
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...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
Primary interface to the complete machine description for the target machine.
void emitModuleFlags(MCStreamer &Streamer, ArrayRef< Module::ModuleFlagEntry > ModuleFlags, const TargetMachine &TM) const override
Emit the module flags that specify the garbage collection information.
This class contains meta information specific to a module.