AddressPool.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //===-- llvm/CodeGen/AddressPool.h - Dwarf Debug Framework -----*- 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. #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
  10. #define LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
  11. #include "llvm/ADT/DenseMap.h"
  12. namespace llvm {
  13. class MCSection;
  14. class MCSymbol;
  15. class AsmPrinter;
  16. // Collection of addresses for this unit and assorted labels.
  17. // A Symbol->unsigned mapping of addresses used by indirect
  18. // references.
  19. class AddressPool {
  20. struct AddressPoolEntry {
  21. unsigned Number;
  22. bool TLS;
  23. AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {}
  24. };
  25. DenseMap<const MCSymbol *, AddressPoolEntry> Pool;
  26. /// Record whether the AddressPool has been queried for an address index since
  27. /// the last "resetUsedFlag" call. Used to implement type unit fallback - a
  28. /// type that references addresses cannot be placed in a type unit when using
  29. /// fission.
  30. bool HasBeenUsed;
  31. public:
  32. AddressPool() : HasBeenUsed(false) {}
  33. /// \brief Returns the index into the address pool with the given
  34. /// label/symbol.
  35. unsigned getIndex(const MCSymbol *Sym, bool TLS = false);
  36. void emit(AsmPrinter &Asm, MCSection *AddrSection);
  37. bool isEmpty() { return Pool.empty(); }
  38. bool hasBeenUsed() const { return HasBeenUsed; }
  39. void resetUsedFlag() { HasBeenUsed = false; }
  40. };
  41. }
  42. #endif