FoldingSet.h (225736) | FoldingSet.h (235633) |
---|---|
1//===-- llvm/ADT/FoldingSet.h - Uniquing Hash Set ---------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 179 unchanged lines hidden (view full) --- 188 189protected: 190 191 /// GetNodeProfile - Instantiations of the FoldingSet template implement 192 /// this function to gather data bits for the given node. 193 virtual void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const = 0; 194 /// NodeEquals - Instantiations of the FoldingSet template implement 195 /// this function to compare the given node with the given ID. | 1//===-- llvm/ADT/FoldingSet.h - Uniquing Hash Set ---------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 179 unchanged lines hidden (view full) --- 188 189protected: 190 191 /// GetNodeProfile - Instantiations of the FoldingSet template implement 192 /// this function to gather data bits for the given node. 193 virtual void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const = 0; 194 /// NodeEquals - Instantiations of the FoldingSet template implement 195 /// this function to compare the given node with the given ID. |
196 virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID, | 196 virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID, unsigned IDHash, |
197 FoldingSetNodeID &TempID) const=0; | 197 FoldingSetNodeID &TempID) const=0; |
198 /// NodeEquals - Instantiations of the FoldingSet template implement | 198 /// ComputeNodeHash - Instantiations of the FoldingSet template implement |
199 /// this function to compute a hash value for the given node. | 199 /// this function to compute a hash value for the given node. |
200 virtual unsigned ComputeNodeHash(Node *N, 201 FoldingSetNodeID &TempID) const = 0; | 200 virtual unsigned ComputeNodeHash(Node *N, FoldingSetNodeID &TempID) const = 0; |
202}; 203 204//===----------------------------------------------------------------------===// 205 206template<typename T> struct FoldingSetTrait; 207 208/// DefaultFoldingSetTrait - This class provides default implementations 209/// for FoldingSetTrait implementations. --- 5 unchanged lines hidden (view full) --- 215 static void Profile(T &X, FoldingSetNodeID &ID) { 216 X.Profile(ID); 217 } 218 219 // Equals - Test if the profile for X would match ID, using TempID 220 // to compute a temporary ID if necessary. The default implementation 221 // just calls Profile and does a regular comparison. Implementations 222 // can override this to provide more efficient implementations. | 201}; 202 203//===----------------------------------------------------------------------===// 204 205template<typename T> struct FoldingSetTrait; 206 207/// DefaultFoldingSetTrait - This class provides default implementations 208/// for FoldingSetTrait implementations. --- 5 unchanged lines hidden (view full) --- 214 static void Profile(T &X, FoldingSetNodeID &ID) { 215 X.Profile(ID); 216 } 217 218 // Equals - Test if the profile for X would match ID, using TempID 219 // to compute a temporary ID if necessary. The default implementation 220 // just calls Profile and does a regular comparison. Implementations 221 // can override this to provide more efficient implementations. |
223 static inline bool Equals(T &X, const FoldingSetNodeID &ID, | 222 static inline bool Equals(T &X, const FoldingSetNodeID &ID, unsigned IDHash, |
224 FoldingSetNodeID &TempID); 225 226 // ComputeHash - Compute a hash value for X, using TempID to 227 // compute a temporary ID if necessary. The default implementation 228 // just calls Profile and does a regular hash computation. 229 // Implementations can override this to provide more efficient 230 // implementations. 231 static inline unsigned ComputeHash(T &X, FoldingSetNodeID &TempID); --- 12 unchanged lines hidden (view full) --- 244 245/// DefaultContextualFoldingSetTrait - Like DefaultFoldingSetTrait, but 246/// for ContextualFoldingSets. 247template<typename T, typename Ctx> 248struct DefaultContextualFoldingSetTrait { 249 static void Profile(T &X, FoldingSetNodeID &ID, Ctx Context) { 250 X.Profile(ID, Context); 251 } | 223 FoldingSetNodeID &TempID); 224 225 // ComputeHash - Compute a hash value for X, using TempID to 226 // compute a temporary ID if necessary. The default implementation 227 // just calls Profile and does a regular hash computation. 228 // Implementations can override this to provide more efficient 229 // implementations. 230 static inline unsigned ComputeHash(T &X, FoldingSetNodeID &TempID); --- 12 unchanged lines hidden (view full) --- 243 244/// DefaultContextualFoldingSetTrait - Like DefaultFoldingSetTrait, but 245/// for ContextualFoldingSets. 246template<typename T, typename Ctx> 247struct DefaultContextualFoldingSetTrait { 248 static void Profile(T &X, FoldingSetNodeID &ID, Ctx Context) { 249 X.Profile(ID, Context); 250 } |
252 static inline bool Equals(T &X, const FoldingSetNodeID &ID, | 251 static inline bool Equals(T &X, const FoldingSetNodeID &ID, unsigned IDHash, |
253 FoldingSetNodeID &TempID, Ctx Context); 254 static inline unsigned ComputeHash(T &X, FoldingSetNodeID &TempID, 255 Ctx Context); 256}; 257 258/// ContextualFoldingSetTrait - Like FoldingSetTrait, but for 259/// ContextualFoldingSets. 260template<typename T, typename Ctx> struct ContextualFoldingSetTrait --- 78 unchanged lines hidden (view full) --- 339template<class T> class FoldingSetIterator; 340template<class T> class FoldingSetBucketIterator; 341 342// Definitions of FoldingSetTrait and ContextualFoldingSetTrait functions, which 343// require the definition of FoldingSetNodeID. 344template<typename T> 345inline bool 346DefaultFoldingSetTrait<T>::Equals(T &X, const FoldingSetNodeID &ID, | 252 FoldingSetNodeID &TempID, Ctx Context); 253 static inline unsigned ComputeHash(T &X, FoldingSetNodeID &TempID, 254 Ctx Context); 255}; 256 257/// ContextualFoldingSetTrait - Like FoldingSetTrait, but for 258/// ContextualFoldingSets. 259template<typename T, typename Ctx> struct ContextualFoldingSetTrait --- 78 unchanged lines hidden (view full) --- 338template<class T> class FoldingSetIterator; 339template<class T> class FoldingSetBucketIterator; 340 341// Definitions of FoldingSetTrait and ContextualFoldingSetTrait functions, which 342// require the definition of FoldingSetNodeID. 343template<typename T> 344inline bool 345DefaultFoldingSetTrait<T>::Equals(T &X, const FoldingSetNodeID &ID, |
347 FoldingSetNodeID &TempID) { | 346 unsigned IDHash, FoldingSetNodeID &TempID) { |
348 FoldingSetTrait<T>::Profile(X, TempID); 349 return TempID == ID; 350} 351template<typename T> 352inline unsigned 353DefaultFoldingSetTrait<T>::ComputeHash(T &X, FoldingSetNodeID &TempID) { 354 FoldingSetTrait<T>::Profile(X, TempID); 355 return TempID.ComputeHash(); 356} 357template<typename T, typename Ctx> 358inline bool 359DefaultContextualFoldingSetTrait<T, Ctx>::Equals(T &X, 360 const FoldingSetNodeID &ID, | 347 FoldingSetTrait<T>::Profile(X, TempID); 348 return TempID == ID; 349} 350template<typename T> 351inline unsigned 352DefaultFoldingSetTrait<T>::ComputeHash(T &X, FoldingSetNodeID &TempID) { 353 FoldingSetTrait<T>::Profile(X, TempID); 354 return TempID.ComputeHash(); 355} 356template<typename T, typename Ctx> 357inline bool 358DefaultContextualFoldingSetTrait<T, Ctx>::Equals(T &X, 359 const FoldingSetNodeID &ID, |
360 unsigned IDHash, |
|
361 FoldingSetNodeID &TempID, 362 Ctx Context) { 363 ContextualFoldingSetTrait<T, Ctx>::Profile(X, TempID, Context); 364 return TempID == ID; 365} 366template<typename T, typename Ctx> 367inline unsigned 368DefaultContextualFoldingSetTrait<T, Ctx>::ComputeHash(T &X, --- 13 unchanged lines hidden (view full) --- 382 /// GetNodeProfile - Each instantiatation of the FoldingSet needs to provide a 383 /// way to convert nodes into a unique specifier. 384 virtual void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const { 385 T *TN = static_cast<T *>(N); 386 FoldingSetTrait<T>::Profile(*TN, ID); 387 } 388 /// NodeEquals - Instantiations may optionally provide a way to compare a 389 /// node with a specified ID. | 361 FoldingSetNodeID &TempID, 362 Ctx Context) { 363 ContextualFoldingSetTrait<T, Ctx>::Profile(X, TempID, Context); 364 return TempID == ID; 365} 366template<typename T, typename Ctx> 367inline unsigned 368DefaultContextualFoldingSetTrait<T, Ctx>::ComputeHash(T &X, --- 13 unchanged lines hidden (view full) --- 382 /// GetNodeProfile - Each instantiatation of the FoldingSet needs to provide a 383 /// way to convert nodes into a unique specifier. 384 virtual void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const { 385 T *TN = static_cast<T *>(N); 386 FoldingSetTrait<T>::Profile(*TN, ID); 387 } 388 /// NodeEquals - Instantiations may optionally provide a way to compare a 389 /// node with a specified ID. |
390 virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID, | 390 virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID, unsigned IDHash, |
391 FoldingSetNodeID &TempID) const { 392 T *TN = static_cast<T *>(N); | 391 FoldingSetNodeID &TempID) const { 392 T *TN = static_cast<T *>(N); |
393 return FoldingSetTrait | 393 return FoldingSetTrait<T>::Equals(*TN, ID, IDHash, TempID); |
394 } | 394 } |
395 /// NodeEquals - Instantiations may optionally provide a way to compute a | 395 /// ComputeNodeHash - Instantiations may optionally provide a way to compute a |
396 /// hash value directly from a node. | 396 /// hash value directly from a node. |
397 virtual unsigned ComputeNodeHash(Node *N, 398 FoldingSetNodeID &TempID) const { | 397 virtual unsigned ComputeNodeHash(Node *N, FoldingSetNodeID &TempID) const { |
399 T *TN = static_cast<T *>(N); 400 return FoldingSetTrait<T>::ComputeHash(*TN, TempID); 401 } 402 403public: 404 explicit FoldingSet(unsigned Log2InitSize = 6) 405 : FoldingSetImpl(Log2InitSize) 406 {} --- 53 unchanged lines hidden (view full) --- 460 /// GetNodeProfile - Each instantiatation of the FoldingSet needs to provide a 461 /// way to convert nodes into a unique specifier. 462 virtual void GetNodeProfile(FoldingSetImpl::Node *N, 463 FoldingSetNodeID &ID) const { 464 T *TN = static_cast<T *>(N); 465 ContextualFoldingSetTrait<T, Ctx>::Profile(*TN, ID, Context); 466 } 467 virtual bool NodeEquals(FoldingSetImpl::Node *N, | 398 T *TN = static_cast<T *>(N); 399 return FoldingSetTrait<T>::ComputeHash(*TN, TempID); 400 } 401 402public: 403 explicit FoldingSet(unsigned Log2InitSize = 6) 404 : FoldingSetImpl(Log2InitSize) 405 {} --- 53 unchanged lines hidden (view full) --- 459 /// GetNodeProfile - Each instantiatation of the FoldingSet needs to provide a 460 /// way to convert nodes into a unique specifier. 461 virtual void GetNodeProfile(FoldingSetImpl::Node *N, 462 FoldingSetNodeID &ID) const { 463 T *TN = static_cast<T *>(N); 464 ContextualFoldingSetTrait<T, Ctx>::Profile(*TN, ID, Context); 465 } 466 virtual bool NodeEquals(FoldingSetImpl::Node *N, |
468 const FoldingSetNodeID &ID, | 467 const FoldingSetNodeID &ID, unsigned IDHash, |
469 FoldingSetNodeID &TempID) const { 470 T *TN = static_cast<T *>(N); | 468 FoldingSetNodeID &TempID) const { 469 T *TN = static_cast<T *>(N); |
471 return ContextualFoldingSetTrait<T, Ctx>::Equals(*TN, ID, TempID, Context); | 470 return ContextualFoldingSetTrait<T, Ctx>::Equals(*TN, ID, IDHash, TempID, 471 Context); |
472 } 473 virtual unsigned ComputeNodeHash(FoldingSetImpl::Node *N, 474 FoldingSetNodeID &TempID) const { 475 T *TN = static_cast<T *>(N); 476 return ContextualFoldingSetTrait<T, Ctx>::ComputeHash(*TN, TempID, Context); 477 } 478 479public: --- 201 unchanged lines hidden --- | 472 } 473 virtual unsigned ComputeNodeHash(FoldingSetImpl::Node *N, 474 FoldingSetNodeID &TempID) const { 475 T *TN = static_cast<T *>(N); 476 return ContextualFoldingSetTrait<T, Ctx>::ComputeHash(*TN, TempID, Context); 477 } 478 479public: --- 201 unchanged lines hidden --- |