mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 04:30:12 +00:00
FoldingSet: Push the hash through FoldingSetTraits::Equals, so clients can use it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154496 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7484920cf5
commit
f7c3e5f051
@ -193,12 +193,11 @@ protected:
|
|||||||
virtual void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const = 0;
|
virtual void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const = 0;
|
||||||
/// NodeEquals - Instantiations of the FoldingSet template implement
|
/// NodeEquals - Instantiations of the FoldingSet template implement
|
||||||
/// this function to compare the given node with the given ID.
|
/// this function to compare the given node with the given ID.
|
||||||
virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID,
|
virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID, unsigned IDHash,
|
||||||
FoldingSetNodeID &TempID) const=0;
|
FoldingSetNodeID &TempID) const=0;
|
||||||
/// NodeEquals - Instantiations of the FoldingSet template implement
|
/// ComputeNodeHash - Instantiations of the FoldingSet template implement
|
||||||
/// this function to compute a hash value for the given node.
|
/// this function to compute a hash value for the given node.
|
||||||
virtual unsigned ComputeNodeHash(Node *N,
|
virtual unsigned ComputeNodeHash(Node *N, FoldingSetNodeID &TempID) const = 0;
|
||||||
FoldingSetNodeID &TempID) const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -220,7 +219,7 @@ template<typename T> struct DefaultFoldingSetTrait {
|
|||||||
// to compute a temporary ID if necessary. The default implementation
|
// to compute a temporary ID if necessary. The default implementation
|
||||||
// just calls Profile and does a regular comparison. Implementations
|
// just calls Profile and does a regular comparison. Implementations
|
||||||
// can override this to provide more efficient implementations.
|
// can override this to provide more efficient implementations.
|
||||||
static inline bool Equals(T &X, const FoldingSetNodeID &ID,
|
static inline bool Equals(T &X, const FoldingSetNodeID &ID, unsigned IDHash,
|
||||||
FoldingSetNodeID &TempID);
|
FoldingSetNodeID &TempID);
|
||||||
|
|
||||||
// ComputeHash - Compute a hash value for X, using TempID to
|
// ComputeHash - Compute a hash value for X, using TempID to
|
||||||
@ -249,7 +248,7 @@ struct DefaultContextualFoldingSetTrait {
|
|||||||
static void Profile(T &X, FoldingSetNodeID &ID, Ctx Context) {
|
static void Profile(T &X, FoldingSetNodeID &ID, Ctx Context) {
|
||||||
X.Profile(ID, Context);
|
X.Profile(ID, Context);
|
||||||
}
|
}
|
||||||
static inline bool Equals(T &X, const FoldingSetNodeID &ID,
|
static inline bool Equals(T &X, const FoldingSetNodeID &ID, unsigned IDHash,
|
||||||
FoldingSetNodeID &TempID, Ctx Context);
|
FoldingSetNodeID &TempID, Ctx Context);
|
||||||
static inline unsigned ComputeHash(T &X, FoldingSetNodeID &TempID,
|
static inline unsigned ComputeHash(T &X, FoldingSetNodeID &TempID,
|
||||||
Ctx Context);
|
Ctx Context);
|
||||||
@ -344,7 +343,7 @@ template<class T> class FoldingSetBucketIterator;
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
inline bool
|
inline bool
|
||||||
DefaultFoldingSetTrait<T>::Equals(T &X, const FoldingSetNodeID &ID,
|
DefaultFoldingSetTrait<T>::Equals(T &X, const FoldingSetNodeID &ID,
|
||||||
FoldingSetNodeID &TempID) {
|
unsigned IDHash, FoldingSetNodeID &TempID) {
|
||||||
FoldingSetTrait<T>::Profile(X, TempID);
|
FoldingSetTrait<T>::Profile(X, TempID);
|
||||||
return TempID == ID;
|
return TempID == ID;
|
||||||
}
|
}
|
||||||
@ -358,6 +357,7 @@ template<typename T, typename Ctx>
|
|||||||
inline bool
|
inline bool
|
||||||
DefaultContextualFoldingSetTrait<T, Ctx>::Equals(T &X,
|
DefaultContextualFoldingSetTrait<T, Ctx>::Equals(T &X,
|
||||||
const FoldingSetNodeID &ID,
|
const FoldingSetNodeID &ID,
|
||||||
|
unsigned IDHash,
|
||||||
FoldingSetNodeID &TempID,
|
FoldingSetNodeID &TempID,
|
||||||
Ctx Context) {
|
Ctx Context) {
|
||||||
ContextualFoldingSetTrait<T, Ctx>::Profile(X, TempID, Context);
|
ContextualFoldingSetTrait<T, Ctx>::Profile(X, TempID, Context);
|
||||||
@ -387,15 +387,14 @@ private:
|
|||||||
}
|
}
|
||||||
/// NodeEquals - Instantiations may optionally provide a way to compare a
|
/// NodeEquals - Instantiations may optionally provide a way to compare a
|
||||||
/// node with a specified ID.
|
/// node with a specified ID.
|
||||||
virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID,
|
virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID, unsigned IDHash,
|
||||||
FoldingSetNodeID &TempID) const {
|
FoldingSetNodeID &TempID) const {
|
||||||
T *TN = static_cast<T *>(N);
|
T *TN = static_cast<T *>(N);
|
||||||
return FoldingSetTrait<T>::Equals(*TN, ID, TempID);
|
return FoldingSetTrait<T>::Equals(*TN, ID, IDHash, TempID);
|
||||||
}
|
}
|
||||||
/// NodeEquals - Instantiations may optionally provide a way to compute a
|
/// ComputeNodeHash - Instantiations may optionally provide a way to compute a
|
||||||
/// hash value directly from a node.
|
/// hash value directly from a node.
|
||||||
virtual unsigned ComputeNodeHash(Node *N,
|
virtual unsigned ComputeNodeHash(Node *N, FoldingSetNodeID &TempID) const {
|
||||||
FoldingSetNodeID &TempID) const {
|
|
||||||
T *TN = static_cast<T *>(N);
|
T *TN = static_cast<T *>(N);
|
||||||
return FoldingSetTrait<T>::ComputeHash(*TN, TempID);
|
return FoldingSetTrait<T>::ComputeHash(*TN, TempID);
|
||||||
}
|
}
|
||||||
@ -465,10 +464,11 @@ private:
|
|||||||
ContextualFoldingSetTrait<T, Ctx>::Profile(*TN, ID, Context);
|
ContextualFoldingSetTrait<T, Ctx>::Profile(*TN, ID, Context);
|
||||||
}
|
}
|
||||||
virtual bool NodeEquals(FoldingSetImpl::Node *N,
|
virtual bool NodeEquals(FoldingSetImpl::Node *N,
|
||||||
const FoldingSetNodeID &ID,
|
const FoldingSetNodeID &ID, unsigned IDHash,
|
||||||
FoldingSetNodeID &TempID) const {
|
FoldingSetNodeID &TempID) const {
|
||||||
T *TN = static_cast<T *>(N);
|
T *TN = static_cast<T *>(N);
|
||||||
return ContextualFoldingSetTrait<T, Ctx>::Equals(*TN, ID, TempID, Context);
|
return ContextualFoldingSetTrait<T, Ctx>::Equals(*TN, ID, IDHash, TempID,
|
||||||
|
Context);
|
||||||
}
|
}
|
||||||
virtual unsigned ComputeNodeHash(FoldingSetImpl::Node *N,
|
virtual unsigned ComputeNodeHash(FoldingSetImpl::Node *N,
|
||||||
FoldingSetNodeID &TempID) const {
|
FoldingSetNodeID &TempID) const {
|
||||||
|
@ -140,7 +140,7 @@ namespace llvm {
|
|||||||
ID = X.FastID;
|
ID = X.FastID;
|
||||||
}
|
}
|
||||||
static bool Equals(const SCEV &X, const FoldingSetNodeID &ID,
|
static bool Equals(const SCEV &X, const FoldingSetNodeID &ID,
|
||||||
FoldingSetNodeID &TempID) {
|
unsigned IDHash, FoldingSetNodeID &TempID) {
|
||||||
return ID == X.FastID;
|
return ID == X.FastID;
|
||||||
}
|
}
|
||||||
static unsigned ComputeHash(const SCEV &X, FoldingSetNodeID &TempID) {
|
static unsigned ComputeHash(const SCEV &X, FoldingSetNodeID &TempID) {
|
||||||
|
@ -265,15 +265,15 @@ void FoldingSetImpl::GrowHashTable() {
|
|||||||
FoldingSetImpl::Node
|
FoldingSetImpl::Node
|
||||||
*FoldingSetImpl::FindNodeOrInsertPos(const FoldingSetNodeID &ID,
|
*FoldingSetImpl::FindNodeOrInsertPos(const FoldingSetNodeID &ID,
|
||||||
void *&InsertPos) {
|
void *&InsertPos) {
|
||||||
|
unsigned IDHash = ID.ComputeHash();
|
||||||
void **Bucket = GetBucketFor(ID.ComputeHash(), Buckets, NumBuckets);
|
void **Bucket = GetBucketFor(IDHash, Buckets, NumBuckets);
|
||||||
void *Probe = *Bucket;
|
void *Probe = *Bucket;
|
||||||
|
|
||||||
InsertPos = 0;
|
InsertPos = 0;
|
||||||
|
|
||||||
FoldingSetNodeID TempID;
|
FoldingSetNodeID TempID;
|
||||||
while (Node *NodeInBucket = GetNextPtr(Probe)) {
|
while (Node *NodeInBucket = GetNextPtr(Probe)) {
|
||||||
if (NodeEquals(NodeInBucket, ID, TempID))
|
if (NodeEquals(NodeInBucket, ID, IDHash, TempID))
|
||||||
return NodeInBucket;
|
return NodeInBucket;
|
||||||
TempID.clear();
|
TempID.clear();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user