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 /// Return an MCExpr to use for a reference to the specified type info global
64 /// variable from exception handling information.
66 getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
67 Mangler &Mang, const TargetMachine &TM,
68 MachineModuleInfo *MMI,
69 MCStreamer &Streamer) const override;
71 // The symbol that gets passed to .cfi_personality.
72 MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
73 const TargetMachine &TM,
74 MachineModuleInfo *MMI) const override;
76 void InitializeELF(bool UseInitArray_);
77 const MCSection *getStaticCtorSection(unsigned Priority,
78 const MCSymbol *KeySym) const override;
79 const MCSection *getStaticDtorSection(unsigned Priority,
80 const MCSymbol *KeySym) const override;
85 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
87 virtual ~TargetLoweringObjectFileMachO() {}
89 /// Extract the dependent library name from a linker option string. Returns
90 /// StringRef() if the option does not specify a library.
91 StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const override;
93 /// Emit the module flags that specify the garbage collection information.
94 void emitModuleFlags(MCStreamer &Streamer,
95 ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
96 Mangler &Mang, const TargetMachine &TM) const override;
99 SelectSectionForGlobal(const GlobalValue *GV,
100 SectionKind Kind, Mangler &Mang,
101 const TargetMachine &TM) const override;
104 getExplicitSectionGlobal(const GlobalValue *GV,
105 SectionKind Kind, Mangler &Mang,
106 const TargetMachine &TM) const override;
108 const MCSection *getSectionForConstant(SectionKind Kind,
109 const Constant *C) const override;
111 /// The mach-o version of this method defaults to returning a stub reference.
113 getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
114 Mangler &Mang, const TargetMachine &TM,
115 MachineModuleInfo *MMI,
116 MCStreamer &Streamer) const override;
118 // The symbol that gets passed to .cfi_personality.
119 MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
120 const TargetMachine &TM,
121 MachineModuleInfo *MMI) const override;
126 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
128 virtual ~TargetLoweringObjectFileCOFF() {}
131 getExplicitSectionGlobal(const GlobalValue *GV,
132 SectionKind Kind, Mangler &Mang,
133 const TargetMachine &TM) const override;
136 SelectSectionForGlobal(const GlobalValue *GV,
137 SectionKind Kind, Mangler &Mang,
138 const TargetMachine &TM) const override;
140 /// Extract the dependent library name from a linker option string. Returns
141 /// StringRef() if the option does not specify a library.
142 StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const override;
144 /// Emit Obj-C garbage collection and linker options. Only linker option
145 /// emission is implemented for COFF.
146 void emitModuleFlags(MCStreamer &Streamer,
147 ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
148 Mangler &Mang, const TargetMachine &TM) const override;
150 const MCSection *getStaticCtorSection(unsigned Priority,
151 const MCSymbol *KeySym) const override;
152 const MCSection *getStaticDtorSection(unsigned Priority,
153 const MCSymbol *KeySym) const override;
156 } // end namespace llvm