From d76e3d5414e25bc0b3333774d57dff3ff1fce829 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Wed, 20 Sep 2017 18:01:20 +0000 Subject: [PATCH] [TableGen] Add a DenseMapInfo for MachineValueType. No functional change, just adding a DenseMapInfo and tombstone value so that MVT's can be put into a DenseMap / DenseSet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313782 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineValueType.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/llvm/CodeGen/MachineValueType.h b/include/llvm/CodeGen/MachineValueType.h index 0bdb38bfcbe..c248a547972 100644 --- a/include/llvm/CodeGen/MachineValueType.h +++ b/include/llvm/CodeGen/MachineValueType.h @@ -16,6 +16,7 @@ #define LLVM_CODEGEN_MACHINEVALUETYPE_H #include "llvm/ADT/iterator_range.h" +#include "llvm/ADT/DenseMapInfo.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" #include @@ -30,6 +31,8 @@ namespace llvm { class MVT { public: enum SimpleValueType : uint8_t { + // clang-format off + // Simple value types that aren't explicitly part of this enumeration // are considered extended value types. INVALID_SIMPLE_VALUE_TYPE = 0, @@ -198,6 +201,10 @@ namespace llvm { // This value must be a multiple of 32. MAX_ALLOWED_VALUETYPE = 128, + // tombstone value used for DenseMap / DenseSet. + // This is only for internal use! + tombstone = 247, + // A value of type llvm::TokenTy token = 248, @@ -231,6 +238,8 @@ namespace llvm { // Any type. This is used for intrinsics that have overloadings. // This is only for tblgen's consumption! Any = 255 + + // clang-format on }; SimpleValueType SimpleTy = INVALID_SIMPLE_VALUE_TYPE; @@ -1044,6 +1053,18 @@ namespace llvm { /// @} }; + template <> struct DenseMapInfo { + static inline MVT getEmptyKey() { + return MVT(MVT::INVALID_SIMPLE_VALUE_TYPE); + } + + static inline MVT getTombstoneKey() { return MVT(MVT::tombstone); } + static unsigned getHashValue(const MVT &Val) { + return unsigned(Val.SimpleTy); + } + static bool isEqual(const MVT &LHS, const MVT &RHS) { return LHS == RHS; } + }; + } // end namespace llvm #endif // LLVM_CODEGEN_MACHINEVALUETYPE_H -- 2.50.0