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 LLVM_OVERRIDE;
44 /// Given a constant with the SectionKind, return a section that it should be
46 const MCSection *getSectionForConstant(SectionKind Kind) const LLVM_OVERRIDE;
48 const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
49 SectionKind Kind, Mangler &Mang,
50 const TargetMachine &TM) const
53 const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
54 SectionKind Kind, Mangler &Mang,
55 const TargetMachine &TM) const
58 /// Return an MCExpr to use for a reference to the specified type info global
59 /// variable from exception handling information.
61 getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
62 Mangler &Mang, const TargetMachine &TM,
63 MachineModuleInfo *MMI, MCStreamer &Streamer) const
66 // The symbol that gets passed to .cfi_personality.
67 MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
68 const TargetMachine &TM,
69 MachineModuleInfo *MMI) const LLVM_OVERRIDE;
71 void InitializeELF(bool UseInitArray_);
72 const MCSection *getStaticCtorSection(unsigned Priority = 65535) const
74 const MCSection *getStaticDtorSection(unsigned Priority = 65535) const
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 LLVM_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
94 bool isSectionAtomizableBySymbols(const MCSection &Section) const
97 const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
98 SectionKind Kind, Mangler &Mang,
99 const TargetMachine &TM) const
102 const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
103 SectionKind Kind, Mangler &Mang,
104 const TargetMachine &TM) const
107 const MCSection *getSectionForConstant(SectionKind Kind) const LLVM_OVERRIDE;
109 /// This hook allows targets to selectively decide not to emit the
110 /// UsedDirective for some symbols in llvm.used.
111 /// FIXME: REMOVE this (rdar://7071300)
112 bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler &Mang,
113 TargetMachine &TM) const LLVM_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, MCStreamer &Streamer) const
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 LLVM_OVERRIDE;
130 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
132 virtual ~TargetLoweringObjectFileCOFF() {}
134 const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
135 SectionKind Kind, Mangler &Mang,
136 const TargetMachine &TM) const
139 const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
140 SectionKind Kind, Mangler &Mang,
141 const TargetMachine &TM) const
144 /// Extract the dependent library name from a linker option string. Returns
145 /// StringRef() if the option does not specify a library.
146 StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const LLVM_OVERRIDE;
148 /// Emit Obj-C garbage collection and linker options. Only linker option
149 /// emission is implemented for COFF.
150 void emitModuleFlags(MCStreamer &Streamer,
151 ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
152 Mangler &Mang, const TargetMachine &TM) const
156 } // end namespace llvm