[PATCH] D30857: Add a DenseMapInfo<T> for shorts.
Zachary Turner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 10 17:27:42 PST 2017
zturner created this revision.
Not sure why this little guy was curiously missing, but I need one.
https://reviews.llvm.org/D30857
Files:
llvm/include/llvm/ADT/DenseMapInfo.h
Index: llvm/include/llvm/ADT/DenseMapInfo.h
===================================================================
--- llvm/include/llvm/ADT/DenseMapInfo.h
+++ llvm/include/llvm/ADT/DenseMapInfo.h
@@ -60,6 +60,16 @@
}
};
+// Provide DenseMapInfo for unsigned shorts.
+template <> struct DenseMapInfo<unsigned short> {
+ static inline unsigned short getEmptyKey() { return 0xFFFF; }
+ static inline unsigned short getTombstoneKey() { return 0xFFFF - 1; }
+ static unsigned getHashValue(const unsigned short &Val) { return Val * 37U; }
+ static bool isEqual(const unsigned short &LHS, const unsigned short &RHS) {
+ return LHS == RHS;
+ }
+};
+
// Provide DenseMapInfo for unsigned ints.
template<> struct DenseMapInfo<unsigned> {
static inline unsigned getEmptyKey() { return ~0U; }
@@ -95,6 +105,14 @@
}
};
+// Provide DenseMapInfo for shorts.
+template <> struct DenseMapInfo<short> {
+ static inline short getEmptyKey() { return 0x7FFF; }
+ static inline short getTombstoneKey() { return -0x7FFF - 1; }
+ static unsigned getHashValue(const short &Val) { return Val * 37U; }
+ static bool isEqual(const short &LHS, const short &RHS) { return LHS == RHS; }
+};
+
// Provide DenseMapInfo for ints.
template<> struct DenseMapInfo<int> {
static inline int getEmptyKey() { return 0x7fffffff; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30857.91440.patch
Type: text/x-patch
Size: 1321 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170311/c02e56a2/attachment.bin>
More information about the llvm-commits
mailing list