LLVM  10.0.0svn
DWARFUnitIndex.h
Go to the documentation of this file.
1 //===- DWARFUnitIndex.h -----------------------------------------*- 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_DEBUGINFO_DWARF_DWARFUNITINDEX_H
10 #define LLVM_DEBUGINFO_DWARF_DWARFUNITINDEX_H
11 
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/StringRef.h"
15 #include <cstdint>
16 #include <memory>
17 
18 namespace llvm {
19 
20 class raw_ostream;
21 
31 };
32 
34  struct Header {
36  uint32_t NumColumns;
37  uint32_t NumUnits;
38  uint32_t NumBuckets = 0;
39 
40  bool parse(DataExtractor IndexData, uint64_t *OffsetPtr);
41  void dump(raw_ostream &OS) const;
42  };
43 
44 public:
45  class Entry {
46  public:
50  };
51 
52  private:
53  const DWARFUnitIndex *Index;
54  uint64_t Signature;
55  std::unique_ptr<SectionContribution[]> Contributions;
56  friend class DWARFUnitIndex;
57 
58  public:
60  const SectionContribution *getOffset() const;
61 
63  return Contributions.get();
64  }
65 
66  uint64_t getSignature() const { return Signature; }
67  };
68 
69 private:
70  struct Header Header;
71 
72  DWARFSectionKind InfoColumnKind;
73  int InfoColumn = -1;
74  std::unique_ptr<DWARFSectionKind[]> ColumnKinds;
75  std::unique_ptr<Entry[]> Rows;
76  mutable std::vector<Entry *> OffsetLookup;
77 
78  static StringRef getColumnHeader(DWARFSectionKind DS);
79 
80  bool parseImpl(DataExtractor IndexData);
81 
82 public:
84  : InfoColumnKind(InfoColumnKind) {}
85 
86  explicit operator bool() const { return Header.NumBuckets; }
87 
88  bool parse(DataExtractor IndexData);
89  void dump(raw_ostream &OS) const;
90 
91  const Entry *getFromOffset(uint32_t Offset) const;
92  const Entry *getFromHash(uint64_t Offset) const;
93 
95  return makeArrayRef(ColumnKinds.get(), Header.NumColumns);
96  }
97 
99  return makeArrayRef(Rows.get(), Header.NumBuckets);
100  }
101 };
102 
103 } // end namespace llvm
104 
105 #endif // LLVM_DEBUGINFO_DWARF_DWARFUNITINDEX_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
ArrayRef< DWARFSectionKind > getColumnKinds() const
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:450
ArrayRef< Entry > getRows() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
static Error getOffset(const SymbolRef &Sym, SectionRef Sec, uint64_t &Result)
const SectionContribution * getOffsets() const
DWARFSectionKind
DWARFUnitIndex(DWARFSectionKind InfoColumnKind)
void dump(raw_ostream &OS) const
const Entry * getFromHash(uint64_t Offset) const
const Entry * getFromOffset(uint32_t Offset) const
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
bool parse(DataExtractor IndexData)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
uint64_t getSignature() const
const uint64_t Version
Definition: InstrProf.h:984