LLVM  8.0.1
AddressPool.h
Go to the documentation of this file.
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 
10 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
11 #define LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
12 
13 #include "llvm/ADT/DenseMap.h"
14 
15 namespace llvm {
16 
17 class AsmPrinter;
18 class MCSection;
19 class MCSymbol;
20 
21 // Collection of addresses for this unit and assorted labels.
22 // A Symbol->unsigned mapping of addresses used by indirect
23 // references.
24 class AddressPool {
25  struct AddressPoolEntry {
26  unsigned Number;
27  bool TLS;
28 
29  AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {}
30  };
32 
33  /// Record whether the AddressPool has been queried for an address index since
34  /// the last "resetUsedFlag" call. Used to implement type unit fallback - a
35  /// type that references addresses cannot be placed in a type unit when using
36  /// fission.
37  bool HasBeenUsed = false;
38 
39 public:
40  AddressPool() = default;
41 
42  /// Returns the index into the address pool with the given
43  /// label/symbol.
44  unsigned getIndex(const MCSymbol *Sym, bool TLS = false);
45 
46  void emit(AsmPrinter &Asm, MCSection *AddrSection);
47 
48  bool isEmpty() { return Pool.empty(); }
49 
50  bool hasBeenUsed() const { return HasBeenUsed; }
51 
52  void resetUsedFlag() { HasBeenUsed = false; }
53 
54  MCSymbol *getLabel() { return AddressTableBaseSym; }
55  void setLabel(MCSymbol *Sym) { AddressTableBaseSym = Sym; }
56 
57 private:
58  void emitHeader(AsmPrinter &Asm, MCSection *Section);
59 
60  /// Symbol designates the start of the contribution to the address table.
61  MCSymbol *AddressTableBaseSym = nullptr;
62 };
63 
64 } // end namespace llvm
65 
66 #endif // LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
void setLabel(MCSymbol *Sym)
Definition: AddressPool.h:55
This class represents lattice values for constants.
Definition: AllocatorList.h:24
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
void emit(AsmPrinter &Asm, MCSection *AddrSection)
Definition: AddressPool.cpp:45
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:79
MCSymbol * getLabel()
Definition: AddressPool.h:54
void resetUsedFlag()
Definition: AddressPool.h:52
AddressPool()=default
bool hasBeenUsed() const
Definition: AddressPool.h:50
unsigned getIndex(const MCSymbol *Sym, bool TLS=false)
Returns the index into the address pool with the given label/symbol.
Definition: AddressPool.cpp:20