18 #ifndef LLVM_CODEGEN_PBQP_COSTALLOCATOR_H 19 #define LLVM_CODEGEN_PBQP_COSTALLOCATOR_H 31 using PoolRef = std::shared_ptr<const ValueT>;
34 class PoolEntry :
public std::enable_shared_from_this<PoolEntry> {
36 template <
typename ValueKeyT>
38 : Pool(Pool), Value(std::move(Value)) {}
40 ~PoolEntry() { Pool.removeEntry(
this); }
49 class PoolEntryDSInfo {
51 static inline PoolEntry *getEmptyKey() {
return nullptr; }
53 static inline PoolEntry *getTombstoneKey() {
54 return reinterpret_cast<PoolEntry *
>(
static_cast<uintptr_t
>(1));
57 template <
typename ValueKeyT>
58 static unsigned getHashValue(
const ValueKeyT &
C) {
62 static unsigned getHashValue(PoolEntry *
P) {
63 return getHashValue(P->getValue());
66 static unsigned getHashValue(
const PoolEntry *P) {
67 return getHashValue(P->getValue());
70 template <
typename ValueKeyT1,
typename ValueKeyT2>
71 static bool isEqual(
const ValueKeyT1 &C1,
const ValueKeyT2 &C2) {
75 template <
typename ValueKeyT>
76 static bool isEqual(
const ValueKeyT &C, PoolEntry *P) {
77 if (P == getEmptyKey() || P == getTombstoneKey())
79 return isEqual(C, P->getValue());
82 static bool isEqual(PoolEntry *P1, PoolEntry *P2) {
83 if (P1 == getEmptyKey() || P1 == getTombstoneKey())
85 return isEqual(P1->getValue(), P2);
93 void removeEntry(PoolEntry *
P) { EntrySet.
erase(P); }
99 if (I != EntrySet.
end())
100 return PoolRef((*I)->shared_from_this(), &(*I)->getValue());
102 auto P = std::make_shared<PoolEntry>(*
this, std::move(ValueKey));
104 return PoolRef(std::move(P), &P->getValue());
120 return VectorPool.getValue(std::move(v));
124 return MatrixPool.getValue(std::move(m));
135 #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
static bool isEqual(const Function &Caller, const Function &Callee)
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.