1 //==-- llvm/CodeGen/TargetLoweringObjectFileImpl.h - Object Info -*- C++ -*-==// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file implements classes used to handle lowerings specific to common 11 // object file formats. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H 16 #define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H 17 18 #include "llvm/MC/SectionKind.h" 19 #include "llvm/Target/TargetLoweringObjectFile.h" 20 #include "llvm/ADT/StringRef.h" 21 22 namespace llvm { 23 class MachineModuleInfo; 24 class Mangler; 25 class MCAsmInfo; 26 class MCExpr; 27 class MCSection; 28 class MCSectionMachO; 29 class MCSymbol; 30 class MCContext; 31 class GlobalValue; 32 class TargetMachine; 33 34 35 class TargetLoweringObjectFileELF : public TargetLoweringObjectFile { 36 public: 37 virtual ~TargetLoweringObjectFileELF() {} 38 39 virtual void emitPersonalityValue(MCStreamer &Streamer, 40 const TargetMachine &TM, 41 const MCSymbol *Sym) const; 42 43 /// getSectionForConstant - Given a constant with the SectionKind, return a 44 /// section that it should be placed in. 45 virtual const MCSection *getSectionForConstant(SectionKind Kind) const; 46 47 48 virtual const MCSection * 49 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, 50 Mangler *Mang, const TargetMachine &TM) const; 51 52 virtual const MCSection * 53 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, 54 Mangler *Mang, const TargetMachine &TM) const; 55 56 /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference 57 /// to the specified global variable from exception handling information. 58 /// 59 virtual const MCExpr * 60 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, 61 MachineModuleInfo *MMI, unsigned Encoding, 62 MCStreamer &Streamer) const; 63 64 // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality. 65 virtual MCSymbol * 66 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, 67 MachineModuleInfo *MMI) const; 68 69 virtual const MCSection * 70 getStaticCtorSection(unsigned Priority = 65535) const; 71 virtual const MCSection * 72 getStaticDtorSection(unsigned Priority = 65535) const; 73 }; 74 75 76 77 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile { 78 public: 79 virtual ~TargetLoweringObjectFileMachO() {} 80 81 /// emitModuleFlags - Emit the module flags that specify the garbage 82 /// collection information. 83 virtual void emitModuleFlags(MCStreamer &Streamer, 84 ArrayRef<Module::ModuleFlagEntry> ModuleFlags, 85 Mangler *Mang, const TargetMachine &TM) const; 86 87 virtual const MCSection * 88 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, 89 Mangler *Mang, const TargetMachine &TM) const; 90 91 virtual const MCSection * 92 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, 93 Mangler *Mang, const TargetMachine &TM) const; 94 95 virtual const MCSection *getSectionForConstant(SectionKind Kind) const; 96 97 /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively 98 /// decide not to emit the UsedDirective for some symbols in llvm.used. 99 /// FIXME: REMOVE this (rdar://7071300) 100 virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, 101 Mangler *) const; 102 103 /// getExprForDwarfGlobalReference - The mach-o version of this method 104 /// defaults to returning a stub reference. 105 virtual const MCExpr * 106 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, 107 MachineModuleInfo *MMI, unsigned Encoding, 108 MCStreamer &Streamer) const; 109 110 // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality. 111 virtual MCSymbol * 112 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, 113 MachineModuleInfo *MMI) const; 114 }; 115 116 117 118 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile { 119 public: 120 virtual ~TargetLoweringObjectFileCOFF() {} 121 122 virtual const MCSection * 123 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, 124 Mangler *Mang, const TargetMachine &TM) const; 125 126 virtual const MCSection * 127 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, 128 Mangler *Mang, const TargetMachine &TM) const; 129 }; 130 131 } // end namespace llvm 132 133 #endif 134