Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:20

0001 //===-- NumberedValues.h - --------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_ASMPARSER_NUMBEREDVALUES_H
0010 #define LLVM_ASMPARSER_NUMBEREDVALUES_H
0011 
0012 #include "llvm/ADT/DenseMap.h"
0013 
0014 namespace llvm {
0015 
0016 /// Mapping from value ID to value, which also remembers what the next unused
0017 /// ID is.
0018 template <class T> class NumberedValues {
0019   DenseMap<unsigned, T> Vals;
0020   unsigned NextUnusedID = 0;
0021 
0022 public:
0023   unsigned getNext() const { return NextUnusedID; }
0024   T get(unsigned ID) const { return Vals.lookup(ID); }
0025   void add(unsigned ID, T V) {
0026     assert(ID >= NextUnusedID && "Invalid value ID");
0027     Vals.insert({ID, V});
0028     NextUnusedID = ID + 1;
0029   }
0030 };
0031 
0032 } // end namespace llvm
0033 
0034 #endif