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 virtual void emitPersonalityValue(MCStreamer &Streamer,
42 const TargetMachine &TM,
43 const MCSymbol *Sym) const;
45 /// Given a constant with the SectionKind, return a section that it should be
47 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
50 virtual const MCSection *
51 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
52 Mangler *Mang, const TargetMachine &TM) const;
54 virtual const MCSection *
55 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
56 Mangler *Mang, 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.
60 virtual const MCExpr *
61 getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
62 MachineModuleInfo *MMI, unsigned Encoding,
63 MCStreamer &Streamer) const;
65 // The symbol that gets passed to .cfi_personality.
67 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
68 MachineModuleInfo *MMI) const;
70 void InitializeELF(bool UseInitArray_);
71 virtual const MCSection *
72 getStaticCtorSection(unsigned Priority = 65535) const;
73 virtual const MCSection *
74 getStaticDtorSection(unsigned Priority = 65535) const;
79 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
81 virtual ~TargetLoweringObjectFileMachO() {}
83 /// Extract the dependent library name from a linker option string. Returns
84 /// StringRef() if the option does not specify a library.
85 virtual StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const;
87 /// Emit the module flags that specify the garbage collection information.
88 virtual void emitModuleFlags(MCStreamer &Streamer,
89 ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
90 Mangler *Mang, const TargetMachine &TM) const;
92 virtual const MCSection *
93 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
94 Mangler *Mang, const TargetMachine &TM) const;
96 virtual const MCSection *
97 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
98 Mangler *Mang, const TargetMachine &TM) const;
100 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
102 /// This hook allows targets to selectively decide not to emit the
103 /// UsedDirective for some symbols in llvm.used.
104 /// FIXME: REMOVE this (rdar://7071300)
105 virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
108 /// The mach-o version of this method defaults to returning a stub reference.
109 virtual const MCExpr *
110 getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
111 MachineModuleInfo *MMI, unsigned Encoding,
112 MCStreamer &Streamer) const;
114 // The symbol that gets passed to .cfi_personality.
116 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
117 MachineModuleInfo *MMI) const;
122 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
124 virtual ~TargetLoweringObjectFileCOFF() {}
126 virtual const MCSection *
127 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
128 Mangler *Mang, const TargetMachine &TM) const;
130 virtual const MCSection *
131 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
132 Mangler *Mang, const TargetMachine &TM) const;
134 /// Extract the dependent library name from a linker option string. Returns
135 /// StringRef() if the option does not specify a library.
136 virtual StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const;
138 /// Emit Obj-C garbage collection and linker options. Only linker option
139 /// emission is implemented for COFF.
140 virtual void emitModuleFlags(MCStreamer &Streamer,
141 ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
142 Mangler *Mang, const TargetMachine &TM) const;
145 } // end namespace llvm