Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit d76e3d5

Browse files
author
Zachary Turner
committed
[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
1 parent 1809c66 commit d76e3d5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

include/llvm/CodeGen/MachineValueType.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define LLVM_CODEGEN_MACHINEVALUETYPE_H
1717

1818
#include "llvm/ADT/iterator_range.h"
19+
#include "llvm/ADT/DenseMapInfo.h"
1920
#include "llvm/Support/ErrorHandling.h"
2021
#include "llvm/Support/MathExtras.h"
2122
#include <cassert>
@@ -30,6 +31,8 @@ namespace llvm {
3031
class MVT {
3132
public:
3233
enum SimpleValueType : uint8_t {
34+
// clang-format off
35+
3336
// Simple value types that aren't explicitly part of this enumeration
3437
// are considered extended value types.
3538
INVALID_SIMPLE_VALUE_TYPE = 0,
@@ -198,6 +201,10 @@ namespace llvm {
198201
// This value must be a multiple of 32.
199202
MAX_ALLOWED_VALUETYPE = 128,
200203

204+
// tombstone value used for DenseMap / DenseSet.
205+
// This is only for internal use!
206+
tombstone = 247,
207+
201208
// A value of type llvm::TokenTy
202209
token = 248,
203210

@@ -231,6 +238,8 @@ namespace llvm {
231238
// Any type. This is used for intrinsics that have overloadings.
232239
// This is only for tblgen's consumption!
233240
Any = 255
241+
242+
// clang-format on
234243
};
235244

236245
SimpleValueType SimpleTy = INVALID_SIMPLE_VALUE_TYPE;
@@ -1044,6 +1053,18 @@ namespace llvm {
10441053
/// @}
10451054
};
10461055

1056+
template <> struct DenseMapInfo<MVT> {
1057+
static inline MVT getEmptyKey() {
1058+
return MVT(MVT::INVALID_SIMPLE_VALUE_TYPE);
1059+
}
1060+
1061+
static inline MVT getTombstoneKey() { return MVT(MVT::tombstone); }
1062+
static unsigned getHashValue(const MVT &Val) {
1063+
return unsigned(Val.SimpleTy);
1064+
}
1065+
static bool isEqual(const MVT &LHS, const MVT &RHS) { return LHS == RHS; }
1066+
};
1067+
10471068
} // end namespace llvm
10481069

10491070
#endif // LLVM_CODEGEN_MACHINEVALUETYPE_H

0 commit comments

Comments
 (0)