blob: 990a158d87cd23d80daa2444d8f1a3a78c98f74d [file] [log] [blame]
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +00001//===- llvm/CodeGen/AddressPool.h - Dwarf Debug Framework -------*- C++ -*-===//
David Blaikiee226b082014-04-23 21:04:59 +00002//
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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000010#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
11#define LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
David Blaikiee226b082014-04-23 21:04:59 +000012
13#include "llvm/ADT/DenseMap.h"
14
15namespace llvm {
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000016
David Blaikiee226b082014-04-23 21:04:59 +000017class AsmPrinter;
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000018class MCSection;
19class MCSymbol;
20
David Blaikiee226b082014-04-23 21:04:59 +000021// Collection of addresses for this unit and assorted labels.
22// A Symbol->unsigned mapping of addresses used by indirect
23// references.
24class AddressPool {
25 struct AddressPoolEntry {
26 unsigned Number;
27 bool TLS;
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000028
David Blaikiee226b082014-04-23 21:04:59 +000029 AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {}
30 };
31 DenseMap<const MCSymbol *, AddressPoolEntry> Pool;
David Blaikieb2133cb2014-04-28 22:52:50 +000032
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
36 /// fission.
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000037 bool HasBeenUsed = false;
David Blaikie8fb87ee2014-04-23 21:20:07 +000038
David Blaikiee226b082014-04-23 21:04:59 +000039public:
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000040 AddressPool() = default;
David Blaikiee12b49a2014-04-26 17:27:38 +000041
David Blaikiee226b082014-04-23 21:04:59 +000042 /// \brief Returns the index into the address pool with the given
43 /// label/symbol.
44 unsigned getIndex(const MCSymbol *Sym, bool TLS = false);
45
Rafael Espindola0709a7b2015-05-21 19:20:38 +000046 void emit(AsmPrinter &Asm, MCSection *AddrSection);
David Blaikiee226b082014-04-23 21:04:59 +000047
48 bool isEmpty() { return Pool.empty(); }
David Blaikiee12b49a2014-04-26 17:27:38 +000049
50 bool hasBeenUsed() const { return HasBeenUsed; }
51
52 void resetUsedFlag() { HasBeenUsed = false; }
David Blaikiee226b082014-04-23 21:04:59 +000053};
Eugene Zelenko6e07bfd2017-08-17 21:26:39 +000054
55} // end namespace llvm
56
57#endif // LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H