LLVM 20.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#include <utility>
16
17namespace llvm {
18namespace dwarf_linker {
19
20/// This class stores values sequentually and assigns index to the each value.
21template <typename T> class IndexedValuesMap {
22public:
24 auto [It, Inserted] = ValueToIndexMap.try_emplace(Value, Values.size());
25 if (Inserted)
26 Values.push_back(Value);
27 return It->second;
28 }
29
30 const SmallVector<T> &getValues() const { return Values; }
31
32 void clear() {
34 Values.clear();
35 }
36
37 bool empty() { return Values.empty(); }
38
39protected:
43};
44
45} // end of namespace dwarf_linker
46} // end of namespace llvm
47
48#endif // LLVM_DWARFLINKER_INDEXEDVALUESMAP_H
This file defines the DenseMap class.
This file defines the SmallVector class.
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Definition: DenseMap.h:226
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
LLVM Value Representation.
Definition: Value.h:74
This class stores values sequentually and assigns index to the each value.
const SmallVector< T > & getValues() const
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18