LLVM 19.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:
25 if (It == ValueToIndexMap.end()) {
26 It = ValueToIndexMap.insert(std::make_pair(Value, Values.size())).first;
27 Values.push_back(Value);
28 }
29 return It->second;
30 }
31
32 const SmallVector<T> &getValues() const { return Values; }
33
34 void clear() {
36 Values.clear();
37 }
38
39 bool empty() { return Values.empty(); }
40
41protected:
45};
46
47} // end of namespace dwarf_linker
48} // end of namespace llvm
49
50#endif // LLVM_DWARFLINKER_INDEXEDVALUESMAP_H
This file defines the DenseMap class.
This file defines the SmallVector class.
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:155
iterator end()
Definition: DenseMap.h:84
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:220
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
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