LLVM  10.0.0svn
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 
24  unsigned Offset;
25  unsigned Index;
26 
27  bool isIndexed() const { return Index != NotIndexed; }
28 };
29 
30 /// String pool entry reference.
33  MapEntryAndIndexed;
34 
35  const StringMapEntry<DwarfStringPoolEntry> *getMapEntry() const {
36  return MapEntryAndIndexed.getPointer();
37  }
38 
39 public:
40  DwarfStringPoolEntryRef() = default;
42  bool Indexed)
43  : MapEntryAndIndexed(&Entry, Indexed) {}
44 
45  explicit operator bool() const { return getMapEntry(); }
46  MCSymbol *getSymbol() const {
47  assert(getMapEntry()->second.Symbol && "No symbol available!");
48  return getMapEntry()->second.Symbol;
49  }
50  unsigned getOffset() const { return getMapEntry()->second.Offset; }
51  bool isIndexed() const { return MapEntryAndIndexed.getInt(); }
52  unsigned getIndex() const {
53  assert(isIndexed());
54  assert(getMapEntry()->getValue().isIndexed());
55  return getMapEntry()->second.Index;
56  }
57  StringRef getString() const { return getMapEntry()->first(); }
58  /// Return the entire string pool entry for convenience.
59  DwarfStringPoolEntry getEntry() const { return getMapEntry()->getValue(); }
60 
61  bool operator==(const DwarfStringPoolEntryRef &X) const {
62  return getMapEntry() == X.getMapEntry();
63  }
64  bool operator!=(const DwarfStringPoolEntryRef &X) const {
65  return getMapEntry() != X.getMapEntry();
66  }
67 };
68 
69 } // end namespace llvm
70 
71 #endif
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This class represents lattice values for constants.
Definition: AllocatorList.h:23
PointerTy getPointer() const
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMap.h:158
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
unsigned second
DwarfStringPoolEntry getEntry() const
Return the entire string pool entry for convenience.
DwarfStringPoolEntryRef(const StringMapEntry< DwarfStringPoolEntry > &Entry, bool Indexed)
static constexpr unsigned NotIndexed
IntType getInt() const
Data for a string pool entry.
PointerIntPair - This class implements a pair of a pointer and small integer.
bool operator==(const DwarfStringPoolEntryRef &X) const
bool operator!=(const DwarfStringPoolEntryRef &X) const
String pool entry reference.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48