1 //==-- llvm/CodeGen/TargetLoweringObjectFileImpl.h - Object Info -*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements classes used to handle lowerings specific to common
11 // object file formats.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
16 #define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/SectionKind.h"
20 #include "llvm/Target/TargetLoweringObjectFile.h"
23 class MachineModuleInfo;
35 class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
39 TargetLoweringObjectFileELF() : UseInitArray(false) {}
41 virtual ~TargetLoweringObjectFileELF() {}
43 void emitPersonalityValue(MCStreamer &Streamer, const TargetMachine &TM,
44 const MCSymbol *Sym) const override;
46 /// Given a constant with the SectionKind, return a section that it should be
48 const MCSection *getSectionForConstant(SectionKind Kind,
49 const Constant *C) const override;
51 const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
52 SectionKind Kind, Mangler &Mang,
53 const TargetMachine &TM) const override;
55 const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
56 SectionKind Kind, Mangler &Mang,
57 const TargetMachine &TM) const override;
60 getSectionForJumpTable(const Function &F, Mangler &Mang,
61 const TargetMachine &TM) const override;
63 bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
64 const Function &F) const override;
66 /// Return an MCExpr to use for a reference to the specified type info global
67 /// variable from exception handling information.
69 getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
70 Mangler &Mang, const TargetMachine &TM,
71 MachineModuleInfo *MMI,
72 MCStreamer &Streamer) const override;
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;
79 void InitializeELF(bool UseInitArray_);
80 const MCSection *getStaticCtorSection(unsigned Priority,
81 const MCSymbol *KeySym) const override;
82 const MCSection *getStaticDtorSection(unsigned Priority,
83 const MCSymbol *KeySym) const override;
88 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
90 virtual ~TargetLoweringObjectFileMachO() {}
91 TargetLoweringObjectFileMachO();
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;
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;
103 SelectSectionForGlobal(const GlobalValue *GV,
104 SectionKind Kind, Mangler &Mang,
105 const TargetMachine &TM) const override;
108 getExplicitSectionGlobal(const GlobalValue *GV,
109 SectionKind Kind, Mangler &Mang,
110 const TargetMachine &TM) const override;
112 const MCSection *getSectionForConstant(SectionKind Kind,
113 const Constant *C) const override;
115 /// The mach-o version of this method defaults to returning a stub reference.
117 getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
118 Mangler &Mang, const TargetMachine &TM,
119 MachineModuleInfo *MMI,
120 MCStreamer &Streamer) const override;
122 // The symbol that gets passed to .cfi_personality.
123 MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
124 const TargetMachine &TM,
125 MachineModuleInfo *MMI) const override;
127 /// Get MachO PC relative GOT entry relocation
128 const MCExpr *getIndirectSymViaGOTPCRel(const MCSymbol *Sym,
129 const MCValue &MV, int64_t Offset,
130 MachineModuleInfo *MMI,
131 MCStreamer &Streamer) const override;
136 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
138 virtual ~TargetLoweringObjectFileCOFF() {}
141 getExplicitSectionGlobal(const GlobalValue *GV,
142 SectionKind Kind, Mangler &Mang,
143 const TargetMachine &TM) const override;
146 SelectSectionForGlobal(const GlobalValue *GV,
147 SectionKind Kind, Mangler &Mang,
148 const TargetMachine &TM) const override;
150 /// Extract the dependent library name from a linker option string. Returns
151 /// StringRef() if the option does not specify a library.
152 StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const override;
154 /// Emit Obj-C garbage collection and linker options. Only linker option
155 /// emission is implemented for COFF.
156 void emitModuleFlags(MCStreamer &Streamer,
157 ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
158 Mangler &Mang, const TargetMachine &TM) const override;
160 const MCSection *getStaticCtorSection(unsigned Priority,
161 const MCSymbol *KeySym) const override;
162 const MCSection *getStaticDtorSection(unsigned Priority,
163 const MCSymbol *KeySym) const override;
166 } // end namespace llvm