diff options
| author | Zachary Turner <zturner@google.com> | 2017-03-11 02:52:48 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2017-03-11 02:52:48 +0000 |
| commit | 6023fb58ccf4b635021f8f6f6a79e346aa935670 (patch) | |
| tree | 1ed8ce1bed07581c70a6fb13d6b8db6cdb48cbb9 | |
| parent | 5dfa9642a8368fba3133c8d0c7fa197b664c7ca7 (diff) | |
| download | bcm5719-llvm-6023fb58ccf4b635021f8f6f6a79e346aa935670.tar.gz bcm5719-llvm-6023fb58ccf4b635021f8f6f6a79e346aa935670.zip | |
[ADT] Add a DenseMapInfo<T> for shorts.
Differential Revision: https://reviews.llvm.org/D30857
llvm-svn: 297552
| -rw-r--r-- | llvm/include/llvm/ADT/DenseMapInfo.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h b/llvm/include/llvm/ADT/DenseMapInfo.h index a844ebcccf5..bb973ac6506 100644 --- a/llvm/include/llvm/ADT/DenseMapInfo.h +++ b/llvm/include/llvm/ADT/DenseMapInfo.h @@ -60,6 +60,16 @@ template<> struct DenseMapInfo<char> { } }; +// 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 @@ template<> struct DenseMapInfo<unsigned long long> { } }; +// 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; } |

