17 #ifndef LLVM_CODEGEN_PBQP_COSTALLOCATOR_H 18 #define LLVM_CODEGEN_PBQP_COSTALLOCATOR_H 30 using PoolRef = std::shared_ptr<const ValueT>;
33 class PoolEntry :
public std::enable_shared_from_this<PoolEntry> {
35 template <
typename ValueKeyT>
37 : Pool(Pool),
Value(std::move(Value)) {}
39 ~PoolEntry() { Pool.removeEntry(
this); }
48 class PoolEntryDSInfo {
50 static inline PoolEntry *getEmptyKey() {
return nullptr; }
52 static inline PoolEntry *getTombstoneKey() {
53 return reinterpret_cast<PoolEntry *
>(
static_cast<uintptr_t
>(1));
56 template <
typename ValueKeyT>
57 static unsigned getHashValue(
const ValueKeyT &
C) {
61 static unsigned getHashValue(PoolEntry *
P) {
62 return getHashValue(P->getValue());
65 static unsigned getHashValue(
const PoolEntry *P) {
66 return getHashValue(P->getValue());
69 template <
typename ValueKeyT1,
typename ValueKeyT2>
70 static bool isEqual(
const ValueKeyT1 &C1,
const ValueKeyT2 &C2) {
74 template <
typename ValueKeyT>
75 static bool isEqual(
const ValueKeyT &C, PoolEntry *P) {
76 if (P == getEmptyKey() || P == getTombstoneKey())
78 return isEqual(C, P->getValue());
81 static bool isEqual(PoolEntry *P1, PoolEntry *P2) {
82 if (P1 == getEmptyKey() || P1 == getTombstoneKey())
84 return isEqual(P1->getValue(), P2);
92 void removeEntry(PoolEntry *
P) { EntrySet.
erase(P); }
98 if (I != EntrySet.
end())
99 return PoolRef((*I)->shared_from_this(), &(*I)->getValue());
101 auto P = std::make_shared<PoolEntry>(*
this, std::move(ValueKey));
103 return PoolRef(std::move(P), &P->getValue());
119 return VectorPool.getValue(std::move(v));
123 return MatrixPool.getValue(std::move(m));
134 #endif // LLVM_CODEGEN_PBQP_COSTALLOCATOR_H
This class represents lattice values for constants.
MatrixPtr getMatrix(MatrixKeyT m)
PoolRef getValue(ValueKeyT ValueKey)
bool erase(const ValueT &V)
typename MatrixCostPool::PoolRef MatrixPtr
std::pair< iterator, bool > insert(const ValueT &V)
iterator find_as(const LookupKeyT &Val)
Alternative version of find() which allows a different, and possibly less expensive, key type.
VectorPtr getVector(VectorKeyT v)
hash_code hash_value(const Vector &V)
Return a hash_value for the given vector.
std::shared_ptr< const AllowedRegVector > PoolRef
typename VectorCostPool::PoolRef VectorPtr
LLVM Value Representation.
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)