From 015e0c4bd3a20ede859cff852bce0b87249ce87a Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Sun, 26 Oct 2014 18:16:27 +0000 Subject: [PATCH] [PBQP] Tidy up CostAllocator.h: fix variable case, rename CostPool to ValuePool. No functional change. This just brings things more in-line with coding standards, and makes ValuePool's functionality clearer (it's not tied to pooling costs, and we may want to use it to hold other things in the future). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220641 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/PBQP/CostAllocator.h | 74 +++++++++++------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/include/llvm/CodeGen/PBQP/CostAllocator.h b/include/llvm/CodeGen/PBQP/CostAllocator.h index 8c86a700cf6..e8b99378273 100644 --- a/include/llvm/CodeGen/PBQP/CostAllocator.h +++ b/include/llvm/CodeGen/PBQP/CostAllocator.h @@ -25,24 +25,24 @@ namespace llvm { namespace PBQP { -template -class CostPool { +template +class ValuePool { public: - typedef std::shared_ptr PoolRef; + typedef std::shared_ptr PoolRef; private: class PoolEntry : public std::enable_shared_from_this { public: - template - PoolEntry(CostPool &pool, CostKeyT cost) - : pool(pool), cost(std::move(cost)) {} - ~PoolEntry() { pool.removeEntry(this); } - CostT& getCost() { return cost; } - const CostT& getCost() const { return cost; } + template + PoolEntry(ValuePool &Pool, ValueKeyT Value) + : Pool(Pool), Value(std::move(Value)) {} + ~PoolEntry() { Pool.removeEntry(this); } + ValueT& getValue() { return Value; } + const ValueT& getValue() const { return Value; } private: - CostPool &pool; - CostT cost; + ValuePool &Pool; + ValueT Value; }; class PoolEntryDSInfo { @@ -53,64 +53,64 @@ private: return reinterpret_cast(static_cast(1)); } - template - static unsigned getHashValue(const CostKeyT &C) { + template + static unsigned getHashValue(const ValueKeyT &C) { return hash_value(C); } static unsigned getHashValue(PoolEntry *P) { - return getHashValue(P->getCost()); + return getHashValue(P->getValue()); } static unsigned getHashValue(const PoolEntry *P) { - return getHashValue(P->getCost()); + return getHashValue(P->getValue()); } - template + template static - bool isEqual(const CostKeyT1 &C1, const CostKeyT2 &C2) { + bool isEqual(const ValueKeyT1 &C1, const ValueKeyT2 &C2) { return C1 == C2; } - template - static bool isEqual(const CostKeyT &C, PoolEntry *P) { + template + static bool isEqual(const ValueKeyT &C, PoolEntry *P) { if (P == getEmptyKey() || P == getTombstoneKey()) return false; - return isEqual(C, P->getCost()); + return isEqual(C, P->getValue()); } static bool isEqual(PoolEntry *P1, PoolEntry *P2) { if (P1 == getEmptyKey() || P1 == getTombstoneKey()) return P1 == P2; - return isEqual(P1->getCost(), P2); + return isEqual(P1->getValue(), P2); } }; - typedef DenseSet EntrySet; + typedef DenseSet EntrySetT; - EntrySet entrySet; + EntrySetT EntrySet; - void removeEntry(PoolEntry *p) { entrySet.erase(p); } + void removeEntry(PoolEntry *P) { EntrySet.erase(P); } public: - template PoolRef getCost(CostKeyT costKey) { - typename EntrySet::iterator itr = entrySet.find_as(costKey); + template PoolRef getValue(ValueKeyT ValueKey) { + typename EntrySetT::iterator I = EntrySet.find_as(ValueKey); - if (itr != entrySet.end()) - return PoolRef((*itr)->shared_from_this(), &(*itr)->getCost()); + if (I != EntrySet.end()) + return PoolRef((*I)->shared_from_this(), &(*I)->getValue()); - auto p = std::make_shared(*this, std::move(costKey)); - entrySet.insert(p.get()); - return PoolRef(std::move(p), &p->getCost()); + auto P = std::make_shared(*this, std::move(ValueKey)); + EntrySet.insert(P.get()); + return PoolRef(std::move(P), &P->getValue()); } }; template class PoolCostAllocator { private: - typedef CostPool VectorCostPool; - typedef CostPool MatrixCostPool; + typedef ValuePool VectorCostPool; + typedef ValuePool MatrixCostPool; public: typedef VectorT Vector; typedef MatrixT Matrix; @@ -118,13 +118,13 @@ public: typedef typename MatrixCostPool::PoolRef MatrixPtr; template - VectorPtr getVector(VectorKeyT v) { return vectorPool.getCost(std::move(v)); } + VectorPtr getVector(VectorKeyT v) { return VectorPool.getValue(std::move(v)); } template - MatrixPtr getMatrix(MatrixKeyT m) { return matrixPool.getCost(std::move(m)); } + MatrixPtr getMatrix(MatrixKeyT m) { return MatrixPool.getValue(std::move(m)); } private: - VectorCostPool vectorPool; - MatrixCostPool matrixPool; + VectorCostPool VectorPool; + MatrixCostPool MatrixPool; }; } // namespace PBQP -- 2.34.1