LLVM 20.0.0git
NumberedValues.h
Go to the documentation of this file.
1//===-- NumberedValues.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_ASMPARSER_NUMBEREDVALUES_H
10#define LLVM_ASMPARSER_NUMBEREDVALUES_H
11
12#include "llvm/ADT/DenseMap.h"
13
14namespace llvm {
15
16/// Mapping from value ID to value, which also remembers what the next unused
17/// ID is.
18template <class T> class NumberedValues {
20 unsigned NextUnusedID = 0;
21
22public:
23 unsigned getNext() const { return NextUnusedID; }
24 T get(unsigned ID) const { return Vals.lookup(ID); }
25 void add(unsigned ID, T V) {
26 assert(ID >= NextUnusedID && "Invalid value ID");
27 Vals.insert({ID, V});
28 NextUnusedID = ID + 1;
29 }
30};
31
32} // end namespace llvm
33
34#endif
This file defines the DenseMap class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:194
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:211
Mapping from value ID to value, which also remembers what the next unused ID is.
T get(unsigned ID) const
unsigned getNext() const
void add(unsigned ID, T V)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18