| 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 |  | 
| 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" | 
| Benjamin Kramer | 391be79 | 2016-01-27 19:29:56 +0000 | [diff] [blame] | 14 | #include "llvm/MC/MCSymbol.h" | 
| David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 15 |  | 
|  | 16 | namespace llvm { | 
|  | 17 | class MCSection; | 
| David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 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 | b2133cb | 2014-04-28 22:52:50 +0000 | [diff] [blame] | 29 |  | 
|  | 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 Blaikie | e12b49a | 2014-04-26 17:27:38 +0000 | [diff] [blame] | 34 | bool HasBeenUsed; | 
| David Blaikie | 8fb87ee | 2014-04-23 21:20:07 +0000 | [diff] [blame] | 35 |  | 
| David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 36 | public: | 
| David Blaikie | e12b49a | 2014-04-26 17:27:38 +0000 | [diff] [blame] | 37 | AddressPool() : HasBeenUsed(false) {} | 
|  | 38 |  | 
| David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 39 | /// \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 Espindola | 0709a7b | 2015-05-21 19:20:38 +0000 | [diff] [blame] | 43 | void emit(AsmPrinter &Asm, MCSection *AddrSection); | 
| David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 44 |  | 
|  | 45 | bool isEmpty() { return Pool.empty(); } | 
| David Blaikie | e12b49a | 2014-04-26 17:27:38 +0000 | [diff] [blame] | 46 |  | 
|  | 47 | bool hasBeenUsed() const { return HasBeenUsed; } | 
|  | 48 |  | 
|  | 49 | void resetUsedFlag() { HasBeenUsed = false; } | 
| David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 50 | }; | 
| Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 51 | } | 
| David Blaikie | e226b08 | 2014-04-23 21:04:59 +0000 | [diff] [blame] | 52 | #endif |