TargetLoweringObjectFileImpl.h revision d6b43a317e71246380db55a50b799b062b53cdce
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 22namespace 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 35class TargetLoweringObjectFileELF : public TargetLoweringObjectFile { 36 bool UseInitArray; 37 38public: 39 virtual ~TargetLoweringObjectFileELF() {} 40 41 virtual void emitPersonalityValue(MCStreamer &Streamer, 42 const TargetMachine &TM, 43 const MCSymbol *Sym) const; 44 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; 48 49 50 virtual const MCSection * 51 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, 52 Mangler *Mang, const TargetMachine &TM) const; 53 54 virtual const MCSection * 55 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, 56 Mangler *Mang, const TargetMachine &TM) const; 57 58 /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference 59 /// to the specified global variable from exception handling information. 60 /// 61 virtual const MCExpr * 62 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, 63 MachineModuleInfo *MMI, unsigned Encoding, 64 MCStreamer &Streamer) const; 65 66 // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality. 67 virtual MCSymbol * 68 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, 69 MachineModuleInfo *MMI) const; 70 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; 76}; 77 78 79 80class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile { 81public: 82 virtual ~TargetLoweringObjectFileMachO() {} 83 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; 89 90 virtual const MCSection * 91 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, 92 Mangler *Mang, const TargetMachine &TM) const; 93 94 virtual const MCSection * 95 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, 96 Mangler *Mang, const TargetMachine &TM) const; 97 98 virtual const MCSection *getSectionForConstant(SectionKind Kind) const; 99 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, 104 Mangler *) const; 105 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; 112 113 // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality. 114 virtual MCSymbol * 115 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, 116 MachineModuleInfo *MMI) const; 117}; 118 119 120 121class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile { 122public: 123 virtual ~TargetLoweringObjectFileCOFF() {} 124 125 virtual const MCSection * 126 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, 127 Mangler *Mang, const TargetMachine &TM) const; 128 129 virtual const MCSection * 130 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, 131 Mangler *Mang, const TargetMachine &TM) const; 132}; 133 134} // end namespace llvm 135 136#endif 137