mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:43:36 +01:00
50ffa1ab38
This reverts commit 1d542f0ca83fa1411d6501a8d088450d83abd5b8. `recollectUses()` is added to prevent looking at dead uses after Attributor run. This is the first and most basic ICV Tracking implementation. For this first version, we only support deduplication within the same BB. Reviewers: jdoerfert, JonChesterfield, hamax97, jhuber6, uenoku, baziotis, lebedev.ri Differential Revision: https://reviews.llvm.org/D81788
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
//===- llvm/ADT/EnumeratedArray.h - Enumerated Array-------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines an array type that can be indexed using scoped enum values.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_ADT_ENUMERATEDARRAY_H
|
|
#define LLVM_ADT_ENUMERATEDARRAY_H
|
|
|
|
#include <cassert>
|
|
|
|
namespace llvm {
|
|
|
|
template <typename ValueType, typename Enumeration,
|
|
Enumeration LargestEnum = Enumeration::Last, typename IndexType = int,
|
|
IndexType Size = 1 + static_cast<IndexType>(LargestEnum)>
|
|
class EnumeratedArray {
|
|
public:
|
|
EnumeratedArray() = default;
|
|
EnumeratedArray(ValueType V) {
|
|
for (IndexType IX = 0; IX < Size; ++IX) {
|
|
Underlying[IX] = V;
|
|
}
|
|
}
|
|
inline const ValueType &operator[](const Enumeration Index) const {
|
|
auto IX = static_cast<const IndexType>(Index);
|
|
assert(IX >= 0 && IX < Size && "Index is out of bounds.");
|
|
return Underlying[IX];
|
|
}
|
|
inline ValueType &operator[](const Enumeration Index) {
|
|
return const_cast<ValueType &>(
|
|
static_cast<const EnumeratedArray<ValueType, Enumeration, LargestEnum,
|
|
IndexType, Size> &>(*this)[Index]);
|
|
}
|
|
inline IndexType size() { return Size; }
|
|
|
|
private:
|
|
ValueType Underlying[Size];
|
|
};
|
|
|
|
} // namespace llvm
|
|
|
|
#endif // LLVM_ADT_ENUMERATEDARRAY_H
|