xref: /minix3/external/bsd/llvm/dist/llvm/lib/CodeGen/AsmPrinter/AddressPool.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc //===-- llvm/CodeGen/AddressPool.h - Dwarf Debug Framework -----*- C++ -*--===//
2*0a6a1f1dSLionel Sambuc //
3*0a6a1f1dSLionel Sambuc //                     The LLVM Compiler Infrastructure
4*0a6a1f1dSLionel Sambuc //
5*0a6a1f1dSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6*0a6a1f1dSLionel Sambuc // License. See LICENSE.TXT for details.
7*0a6a1f1dSLionel Sambuc //
8*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
9*0a6a1f1dSLionel Sambuc 
10*0a6a1f1dSLionel Sambuc #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
11*0a6a1f1dSLionel Sambuc #define LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
12*0a6a1f1dSLionel Sambuc 
13*0a6a1f1dSLionel Sambuc #include "llvm/ADT/DenseMap.h"
14*0a6a1f1dSLionel Sambuc 
15*0a6a1f1dSLionel Sambuc namespace llvm {
16*0a6a1f1dSLionel Sambuc class MCSection;
17*0a6a1f1dSLionel Sambuc class MCSymbol;
18*0a6a1f1dSLionel Sambuc class AsmPrinter;
19*0a6a1f1dSLionel Sambuc // Collection of addresses for this unit and assorted labels.
20*0a6a1f1dSLionel Sambuc // A Symbol->unsigned mapping of addresses used by indirect
21*0a6a1f1dSLionel Sambuc // references.
22*0a6a1f1dSLionel Sambuc class AddressPool {
23*0a6a1f1dSLionel Sambuc   struct AddressPoolEntry {
24*0a6a1f1dSLionel Sambuc     unsigned Number;
25*0a6a1f1dSLionel Sambuc     bool TLS;
AddressPoolEntryAddressPoolEntry26*0a6a1f1dSLionel Sambuc     AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {}
27*0a6a1f1dSLionel Sambuc   };
28*0a6a1f1dSLionel Sambuc   DenseMap<const MCSymbol *, AddressPoolEntry> Pool;
29*0a6a1f1dSLionel Sambuc 
30*0a6a1f1dSLionel Sambuc   /// Record whether the AddressPool has been queried for an address index since
31*0a6a1f1dSLionel Sambuc   /// the last "resetUsedFlag" call. Used to implement type unit fallback - a
32*0a6a1f1dSLionel Sambuc   /// type that references addresses cannot be placed in a type unit when using
33*0a6a1f1dSLionel Sambuc   /// fission.
34*0a6a1f1dSLionel Sambuc   bool HasBeenUsed;
35*0a6a1f1dSLionel Sambuc 
36*0a6a1f1dSLionel Sambuc public:
AddressPool()37*0a6a1f1dSLionel Sambuc   AddressPool() : HasBeenUsed(false) {}
38*0a6a1f1dSLionel Sambuc 
39*0a6a1f1dSLionel Sambuc   /// \brief Returns the index into the address pool with the given
40*0a6a1f1dSLionel Sambuc   /// label/symbol.
41*0a6a1f1dSLionel Sambuc   unsigned getIndex(const MCSymbol *Sym, bool TLS = false);
42*0a6a1f1dSLionel Sambuc 
43*0a6a1f1dSLionel Sambuc   void emit(AsmPrinter &Asm, const MCSection *AddrSection);
44*0a6a1f1dSLionel Sambuc 
isEmpty()45*0a6a1f1dSLionel Sambuc   bool isEmpty() { return Pool.empty(); }
46*0a6a1f1dSLionel Sambuc 
hasBeenUsed()47*0a6a1f1dSLionel Sambuc   bool hasBeenUsed() const { return HasBeenUsed; }
48*0a6a1f1dSLionel Sambuc 
resetUsedFlag()49*0a6a1f1dSLionel Sambuc   void resetUsedFlag() { HasBeenUsed = false; }
50*0a6a1f1dSLionel Sambuc };
51*0a6a1f1dSLionel Sambuc }
52*0a6a1f1dSLionel Sambuc #endif
53