1 //===- llvm/CodeGen/AddressPool.h - Dwarf Debug Framework -------*- 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 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
11 #define LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
13 #include "llvm/ADT/DenseMap.h"
21 // Collection of addresses for this unit and assorted labels.
22 // A Symbol->unsigned mapping of addresses used by indirect
25 struct AddressPoolEntry {
29 AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {}
31 DenseMap<const MCSymbol *, AddressPoolEntry> Pool;
33 /// Record whether the AddressPool has been queried for an address index since
34 /// the last "resetUsedFlag" call. Used to implement type unit fallback - a
35 /// type that references addresses cannot be placed in a type unit when using
37 bool HasBeenUsed = false;
40 AddressPool() = default;
42 /// Returns the index into the address pool with the given
44 unsigned getIndex(const MCSymbol *Sym, bool TLS = false);
46 void emit(AsmPrinter &Asm, MCSection *AddrSection);
48 bool isEmpty() { return Pool.empty(); }
50 bool hasBeenUsed() const { return HasBeenUsed; }
52 void resetUsedFlag() { HasBeenUsed = false; }
54 MCSymbol *getLabel() { return AddressTableBaseSym; }
55 void setLabel(MCSymbol *Sym) { AddressTableBaseSym = Sym; }
58 void emitHeader(AsmPrinter &Asm, MCSection *Section);
60 /// Symbol designates the start of the contribution to the address table.
61 MCSymbol *AddressTableBaseSym = nullptr;
64 } // end namespace llvm
66 #endif // LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H