1c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===-- llvm/Target/TargetLoweringObjectFile.h - Object Info ----*- C++ -*-===// 2c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 3c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// The LLVM Compiler Infrastructure 4c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 5c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// This file is distributed under the University of Illinois Open Source 6c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// License. See LICENSE.TXT for details. 7c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 8c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===// 9c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 10c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// This file implements classes used to handle lowerings specific to common 11c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// object file formats. 12c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 13c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===// 14c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 15c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#ifndef LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H 16c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#define LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H 17c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 18c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/ArrayRef.h" 19c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/StringRef.h" 20c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/IR/Module.h" 21c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/MC/MCObjectFileInfo.h" 22c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/MC/SectionKind.h" 23c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <cstdint> 24c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 25c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace llvm { 26c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 27c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass GlobalValue; 28c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MachineModuleInfo; 29c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass Mangler; 30c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCContext; 31c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCExpr; 32c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCSection; 33c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCSymbol; 34c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCSymbolRefExpr; 35c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCStreamer; 36c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCValue; 37c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass TargetMachine; 38c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 39c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass TargetLoweringObjectFile : public MCObjectFileInfo { 40c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MCContext *Ctx = nullptr; 41c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 42c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Name-mangler for global names. 43c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Mangler *Mang = nullptr; 44c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 45c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprotected: 46c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot bool SupportIndirectSymViaGOTPCRel = false; 47c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot bool SupportGOTPCRelWithOffset = true; 48c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 49c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// This section contains the static constructor pointer list. 50c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MCSection *StaticCtorSection = nullptr; 51c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 52c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// This section contains the static destructor pointer list. 53c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MCSection *StaticDtorSection = nullptr; 54c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 55c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic: 56c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot TargetLoweringObjectFile() = default; 57c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot TargetLoweringObjectFile(const TargetLoweringObjectFile &) = delete; 58c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot TargetLoweringObjectFile & 59c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot operator=(const TargetLoweringObjectFile &) = delete; 60c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual ~TargetLoweringObjectFile(); 61c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 62c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MCContext &getContext() const { return *Ctx; } 63c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Mangler &getMangler() const { return *Mang; } 64c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 65c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// This method must be called before any actual lowering is done. This 66c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// specifies the current context for codegen, and gives the lowering 67c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// implementations a chance to set up their default sections. 68c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual void Initialize(MCContext &ctx, const TargetMachine &TM); 69c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 70c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM, 71c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const MCSymbol *Sym) const; 72c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 73c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Emit the module-level metadata that the platform cares about. 74c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual void emitModuleMetadata(MCStreamer &Streamer, Module &M, 75c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const TargetMachine &TM) const {} 76c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 77c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Given a constant with the SectionKind, return a section that it should be 78c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// placed in. 79c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual MCSection *getSectionForConstant(const DataLayout &DL, 80c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot SectionKind Kind, 81c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const Constant *C, 82c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot unsigned &Align) const; 83c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 84c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Classify the specified global variable into a set of target independent 85c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// categories embodied in SectionKind. 86c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot static SectionKind getKindForGlobal(const GlobalObject *GO, 87c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const TargetMachine &TM); 88c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 89c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// This method computes the appropriate section to emit the specified global 90c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// variable or function definition. This should not be passed external (or 91c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// available externally) globals. 92c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MCSection *SectionForGlobal(const GlobalObject *GO, SectionKind Kind, 93c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const TargetMachine &TM) const; 94c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 95c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// This method computes the appropriate section to emit the specified global 96c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// variable or function definition. This should not be passed external (or 97c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// available externally) globals. 98c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MCSection *SectionForGlobal(const GlobalObject *GO, 99c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const TargetMachine &TM) const { 100c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return SectionForGlobal(GO, getKindForGlobal(GO, TM), TM); 101c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 102c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 103c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual void getNameWithPrefix(SmallVectorImpl<char> &OutName, 104c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const GlobalValue *GV, 105c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const TargetMachine &TM) const; 106c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 107c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual MCSection *getSectionForJumpTable(const Function &F, 108c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const TargetMachine &TM) const; 109c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 110c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, 111c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const Function &F) const; 112c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 113c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Targets should implement this method to assign a section to globals with 114c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// an explicit section specfied. The implementation of this method can 115c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// assume that GO->hasSection() is true. 116c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual MCSection * 117c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, 118c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const TargetMachine &TM) const = 0; 119c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 120c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Return an MCExpr to use for a reference to the specified global variable 121c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// from exception handling information. 122c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, 123c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot unsigned Encoding, 124c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const TargetMachine &TM, 125c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MachineModuleInfo *MMI, 126c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MCStreamer &Streamer) const; 127c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 128c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Return the MCSymbol for a private symbol with global value name as its 129c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// base, with the specified suffix. 130c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV, 131c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot StringRef Suffix, 132c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const TargetMachine &TM) const; 133c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 134c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // The symbol that gets passed to .cfi_personality. 135c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, 136c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const TargetMachine &TM, 137c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MachineModuleInfo *MMI) const; 138c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 139c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const MCExpr *getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding, 140c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MCStreamer &Streamer) const; 141c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 142c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual MCSection *getStaticCtorSection(unsigned Priority, 143c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const MCSymbol *KeySym) const { 144c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return StaticCtorSection; 145c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 146c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 147c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual MCSection *getStaticDtorSection(unsigned Priority, 148c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const MCSymbol *KeySym) const { 149c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return StaticDtorSection; 150c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 151c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 152c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// \brief Create a symbol reference to describe the given TLS variable when 153c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// emitting the address in debug info. 154c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const; 155c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 156c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual const MCExpr *lowerRelativeReference(const GlobalValue *LHS, 157c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const GlobalValue *RHS, 158c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const TargetMachine &TM) const { 159c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return nullptr; 160c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 161c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 162c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// \brief Target supports replacing a data "PC"-relative access to a symbol 163c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// through another symbol, by accessing the later via a GOT entry instead? 164c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot bool supportIndirectSymViaGOTPCRel() const { 165c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return SupportIndirectSymViaGOTPCRel; 166c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 167c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 168c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// \brief Target GOT "PC"-relative relocation supports encoding an additional 169c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// binary expression with an offset? 170c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot bool supportGOTPCRelWithOffset() const { 171c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return SupportGOTPCRelWithOffset; 172c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 173c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 174c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// \brief Get the target specific PC relative GOT entry relocation 175c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual const MCExpr *getIndirectSymViaGOTPCRel(const MCSymbol *Sym, 176c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const MCValue &MV, 177c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot int64_t Offset, 178c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MachineModuleInfo *MMI, 179c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MCStreamer &Streamer) const { 180c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return nullptr; 181c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 182c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 183c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual void emitLinkerFlagsForGlobal(raw_ostream &OS, 184c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const GlobalValue *GV) const {} 185c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 186c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprotected: 187c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot virtual MCSection *SelectSectionForGlobal(const GlobalObject *GO, 188c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot SectionKind Kind, 189c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const TargetMachine &TM) const = 0; 190c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 191c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 192c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // end namespace llvm 193c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 194c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#endif // LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H 195