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_);
71 getStaticCtorSection(unsigned Priority = 65535) const override;
73 getStaticDtorSection(unsigned Priority = 65535) const override;
78 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
80 virtual ~TargetLoweringObjectFileMachO() {}
82 /// Extract the dependent library name from a linker option string. Returns
83 /// StringRef() if the option does not specify a library.
84 StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const override;
86 /// Emit the module flags that specify the garbage collection information.
87 void emitModuleFlags(MCStreamer &Streamer,
88 ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
89 Mangler &Mang, const TargetMachine &TM) const override;
91 bool isSectionAtomizableBySymbols(const MCSection &Section) const override;
94 SelectSectionForGlobal(const GlobalValue *GV,
95 SectionKind Kind, Mangler &Mang,
96 const TargetMachine &TM) const override;
99 getExplicitSectionGlobal(const GlobalValue *GV,
100 SectionKind Kind, Mangler &Mang,
101 const TargetMachine &TM) const override;
103 const MCSection *getSectionForConstant(SectionKind Kind) const override;
105 /// The mach-o version of this method defaults to returning a stub reference.
107 getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
108 Mangler &Mang, const TargetMachine &TM,
109 MachineModuleInfo *MMI,
110 MCStreamer &Streamer) const override;
112 // The symbol that gets passed to .cfi_personality.
113 MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
114 const TargetMachine &TM,
115 MachineModuleInfo *MMI) const override;
120 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
122 virtual ~TargetLoweringObjectFileCOFF() {}
125 getExplicitSectionGlobal(const GlobalValue *GV,
126 SectionKind Kind, Mangler &Mang,
127 const TargetMachine &TM) const override;
130 SelectSectionForGlobal(const GlobalValue *GV,
131 SectionKind Kind, Mangler &Mang,
132 const TargetMachine &TM) const override;
134 /// Extract the dependent library name from a linker option string. Returns
135 /// StringRef() if the option does not specify a library.
136 StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const override;
138 /// Emit Obj-C garbage collection and linker options. Only linker option
139 /// emission is implemented for COFF.
140 void emitModuleFlags(MCStreamer &Streamer,
141 ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
142 Mangler &Mang, const TargetMachine &TM) const override;
145 } // end namespace llvm