David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 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 | |
| 10 | #ifndef CODEGEN_ASMPRINTER_ADDRESSPOOL_H__ |
| 11 | #define CODEGEN_ASMPRINTER_ADDRESSPOOL_H__ |
| 12 | |
| 13 | #include "llvm/ADT/DenseMap.h" |
| 14 | |
| 15 | namespace llvm { |
| 16 | class MCSection; |
| 17 | class MCSymbol; |
| 18 | class AsmPrinter; |
| 19 | // Collection of addresses for this unit and assorted labels. |
| 20 | // A Symbol->unsigned mapping of addresses used by indirect |
| 21 | // references. |
| 22 | class 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 Blaikie | e12b49a | 2014-04-26 17:27:38 +0000 | [diff] [blame^] | 29 | bool HasBeenUsed; |
David Blaikie | 8fb87ee | 2014-04-23 21:20:07 +0000 | [diff] [blame] | 30 | |
David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 31 | public: |
David Blaikie | e12b49a | 2014-04-26 17:27:38 +0000 | [diff] [blame^] | 32 | AddressPool() : HasBeenUsed(false) {} |
| 33 | |
David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 34 | /// \brief Returns the index into the address pool with the given |
| 35 | /// label/symbol. |
| 36 | unsigned getIndex(const MCSymbol *Sym, bool TLS = false); |
| 37 | |
| 38 | void emit(AsmPrinter &Asm, const MCSection *AddrSection); |
| 39 | |
| 40 | bool isEmpty() { return Pool.empty(); } |
David Blaikie | e12b49a | 2014-04-26 17:27:38 +0000 | [diff] [blame^] | 41 | |
| 42 | bool hasBeenUsed() const { return HasBeenUsed; } |
| 43 | |
| 44 | void resetUsedFlag() { HasBeenUsed = false; } |
David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 45 | }; |
| 46 | } |
| 47 | #endif |