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 /// getSectionForConstant - Given a constant with the SectionKind, return a
46 /// section that it should be placed in.
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, TargetMachine &TM) const;
58 /// getTTypeGlobalReference - Return an MCExpr to use for a reference to the
59 /// specified type info global 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 // getCFIPersonalitySymbol - 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 /// getDepLibFromLinkerOpt - Extract the dependent library name from a linker
84 /// option string. Returns StringRef() if the option does not specify a library.
85 virtual StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const;
87 /// emitModuleFlags - Emit the module flags that specify the garbage
88 /// collection information.
89 virtual void emitModuleFlags(MCStreamer &Streamer,
90 ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
91 Mangler *Mang, const TargetMachine &TM) const;
93 virtual const MCSection *
94 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
95 Mangler *Mang, TargetMachine &TM) const;
97 virtual const MCSection *
98 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
99 Mangler *Mang, const TargetMachine &TM) const;
101 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
103 /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
104 /// decide not to emit the UsedDirective for some symbols in llvm.used.
105 /// FIXME: REMOVE this (rdar://7071300)
106 virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
109 /// getTTypeGlobalReference - The mach-o version of this method
110 /// defaults to returning a stub reference.
111 virtual const MCExpr *
112 getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
113 MachineModuleInfo *MMI, unsigned Encoding,
114 MCStreamer &Streamer) const;
116 // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
118 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
119 MachineModuleInfo *MMI) const;
124 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
126 virtual ~TargetLoweringObjectFileCOFF() {}
128 virtual const MCSection *
129 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
130 Mangler *Mang, const TargetMachine &TM) const;
132 virtual const MCSection *
133 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
134 Mangler *Mang, TargetMachine &TM) const;
136 /// getDepLibFromLinkerOpt - Extract the dependent library name from a linker
137 /// option string. Returns StringRef() if the option does not specify a library.
138 virtual StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const;
140 /// emitModuleFlags - Emit Obj-C garbage collection and linker options. Only
141 /// linker option emission is implemented for COFF.
142 virtual void emitModuleFlags(MCStreamer &Streamer,
143 ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
144 Mangler *Mang, const TargetMachine &TM) const;
147 } // end namespace llvm