blob: ba3e3b7c315d08eb124c98e3c75e3434a715573f [file] [log] [blame]
David Blaikiee226b082014-04-23 21:04:59 +00001//===-- 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
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"
Benjamin Kramer391be792016-01-27 19:29:56 +000014#include "llvm/MC/MCSymbol.h"
David Blaikiee226b082014-04-23 21:04:59 +000015
16namespace llvm {
17class MCSection;
David Blaikiee226b082014-04-23 21:04:59 +000018class AsmPrinter;
19// Collection of addresses for this unit and assorted labels.
20// A Symbol->unsigned mapping of addresses used by indirect
21// references.
22class AddressPool {
23 struct AddressPoolEntry {
24 unsigned Number;
25 bool TLS;
26 AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {}
27 };
28 DenseMap<const MCSymbol *, AddressPoolEntry> Pool;
David Blaikieb2133cb2014-04-28 22:52:50 +000029
30 /// Record whether the AddressPool has been queried for an address index since
31 /// the last "resetUsedFlag" call. Used to implement type unit fallback - a
32 /// type that references addresses cannot be placed in a type unit when using
33 /// fission.
David Blaikiee12b49a2014-04-26 17:27:38 +000034 bool HasBeenUsed;
David Blaikie8fb87ee2014-04-23 21:20:07 +000035
David Blaikiee226b082014-04-23 21:04:59 +000036public:
David Blaikiee12b49a2014-04-26 17:27:38 +000037 AddressPool() : HasBeenUsed(false) {}
38
David Blaikiee226b082014-04-23 21:04:59 +000039 /// \brief Returns the index into the address pool with the given
40 /// label/symbol.
41 unsigned getIndex(const MCSymbol *Sym, bool TLS = false);
42
Rafael Espindola0709a7b2015-05-21 19:20:38 +000043 void emit(AsmPrinter &Asm, MCSection *AddrSection);
David Blaikiee226b082014-04-23 21:04:59 +000044
45 bool isEmpty() { return Pool.empty(); }
David Blaikiee12b49a2014-04-26 17:27:38 +000046
47 bool hasBeenUsed() const { return HasBeenUsed; }
48
49 void resetUsedFlag() { HasBeenUsed = false; }
David Blaikiee226b082014-04-23 21:04:59 +000050};
Alexander Kornienkof00654e2015-06-23 09:49:53 +000051}
David Blaikiee226b082014-04-23 21:04:59 +000052#endif