LLVM  15.0.0git
DwarfStringPoolEntry.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/DwarfStringPoolEntry.h - String pool entry --*- 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_CODEGEN_DWARFSTRINGPOOLENTRY_H
10 #define LLVM_CODEGEN_DWARFSTRINGPOOLENTRY_H
11 
13 #include "llvm/ADT/StringMap.h"
14 
15 namespace llvm {
16 
17 class MCSymbol;
18 
19 /// Data for a string pool entry.
21  static constexpr unsigned NotIndexed = -1;
22 
25  unsigned Index;
26 
27  bool isIndexed() const { return Index != NotIndexed; }
28 };
29 
30 /// String pool entry reference.
32  const StringMapEntry<DwarfStringPoolEntry> *MapEntry = nullptr;
33 
34  const StringMapEntry<DwarfStringPoolEntry> *getMapEntry() const {
35  return MapEntry;
36  }
37 
38 public:
39  DwarfStringPoolEntryRef() = default;
41  : MapEntry(&Entry) {}
42 
43  explicit operator bool() const { return getMapEntry(); }
44  MCSymbol *getSymbol() const {
45  assert(getMapEntry()->second.Symbol && "No symbol available!");
46  return getMapEntry()->second.Symbol;
47  }
48  uint64_t getOffset() const { return getMapEntry()->second.Offset; }
49  unsigned getIndex() const {
50  assert(getMapEntry()->getValue().isIndexed());
51  return getMapEntry()->second.Index;
52  }
53  StringRef getString() const { return getMapEntry()->first(); }
54  /// Return the entire string pool entry for convenience.
55  DwarfStringPoolEntry getEntry() const { return getMapEntry()->getValue(); }
56 
57  bool operator==(const DwarfStringPoolEntryRef &X) const {
58  return getMapEntry() == X.getMapEntry();
59  }
60  bool operator!=(const DwarfStringPoolEntryRef &X) const {
61  return getMapEntry() != X.getMapEntry();
62  }
63 };
64 
65 } // end namespace llvm
66 
67 #endif
llvm::DwarfStringPoolEntryRef::DwarfStringPoolEntryRef
DwarfStringPoolEntryRef(const StringMapEntry< DwarfStringPoolEntry > &Entry)
Definition: DwarfStringPoolEntry.h:40
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::StringMapEntry
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMapEntry.h:101
llvm::DwarfStringPoolEntry::isIndexed
bool isIndexed() const
Definition: DwarfStringPoolEntry.h:27
llvm::DwarfStringPoolEntryRef
String pool entry reference.
Definition: DwarfStringPoolEntry.h:31
llvm::DwarfStringPoolEntry::Offset
uint64_t Offset
Definition: DwarfStringPoolEntry.h:24
PointerIntPair.h
llvm::DwarfStringPoolEntry::NotIndexed
static constexpr unsigned NotIndexed
Definition: DwarfStringPoolEntry.h:21
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::DwarfStringPoolEntryRef::DwarfStringPoolEntryRef
DwarfStringPoolEntryRef()=default
StringMap.h
llvm::DwarfStringPoolEntryRef::getString
StringRef getString() const
Definition: DwarfStringPoolEntry.h:53
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
llvm::DwarfStringPoolEntry
Data for a string pool entry.
Definition: DwarfStringPoolEntry.h:20
uint64_t
llvm::DwarfStringPoolEntryRef::getOffset
uint64_t getOffset() const
Definition: DwarfStringPoolEntry.h:48
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::DwarfStringPoolEntryRef::getSymbol
MCSymbol * getSymbol() const
Definition: DwarfStringPoolEntry.h:44
llvm::DwarfStringPoolEntry::Symbol
MCSymbol * Symbol
Definition: DwarfStringPoolEntry.h:23
llvm::DwarfStringPoolEntryRef::getIndex
unsigned getIndex() const
Definition: DwarfStringPoolEntry.h:49
llvm::DwarfStringPoolEntryRef::operator!=
bool operator!=(const DwarfStringPoolEntryRef &X) const
Definition: DwarfStringPoolEntry.h:60
llvm::DwarfStringPoolEntryRef::getEntry
DwarfStringPoolEntry getEntry() const
Return the entire string pool entry for convenience.
Definition: DwarfStringPoolEntry.h:55
llvm::DwarfStringPoolEntryRef::operator==
bool operator==(const DwarfStringPoolEntryRef &X) const
Definition: DwarfStringPoolEntry.h:57
llvm::DwarfStringPoolEntry::Index
unsigned Index
Definition: DwarfStringPoolEntry.h:25
llvm::ISD::MCSymbol
@ MCSymbol
Definition: ISDOpcodes.h:172