Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 1 | //===- llvm/CodeGen/AddressPool.h - Dwarf Debug Framework -------*- C++ -*-===// |
David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 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 Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 10 | #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H |
| 11 | #define LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H |
David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 12 | |
| 13 | #include "llvm/ADT/DenseMap.h" |
| 14 | |
| 15 | namespace llvm { |
Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 16 | |
David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 17 | class AsmPrinter; |
Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 18 | class MCSection; |
| 19 | class MCSymbol; |
| 20 | |
David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 21 | // Collection of addresses for this unit and assorted labels. |
| 22 | // A Symbol->unsigned mapping of addresses used by indirect |
| 23 | // references. |
| 24 | class AddressPool { |
| 25 | struct AddressPoolEntry { |
| 26 | unsigned Number; |
| 27 | bool TLS; |
Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 28 | |
David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 29 | AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {} |
| 30 | }; |
| 31 | DenseMap<const MCSymbol *, AddressPoolEntry> Pool; |
David Blaikie | b2133cb | 2014-04-28 22:52:50 +0000 | [diff] [blame] | 32 | |
| 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 Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 37 | bool HasBeenUsed = false; |
David Blaikie | 8fb87ee | 2014-04-23 21:20:07 +0000 | [diff] [blame] | 38 | |
David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 39 | public: |
Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 40 | AddressPool() = default; |
David Blaikie | e12b49a | 2014-04-26 17:27:38 +0000 | [diff] [blame] | 41 | |
Adrian Prantl | 5f8f34e4 | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 42 | /// Returns the index into the address pool with the given |
David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 43 | /// label/symbol. |
| 44 | unsigned getIndex(const MCSymbol *Sym, bool TLS = false); |
| 45 | |
Rafael Espindola | 0709a7b | 2015-05-21 19:20:38 +0000 | [diff] [blame] | 46 | void emit(AsmPrinter &Asm, MCSection *AddrSection); |
David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 47 | |
| 48 | bool isEmpty() { return Pool.empty(); } |
David Blaikie | e12b49a | 2014-04-26 17:27:38 +0000 | [diff] [blame] | 49 | |
| 50 | bool hasBeenUsed() const { return HasBeenUsed; } |
| 51 | |
| 52 | void resetUsedFlag() { HasBeenUsed = false; } |
Victor Leschuk | 64e0c56 | 2018-08-01 05:48:06 +0000 | [diff] [blame^] | 53 | |
| 54 | private: |
| 55 | void emitHeader(AsmPrinter &Asm, MCSection *Section); |
David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 56 | }; |
Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 57 | |
| 58 | } // end namespace llvm |
| 59 | |
| 60 | #endif // LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H |