1*0b57cec5SDimitry Andric //===- llvm/CodeGen/AddressPool.h - Dwarf Debug Framework -------*- C++ -*-===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H 10*0b57cec5SDimitry Andric #define LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H 11*0b57cec5SDimitry Andric 12*0b57cec5SDimitry Andric #include "llvm/ADT/DenseMap.h" 13*0b57cec5SDimitry Andric 14*0b57cec5SDimitry Andric namespace llvm { 15*0b57cec5SDimitry Andric 16*0b57cec5SDimitry Andric class AsmPrinter; 17*0b57cec5SDimitry Andric class MCSection; 18*0b57cec5SDimitry Andric class MCSymbol; 19*0b57cec5SDimitry Andric 20*0b57cec5SDimitry Andric // Collection of addresses for this unit and assorted labels. 21*0b57cec5SDimitry Andric // A Symbol->unsigned mapping of addresses used by indirect 22*0b57cec5SDimitry Andric // references. 23*0b57cec5SDimitry Andric class AddressPool { 24*0b57cec5SDimitry Andric struct AddressPoolEntry { 25*0b57cec5SDimitry Andric unsigned Number; 26*0b57cec5SDimitry Andric bool TLS; 27*0b57cec5SDimitry Andric 28*0b57cec5SDimitry Andric AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {} 29*0b57cec5SDimitry Andric }; 30*0b57cec5SDimitry Andric DenseMap<const MCSymbol *, AddressPoolEntry> Pool; 31*0b57cec5SDimitry Andric 32*0b57cec5SDimitry Andric /// Record whether the AddressPool has been queried for an address index since 33*0b57cec5SDimitry Andric /// the last "resetUsedFlag" call. Used to implement type unit fallback - a 34*0b57cec5SDimitry Andric /// type that references addresses cannot be placed in a type unit when using 35*0b57cec5SDimitry Andric /// fission. 36*0b57cec5SDimitry Andric bool HasBeenUsed = false; 37*0b57cec5SDimitry Andric 38*0b57cec5SDimitry Andric public: 39*0b57cec5SDimitry Andric AddressPool() = default; 40*0b57cec5SDimitry Andric 41*0b57cec5SDimitry Andric /// Returns the index into the address pool with the given 42*0b57cec5SDimitry Andric /// label/symbol. 43*0b57cec5SDimitry Andric unsigned getIndex(const MCSymbol *Sym, bool TLS = false); 44*0b57cec5SDimitry Andric 45*0b57cec5SDimitry Andric void emit(AsmPrinter &Asm, MCSection *AddrSection); 46*0b57cec5SDimitry Andric 47*0b57cec5SDimitry Andric bool isEmpty() { return Pool.empty(); } 48*0b57cec5SDimitry Andric 49*0b57cec5SDimitry Andric bool hasBeenUsed() const { return HasBeenUsed; } 50*0b57cec5SDimitry Andric 51*0b57cec5SDimitry Andric void resetUsedFlag() { HasBeenUsed = false; } 52*0b57cec5SDimitry Andric 53*0b57cec5SDimitry Andric MCSymbol *getLabel() { return AddressTableBaseSym; } 54*0b57cec5SDimitry Andric void setLabel(MCSymbol *Sym) { AddressTableBaseSym = Sym; } 55*0b57cec5SDimitry Andric 56*0b57cec5SDimitry Andric private: 57*0b57cec5SDimitry Andric MCSymbol *emitHeader(AsmPrinter &Asm, MCSection *Section); 58*0b57cec5SDimitry Andric 59*0b57cec5SDimitry Andric /// Symbol designates the start of the contribution to the address table. 60*0b57cec5SDimitry Andric MCSymbol *AddressTableBaseSym = nullptr; 61*0b57cec5SDimitry Andric }; 62*0b57cec5SDimitry Andric 63*0b57cec5SDimitry Andric } // end namespace llvm 64*0b57cec5SDimitry Andric 65*0b57cec5SDimitry Andric #endif // LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H 66