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