[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / llvm / lib / CodeGen / AsmPrinter / AddressPool.h
blobf1edc6c330d51e4de89332f615cbe48beced1fc8
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
10 #define LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
12 #include "llvm/ADT/DenseMap.h"
14 namespace llvm {
16 class AsmPrinter;
17 class MCSection;
18 class MCSymbol;
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;
28 AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {}
30 DenseMap<const MCSymbol *, AddressPoolEntry> Pool;
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;
38 public:
39 AddressPool() = default;
41 /// Returns the index into the address pool with the given
42 /// label/symbol.
43 unsigned getIndex(const MCSymbol *Sym, bool TLS = false);
45 void emit(AsmPrinter &Asm, MCSection *AddrSection);
47 bool isEmpty() { return Pool.empty(); }
49 bool hasBeenUsed() const { return HasBeenUsed; }
51 void resetUsedFlag(bool HasBeenUsed = false) { this->HasBeenUsed = HasBeenUsed; }
53 MCSymbol *getLabel() { return AddressTableBaseSym; }
54 void setLabel(MCSymbol *Sym) { AddressTableBaseSym = Sym; }
56 private:
57 MCSymbol *emitHeader(AsmPrinter &Asm, MCSection *Section);
59 /// Symbol designates the start of the contribution to the address table.
60 MCSymbol *AddressTableBaseSym = nullptr;
63 } // end namespace llvm
65 #endif // LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H