mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-31 08:16:47 +00:00 
			
		
		
		
	Specialize DenseMapInfo for SCEVHandle, so that SCEVHandles can be
used as keys in DenseMaps. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73360 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -25,6 +25,7 @@ | |||||||
| #include "llvm/Analysis/LoopInfo.h" | #include "llvm/Analysis/LoopInfo.h" | ||||||
| #include "llvm/Support/DataTypes.h" | #include "llvm/Support/DataTypes.h" | ||||||
| #include "llvm/Support/ValueHandle.h" | #include "llvm/Support/ValueHandle.h" | ||||||
|  | #include "llvm/ADT/DenseMap.h" | ||||||
| #include <iosfwd> | #include <iosfwd> | ||||||
|  |  | ||||||
| namespace llvm { | namespace llvm { | ||||||
| @@ -34,6 +35,7 @@ namespace llvm { | |||||||
|   class SCEVHandle; |   class SCEVHandle; | ||||||
|   class ScalarEvolution; |   class ScalarEvolution; | ||||||
|   class TargetData; |   class TargetData; | ||||||
|  |   template<> struct DenseMapInfo<SCEVHandle>; | ||||||
|  |  | ||||||
|   /// SCEV - This class represents an analyzed expression in the program.  These |   /// SCEV - This class represents an analyzed expression in the program.  These | ||||||
|   /// are reference-counted opaque objects that the client is not allowed to |   /// are reference-counted opaque objects that the client is not allowed to | ||||||
| @@ -44,6 +46,7 @@ namespace llvm { | |||||||
|     mutable unsigned RefCount; |     mutable unsigned RefCount; | ||||||
|  |  | ||||||
|     friend class SCEVHandle; |     friend class SCEVHandle; | ||||||
|  |     friend class DenseMapInfo<SCEVHandle>; | ||||||
|     void addRef() const { ++RefCount; } |     void addRef() const { ++RefCount; } | ||||||
|     void dropRef() const { |     void dropRef() const { | ||||||
|       if (--RefCount == 0) |       if (--RefCount == 0) | ||||||
| @@ -197,6 +200,31 @@ namespace llvm { | |||||||
|   template<> struct simplify_type<SCEVHandle> |   template<> struct simplify_type<SCEVHandle> | ||||||
|     : public simplify_type<const SCEVHandle> {}; |     : public simplify_type<const SCEVHandle> {}; | ||||||
|  |  | ||||||
|  |   // Specialize DenseMapInfo for SCEVHandle so that SCEVHandle may be used | ||||||
|  |   // as a key in DenseMaps. | ||||||
|  |   template<> | ||||||
|  |   struct DenseMapInfo<SCEVHandle> { | ||||||
|  |     static inline SCEVHandle getEmptyKey() { | ||||||
|  |       static SCEVCouldNotCompute Empty; | ||||||
|  |       if (Empty.RefCount == 0) | ||||||
|  |         Empty.addRef(); | ||||||
|  |       return &Empty; | ||||||
|  |     } | ||||||
|  |     static inline SCEVHandle getTombstoneKey() { | ||||||
|  |       static SCEVCouldNotCompute Tombstone; | ||||||
|  |       if (Tombstone.RefCount == 0) | ||||||
|  |         Tombstone.addRef(); | ||||||
|  |       return &Tombstone; | ||||||
|  |     } | ||||||
|  |     static unsigned getHashValue(const SCEVHandle &Val) { | ||||||
|  |       return DenseMapInfo<const SCEV *>::getHashValue(Val); | ||||||
|  |     } | ||||||
|  |     static bool isEqual(const SCEVHandle &LHS, const SCEVHandle &RHS) { | ||||||
|  |       return LHS == RHS; | ||||||
|  |     } | ||||||
|  |     static bool isPod() { return false; } | ||||||
|  |   }; | ||||||
|  |  | ||||||
|   /// ScalarEvolution - This class is the main scalar evolution driver.  Because |   /// ScalarEvolution - This class is the main scalar evolution driver.  Because | ||||||
|   /// client code (intentionally) can't do much with the SCEV objects directly, |   /// client code (intentionally) can't do much with the SCEV objects directly, | ||||||
|   /// they must ask this class for services. |   /// they must ask this class for services. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user