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>
39 ~PoolEntry() { Pool.removeEntry(
this); }
48 class PoolEntryDSInfo {
50 static inline PoolEntry *getEmptyKey() {
return nullptr; }
52 template <
typename ValueKeyT>
53 static unsigned getHashValue(
const ValueKeyT &
C) {
57 static unsigned getHashValue(PoolEntry *
P) {
58 return getHashValue(
P->getValue());
61 static unsigned getHashValue(
const PoolEntry *
P) {
62 return getHashValue(
P->getValue());
65 template <
typename ValueKeyT1,
typename ValueKeyT2>
66 static bool isEqual(
const ValueKeyT1 &C1,
const ValueKeyT2 &C2) {
70 template <
typename ValueKeyT>
71 static bool isEqual(
const ValueKeyT &
C, PoolEntry *
P) {
72 if (
P == getEmptyKey())
74 return isEqual(
C,
P->getValue());
77 static bool isEqual(PoolEntry *P1, PoolEntry *P2) {
78 if (P1 == getEmptyKey())
80 return isEqual(
P1->getValue(), P2);
84 using EntrySetT = DenseSet<PoolEntry *, PoolEntryDSInfo>;
88 void removeEntry(PoolEntry *
P) { EntrySet.erase(
P); }
94 if (
I != EntrySet.end())
95 return PoolRef((*I)->shared_from_this(), &(*I)->getValue());
97 auto P = std::make_shared<PoolEntry>(*
this, std::move(ValueKey));
98 EntrySet.insert(
P.get());
115 return VectorPool.getValue(std::move(v));
119 return MatrixPool.getValue(std::move(m));
123 VectorCostPool VectorPool;
124 MatrixCostPool MatrixPool;
This file defines the DenseSet and SmallDenseSet classes.
VectorPtr getVector(VectorKeyT v)
typename MatrixCostPool::PoolRef MatrixPtr
MatrixPtr getMatrix(MatrixKeyT m)
typename VectorCostPool::PoolRef VectorPtr
PoolRef getValue(ValueKeyT ValueKey)
std::shared_ptr< const ValueT > PoolRef
LLVM Value Representation.
DenseSetIterator< false > iterator
@ C
The default llvm calling convention, compatible with C.
hash_code hash_value(const Vector &V)
Return a hash_value for the given vector.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value