LLVM  14.0.0git
AddressPool.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/AddressPool.h - Dwarf Debug Framework -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
10 #define LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
11 
12 #include "llvm/ADT/DenseMap.h"
13 
14 namespace llvm {
15 
16 class AsmPrinter;
17 class MCSection;
18 class MCSymbol;
19 
20 // Collection of addresses for this unit and assorted labels.
21 // A Symbol->unsigned mapping of addresses used by indirect
22 // references.
23 class AddressPool {
24  struct AddressPoolEntry {
25  unsigned Number;
26  bool TLS;
27 
28  AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {}
29  };
31 
32  /// Record whether the AddressPool has been queried for an address index since
33  /// the last "resetUsedFlag" call. Used to implement type unit fallback - a
34  /// type that references addresses cannot be placed in a type unit when using
35  /// fission.
36  bool HasBeenUsed = false;
37 
38 public:
39  AddressPool() = default;
40 
41  /// Returns the index into the address pool with the given
42  /// label/symbol.
43  unsigned getIndex(const MCSymbol *Sym, bool TLS = false);
44 
45  void emit(AsmPrinter &Asm, MCSection *AddrSection);
46 
47  bool isEmpty() { return Pool.empty(); }
48 
49  bool hasBeenUsed() const { return HasBeenUsed; }
50 
51  void resetUsedFlag(bool HasBeenUsed = false) { this->HasBeenUsed = HasBeenUsed; }
52 
53  MCSymbol *getLabel() { return AddressTableBaseSym; }
54  void setLabel(MCSymbol *Sym) { AddressTableBaseSym = Sym; }
55 
56 private:
57  MCSymbol *emitHeader(AsmPrinter &Asm, MCSection *Section);
58 
59  /// Symbol designates the start of the contribution to the address table.
60  MCSymbol *AddressTableBaseSym = nullptr;
61 };
62 
63 } // end namespace llvm
64 
65 #endif // LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::AddressPool::resetUsedFlag
void resetUsedFlag(bool HasBeenUsed=false)
Definition: AddressPool.h:51
DenseMap.h
llvm::AddressPool::isEmpty
bool isEmpty()
Definition: AddressPool.h:47
llvm::AddressPool::setLabel
void setLabel(MCSymbol *Sym)
Definition: AddressPool.h:54
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:78
llvm::AddressPool::AddressPool
AddressPool()=default
llvm::DenseMap
Definition: DenseMap.h:714
llvm::AddressPool::hasBeenUsed
bool hasBeenUsed() const
Definition: AddressPool.h:49
llvm::AddressPool::emit
void emit(AsmPrinter &Asm, MCSection *AddrSection)
Definition: AddressPool.cpp:42
Number
uint32_t Number
Definition: Profile.cpp:47
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::empty
LLVM_NODISCARD bool empty() const
Definition: DenseMap.h:97
llvm::AddressPool
Definition: AddressPool.h:23
llvm::AddressPool::getLabel
MCSymbol * getLabel()
Definition: AddressPool.h:53
llvm::AsmPrinter
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:82
llvm::AddressPool::getIndex
unsigned getIndex(const MCSymbol *Sym, bool TLS=false)
Returns the index into the address pool with the given label/symbol.
Definition: AddressPool.cpp:19
llvm::HexStyle::Asm
@ Asm
0ffh
Definition: MCInstPrinter.h:34
llvm::ISD::MCSymbol
@ MCSymbol
Definition: ISDOpcodes.h:172