LLVM 22.0.0git
IndexedValuesMap.h
Go to the documentation of this file.
1//===- IndexedValuesMap.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_DWARFLINKER_INDEXEDVALUESMAP_H
10#define LLVM_DWARFLINKER_INDEXEDVALUESMAP_H
11
12#include "llvm/ADT/DenseMap.h"
14#include <cstdint>
15
16namespace llvm {
17namespace dwarf_linker {
18
19/// This class stores values sequentually and assigns index to the each value.
20template <typename T> class IndexedValuesMap {
21public:
23 auto [It, Inserted] = ValueToIndexMap.try_emplace(Value, Values.size());
24 if (Inserted)
25 Values.push_back(Value);
26 return It->second;
27 }
28
29 const SmallVector<T> &getValues() const { return Values; }
30
31 void clear() {
32 ValueToIndexMap.clear();
33 Values.clear();
34 }
35
36 bool empty() { return Values.empty(); }
37
38protected:
42};
43
44} // end of namespace dwarf_linker
45} // end of namespace llvm
46
47#endif // LLVM_DWARFLINKER_INDEXEDVALUESMAP_H
This file defines the DenseMap class.
#define T
This file defines the SmallVector class.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM Value Representation.
Definition Value.h:75
This class stores values sequentually and assigns index to the each value.
DenseMap< uint64_t, uint64_t > ValueToIndexMapTy
const SmallVector< T > & getValues() const
This is an optimization pass for GlobalISel generic memory operations.