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 virtual ~TargetLoweringObjectFileELF() {}
41 void emitPersonalityValue(MCStreamer &Streamer, const TargetMachine &TM,
42 const MCSymbol *Sym) const override;
44 /// Given a constant with the SectionKind, return a section that it should be
46 const MCSection *getSectionForConstant(SectionKind Kind) const override;
48 const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
49 SectionKind Kind, Mangler &Mang,
50 const TargetMachine &TM) const override;
52 const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
53 SectionKind Kind, Mangler &Mang,
54 const TargetMachine &TM) const override;
56 /// Return an MCExpr to use for a reference to the specified type info global
57 /// variable from exception handling information.
59 getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
60 Mangler &Mang, const TargetMachine &TM,
61 MachineModuleInfo *MMI,
62 MCStreamer &Streamer) const override;
64 // The symbol that gets passed to .cfi_personality.
65 MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
66 const TargetMachine &TM,
67 MachineModuleInfo *MMI) const override;
69 void InitializeELF(bool UseInitArray_);
70 const MCSection *getStaticCtorSection(unsigned Priority,
71 const MCSymbol *KeySym,
72 const MCSection *KeySec) const override;
73 const MCSection *getStaticDtorSection(unsigned Priority,
74 const MCSymbol *KeySym,
75 const MCSection *KeySec) const override;
80 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
82 virtual ~TargetLoweringObjectFileMachO() {}
84 /// Extract the dependent library name from a linker option string. Returns
85 /// StringRef() if the option does not specify a library.
86 StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const override;
88 /// Emit the module flags that specify the garbage collection information.
89 void emitModuleFlags(MCStreamer &Streamer,
90 ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
91 Mangler &Mang, const TargetMachine &TM) const override;
93 bool isSectionAtomizableBySymbols(const MCSection &Section) const override;
96 SelectSectionForGlobal(const GlobalValue *GV,
97 SectionKind Kind, Mangler &Mang,
98 const TargetMachine &TM) const override;
101 getExplicitSectionGlobal(const GlobalValue *GV,
102 SectionKind Kind, Mangler &Mang,
103 const TargetMachine &TM) const override;
105 const MCSection *getSectionForConstant(SectionKind Kind) const override;
107 /// The mach-o version of this method defaults to returning a stub reference.
109 getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
110 Mangler &Mang, const TargetMachine &TM,
111 MachineModuleInfo *MMI,
112 MCStreamer &Streamer) const override;
114 // The symbol that gets passed to .cfi_personality.
115 MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
116 const TargetMachine &TM,
117 MachineModuleInfo *MMI) const override;
122 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
124 virtual ~TargetLoweringObjectFileCOFF() {}
127 getExplicitSectionGlobal(const GlobalValue *GV,
128 SectionKind Kind, Mangler &Mang,
129 const TargetMachine &TM) const override;
132 SelectSectionForGlobal(const GlobalValue *GV,
133 SectionKind Kind, Mangler &Mang,
134 const TargetMachine &TM) const override;
136 /// Extract the dependent library name from a linker option string. Returns
137 /// StringRef() if the option does not specify a library.
138 StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const override;
140 /// Emit Obj-C garbage collection and linker options. Only linker option
141 /// emission is implemented for COFF.
142 void emitModuleFlags(MCStreamer &Streamer,
143 ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
144 Mangler &Mang, const TargetMachine &TM) const override;
146 const MCSection *getStaticCtorSection(unsigned Priority,
147 const MCSymbol *KeySym,
148 const MCSection *KeySec) const override;
149 const MCSection *getStaticDtorSection(unsigned Priority,
150 const MCSymbol *KeySym,
151 const MCSection *KeySec) const override;
154 } // end namespace llvm