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/MC/SectionKind.h"
19 #include "llvm/Target/TargetLoweringObjectFile.h"
20 #include "llvm/ADT/StringRef.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, const TargetMachine &TM) const;
58 /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference
59 /// to the specified global variable from exception handling information.
61 virtual const MCExpr *
62 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
63 MachineModuleInfo *MMI, unsigned Encoding,
64 MCStreamer &Streamer) const;
66 // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
68 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
69 MachineModuleInfo *MMI) const;
71 void InitializeELF(bool UseInitArray_);
72 virtual const MCSection *
73 getStaticCtorSection(unsigned Priority = 65535) const;
74 virtual const MCSection *
75 getStaticDtorSection(unsigned Priority = 65535) const;
80 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
82 virtual ~TargetLoweringObjectFileMachO() {}
84 /// emitModuleFlags - Emit the module flags that specify the garbage
85 /// collection information.
86 virtual void emitModuleFlags(MCStreamer &Streamer,
87 ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
88 Mangler *Mang, const TargetMachine &TM) const;
90 virtual const MCSection *
91 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
92 Mangler *Mang, const TargetMachine &TM) const;
94 virtual const MCSection *
95 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
96 Mangler *Mang, const TargetMachine &TM) const;
98 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
100 /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
101 /// decide not to emit the UsedDirective for some symbols in llvm.used.
102 /// FIXME: REMOVE this (rdar://7071300)
103 virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
106 /// getExprForDwarfGlobalReference - The mach-o version of this method
107 /// defaults to returning a stub reference.
108 virtual const MCExpr *
109 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
110 MachineModuleInfo *MMI, unsigned Encoding,
111 MCStreamer &Streamer) const;
113 // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
115 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
116 MachineModuleInfo *MMI) const;
121 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
123 virtual ~TargetLoweringObjectFileCOFF() {}
125 virtual const MCSection *
126 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
127 Mangler *Mang, const TargetMachine &TM) const;
129 virtual const MCSection *
130 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
131 Mangler *Mang, const TargetMachine &TM) const;
134 } // end namespace llvm