Skip to content

Commit 5b17f85

Browse files
committed
[CodeGen][MC] Improve DenseMapInfo for Register/MCRegister.
Make getEmptyKey() and getTombstoneKey() return a Register/MCRegister instead of `unsigned`. Use operator== isEqual.
1 parent dab3c6d commit 5b17f85

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

llvm/include/llvm/CodeGen/Register.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,17 @@ class Register {
147147

148148
// Provide DenseMapInfo for Register
149149
template <> struct DenseMapInfo<Register> {
150-
static inline unsigned getEmptyKey() {
150+
static inline Register getEmptyKey() {
151151
return DenseMapInfo<unsigned>::getEmptyKey();
152152
}
153-
static inline unsigned getTombstoneKey() {
153+
static inline Register getTombstoneKey() {
154154
return DenseMapInfo<unsigned>::getTombstoneKey();
155155
}
156156
static unsigned getHashValue(const Register &Val) {
157157
return DenseMapInfo<unsigned>::getHashValue(Val.id());
158158
}
159159
static bool isEqual(const Register &LHS, const Register &RHS) {
160-
return DenseMapInfo<unsigned>::isEqual(LHS.id(), RHS.id());
160+
return LHS == RHS;
161161
}
162162
};
163163

llvm/include/llvm/CodeGen/TargetInstrInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,8 +2309,7 @@ template <> struct DenseMapInfo<TargetInstrInfo::RegSubRegPair> {
23092309

23102310
static bool isEqual(const TargetInstrInfo::RegSubRegPair &LHS,
23112311
const TargetInstrInfo::RegSubRegPair &RHS) {
2312-
return RegInfo::isEqual(LHS.Reg, RHS.Reg) &&
2313-
SubRegInfo::isEqual(LHS.SubReg, RHS.SubReg);
2312+
return LHS == RHS;
23142313
}
23152314
};
23162315

llvm/include/llvm/MC/MCRegister.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,17 @@ class MCRegister {
106106

107107
// Provide DenseMapInfo for MCRegister
108108
template <> struct DenseMapInfo<MCRegister> {
109-
static inline unsigned getEmptyKey() {
109+
static inline MCRegister getEmptyKey() {
110110
return DenseMapInfo<unsigned>::getEmptyKey();
111111
}
112-
static inline unsigned getTombstoneKey() {
112+
static inline MCRegister getTombstoneKey() {
113113
return DenseMapInfo<unsigned>::getTombstoneKey();
114114
}
115115
static unsigned getHashValue(const MCRegister &Val) {
116116
return DenseMapInfo<unsigned>::getHashValue(Val.id());
117117
}
118118
static bool isEqual(const MCRegister &LHS, const MCRegister &RHS) {
119-
return DenseMapInfo<unsigned>::isEqual(LHS.id(), RHS.id());
119+
return LHS == RHS;
120120
}
121121
};
122122

0 commit comments

Comments
 (0)