[llvm-commits] [llvm] r55167 - in /llvm/trunk: include/llvm/ADT/DenseMap.h include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/RegAllocLocal.cpp lib/Transforms/Scalar/GVN.cpp
Chris Lattner
sabre at nondot.org
Thu Aug 21 22:08:26 PDT 2008
Author: lattner
Date: Fri Aug 22 00:08:25 2008
New Revision: 55167
URL: http://llvm.org/viewvc/llvm-project?rev=55167&view=rev
Log:
consolidate DenseMapInfo implementations, and add one for std::pair.
Patch contributed by m-s.
Modified:
llvm/trunk/include/llvm/ADT/DenseMap.h
llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h
llvm/trunk/lib/CodeGen/RegAllocLocal.cpp
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Modified: llvm/trunk/include/llvm/ADT/DenseMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMap.h?rev=55167&r1=55166&r2=55167&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/DenseMap.h (original)
+++ llvm/trunk/include/llvm/ADT/DenseMap.h Fri Aug 22 00:08:25 2008
@@ -43,6 +43,48 @@
static bool isPod() { return true; }
};
+// Provide DenseMapInfo for unsigned ints.
+template<> struct DenseMapInfo<uint32_t> {
+ static inline uint32_t getEmptyKey() { return ~0; }
+ static inline uint32_t getTombstoneKey() { return ~0 - 1; }
+ static unsigned getHashValue(const uint32_t& Val) { return Val * 37; }
+ static bool isPod() { return true; }
+ static bool isEqual(const uint32_t& LHS, const uint32_t& RHS) {
+ return LHS == RHS;
+ }
+};
+
+// Provide DenseMapInfo for all pairs whose members have info.
+template<typename T, typename U>
+struct DenseMapInfo<std::pair<T, U> > {
+ typedef std::pair<T, U> Pair;
+ typedef DenseMapInfo<T> FirstInfo;
+ typedef DenseMapInfo<U> SecondInfo;
+
+ static inline Pair getEmptyKey() {
+ return std::make_pair(FirstInfo::getEmptyKey(),
+ SecondInfo::getEmptyKey());
+ }
+ static inline Pair getTombstoneKey() {
+ return std::make_pair(FirstInfo::getTombstoneKey(),
+ SecondInfo::getEmptyKey()); }
+ static unsigned getHashValue(const Pair& PairVal) {
+ uint64_t key = (uint64_t)FirstInfo::getHashValue(PairVal.first) << 32
+ | (uint64_t)SecondInfo::getHashValue(PairVal.second);
+ key += ~(key << 32);
+ key ^= (key >> 22);
+ key += ~(key << 13);
+ key ^= (key >> 8);
+ key += (key << 3);
+ key ^= (key >> 15);
+ key += ~(key << 27);
+ key ^= (key >> 31);
+ return (unsigned)key;
+ }
+ static bool isEqual(const Pair& LHS, const Pair& RHS) { return LHS == RHS; }
+ static bool isPod() { return false; }
+};
+
template<typename KeyT, typename ValueT,
typename KeyInfoT = DenseMapInfo<KeyT>,
typename ValueInfoT = DenseMapInfo<ValueT> >
Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=55167&r1=55166&r2=55167&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Fri Aug 22 00:08:25 2008
@@ -55,20 +55,6 @@
}
};
- // Provide DenseMapInfo for unsigned.
- template<>
- struct DenseMapInfo<unsigned> {
- static inline unsigned getEmptyKey() { return (unsigned)-1; }
- static inline unsigned getTombstoneKey() { return (unsigned)-2; }
- static unsigned getHashValue(const unsigned Val) {
- return Val * 37;
- }
- static bool isEqual(const unsigned LHS, const unsigned RHS) {
- return LHS == RHS;
- }
- static bool isPod() { return true; }
- };
-
class LiveIntervals : public MachineFunctionPass {
MachineFunction* mf_;
MachineRegisterInfo* mri_;
Modified: llvm/trunk/lib/CodeGen/RegAllocLocal.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLocal.cpp?rev=55167&r1=55166&r2=55167&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocLocal.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Fri Aug 22 00:08:25 2008
@@ -561,18 +561,6 @@
return false;
}
-namespace llvm {
- template<> struct DenseMapInfo<uint32_t> {
- static inline uint32_t getEmptyKey() { return ~0; }
- static inline uint32_t getTombstoneKey() { return ~0 - 1; }
- static unsigned getHashValue(const uint32_t& Val) { return Val * 37; }
- static bool isPod() { return true; }
- static bool isEqual(const uint32_t& LHS, const uint32_t& RHS) {
- return LHS == RHS;
- }
- };
-}
-
/// ComputeLocalLiveness - Computes liveness of registers within a basic
/// block, setting the killed/dead flags as appropriate.
void RALocal::ComputeLocalLiveness(MachineBasicBlock& MBB) {
Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=55167&r1=55166&r2=55167&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Fri Aug 22 00:08:25 2008
@@ -682,18 +682,6 @@
// GVN Pass
//===----------------------------------------------------------------------===//
-namespace llvm {
- template<> struct DenseMapInfo<uint32_t> {
- static inline uint32_t getEmptyKey() { return ~0; }
- static inline uint32_t getTombstoneKey() { return ~0 - 1; }
- static unsigned getHashValue(const uint32_t& Val) { return Val * 37; }
- static bool isPod() { return true; }
- static bool isEqual(const uint32_t& LHS, const uint32_t& RHS) {
- return LHS == RHS;
- }
- };
-}
-
namespace {
struct VISIBILITY_HIDDEN ValueNumberScope {
ValueNumberScope* parent;
More information about the llvm-commits
mailing list