llvm.org GIT mirror llvm / 2dba6a1
consolidate DenseMapInfo implementations, and add one for std::pair. Patch contributed by m-s. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55167 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
4 changed file(s) with 42 addition(s) and 38 deletion(s). Raw diff Collapse all Expand all
4040 }
4141 static bool isEqual(const T *LHS, const T *RHS) { return LHS == RHS; }
4242 static bool isPod() { return true; }
43 };
44
45 // Provide DenseMapInfo for unsigned ints.
46 template<> struct DenseMapInfo {
47 static inline uint32_t getEmptyKey() { return ~0; }
48 static inline uint32_t getTombstoneKey() { return ~0 - 1; }
49 static unsigned getHashValue(const uint32_t& Val) { return Val * 37; }
50 static bool isPod() { return true; }
51 static bool isEqual(const uint32_t& LHS, const uint32_t& RHS) {
52 return LHS == RHS;
53 }
54 };
55
56 // Provide DenseMapInfo for all pairs whose members have info.
57 template
58 struct DenseMapInfo > {
59 typedef std::pair Pair;
60 typedef DenseMapInfo FirstInfo;
61 typedef DenseMapInfo SecondInfo;
62
63 static inline Pair getEmptyKey() {
64 return std::make_pair(FirstInfo::getEmptyKey(),
65 SecondInfo::getEmptyKey());
66 }
67 static inline Pair getTombstoneKey() {
68 return std::make_pair(FirstInfo::getTombstoneKey(),
69 SecondInfo::getEmptyKey()); }
70 static unsigned getHashValue(const Pair& PairVal) {
71 uint64_t key = (uint64_t)FirstInfo::getHashValue(PairVal.first) << 32
72 | (uint64_t)SecondInfo::getHashValue(PairVal.second);
73 key += ~(key << 32);
74 key ^= (key >> 22);
75 key += ~(key << 13);
76 key ^= (key >> 8);
77 key += (key << 3);
78 key ^= (key >> 15);
79 key += ~(key << 27);
80 key ^= (key >> 31);
81 return (unsigned)key;
82 }
83 static bool isEqual(const Pair& LHS, const Pair& RHS) { return LHS == RHS; }
84 static bool isPod() { return false; }
4385 };
4486
4587 template
5454 }
5555 };
5656
57 // Provide DenseMapInfo for unsigned.
58 template<>
59 struct DenseMapInfo {
60 static inline unsigned getEmptyKey() { return (unsigned)-1; }
61 static inline unsigned getTombstoneKey() { return (unsigned)-2; }
62 static unsigned getHashValue(const unsigned Val) {
63 return Val * 37;
64 }
65 static bool isEqual(const unsigned LHS, const unsigned RHS) {
66 return LHS == RHS;
67 }
68 static bool isPod() { return true; }
69 };
70
7157 class LiveIntervals : public MachineFunctionPass {
7258 MachineFunction* mf_;
7359 MachineRegisterInfo* mri_;
558558 }
559559
560560 return false;
561 }
562
563 namespace llvm {
564 template<> struct DenseMapInfo {
565 static inline uint32_t getEmptyKey() { return ~0; }
566 static inline uint32_t getTombstoneKey() { return ~0 - 1; }
567 static unsigned getHashValue(const uint32_t& Val) { return Val * 37; }
568 static bool isPod() { return true; }
569 static bool isEqual(const uint32_t& LHS, const uint32_t& RHS) {
570 return LHS == RHS;
571 }
572 };
573561 }
574562
575563 /// ComputeLocalLiveness - Computes liveness of registers within a basic
680680 //===----------------------------------------------------------------------===//
681681 // GVN Pass
682682 //===----------------------------------------------------------------------===//
683
684 namespace llvm {
685 template<> struct DenseMapInfo {
686 static inline uint32_t getEmptyKey() { return ~0; }
687 static inline uint32_t getTombstoneKey() { return ~0 - 1; }
688 static unsigned getHashValue(const uint32_t& Val) { return Val * 37; }
689 static bool isPod() { return true; }
690 static bool isEqual(const uint32_t& LHS, const uint32_t& RHS) {
691 return LHS == RHS;
692 }
693 };
694 }
695683
696684 namespace {
697685 struct VISIBILITY_HIDDEN ValueNumberScope {