[InstCombine] Signed saturation patterns
[llvm-complete.git] / include / llvm / CodeGen / DwarfStringPoolEntry.h
blobe189352a7b2d8627e12096082f1b9a4f337bd91e
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CODEGEN_DWARFSTRINGPOOLENTRY_H
10 #define LLVM_CODEGEN_DWARFSTRINGPOOLENTRY_H
12 #include "llvm/ADT/PointerIntPair.h"
13 #include "llvm/ADT/StringMap.h"
15 namespace llvm {
17 class MCSymbol;
19 /// Data for a string pool entry.
20 struct DwarfStringPoolEntry {
21 static constexpr unsigned NotIndexed = -1;
23 MCSymbol *Symbol;
24 unsigned Offset;
25 unsigned Index;
27 bool isIndexed() const { return Index != NotIndexed; }
30 /// String pool entry reference.
31 class DwarfStringPoolEntryRef {
32 PointerIntPair<const StringMapEntry<DwarfStringPoolEntry> *, 1, bool>
33 MapEntryAndIndexed;
35 const StringMapEntry<DwarfStringPoolEntry> *getMapEntry() const {
36 return MapEntryAndIndexed.getPointer();
39 public:
40 DwarfStringPoolEntryRef() = default;
41 DwarfStringPoolEntryRef(const StringMapEntry<DwarfStringPoolEntry> &Entry,
42 bool Indexed)
43 : MapEntryAndIndexed(&Entry, Indexed) {}
45 explicit operator bool() const { return getMapEntry(); }
46 MCSymbol *getSymbol() const {
47 assert(getMapEntry()->second.Symbol && "No symbol available!");
48 return getMapEntry()->second.Symbol;
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;
57 StringRef getString() const { return getMapEntry()->first(); }
58 /// Return the entire string pool entry for convenience.
59 DwarfStringPoolEntry getEntry() const { return getMapEntry()->getValue(); }
61 bool operator==(const DwarfStringPoolEntryRef &X) const {
62 return getMapEntry() == X.getMapEntry();
64 bool operator!=(const DwarfStringPoolEntryRef &X) const {
65 return getMapEntry() != X.getMapEntry();
69 } // end namespace llvm
71 #endif