[llvm] 5b17f85 - [CodeGen][MC] Improve DenseMapInfo for Register/MCRegister.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 22:11:10 PDT 2024


Author: Craig Topper
Date: 2024-09-19T22:10:51-07:00
New Revision: 5b17f85a7d722439a39f1ac1c554aed7858adab4

URL: https://github.com/llvm/llvm-project/commit/5b17f85a7d722439a39f1ac1c554aed7858adab4
DIFF: https://github.com/llvm/llvm-project/commit/5b17f85a7d722439a39f1ac1c554aed7858adab4.diff

LOG: [CodeGen][MC] Improve DenseMapInfo for Register/MCRegister.

Make getEmptyKey() and getTombstoneKey() return a
Register/MCRegister instead of `unsigned`. Use operator==
isEqual.

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/Register.h
    llvm/include/llvm/CodeGen/TargetInstrInfo.h
    llvm/include/llvm/MC/MCRegister.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/Register.h b/llvm/include/llvm/CodeGen/Register.h
index c93b8e10a17574..4a61ea8af3b461 100644
--- a/llvm/include/llvm/CodeGen/Register.h
+++ b/llvm/include/llvm/CodeGen/Register.h
@@ -147,17 +147,17 @@ class Register {
 
 // Provide DenseMapInfo for Register
 template <> struct DenseMapInfo<Register> {
-  static inline unsigned getEmptyKey() {
+  static inline Register getEmptyKey() {
     return DenseMapInfo<unsigned>::getEmptyKey();
   }
-  static inline unsigned getTombstoneKey() {
+  static inline Register getTombstoneKey() {
     return DenseMapInfo<unsigned>::getTombstoneKey();
   }
   static unsigned getHashValue(const Register &Val) {
     return DenseMapInfo<unsigned>::getHashValue(Val.id());
   }
   static bool isEqual(const Register &LHS, const Register &RHS) {
-    return DenseMapInfo<unsigned>::isEqual(LHS.id(), RHS.id());
+    return LHS == RHS;
   }
 };
 

diff  --git a/llvm/include/llvm/CodeGen/TargetInstrInfo.h b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
index c944a96aee61a1..07b59b241d9f9a 100644
--- a/llvm/include/llvm/CodeGen/TargetInstrInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
@@ -2309,8 +2309,7 @@ template <> struct DenseMapInfo<TargetInstrInfo::RegSubRegPair> {
 
   static bool isEqual(const TargetInstrInfo::RegSubRegPair &LHS,
                       const TargetInstrInfo::RegSubRegPair &RHS) {
-    return RegInfo::isEqual(LHS.Reg, RHS.Reg) &&
-           SubRegInfo::isEqual(LHS.SubReg, RHS.SubReg);
+    return LHS == RHS;
   }
 };
 

diff  --git a/llvm/include/llvm/MC/MCRegister.h b/llvm/include/llvm/MC/MCRegister.h
index dd8bc1e0f7189f..2d21e0acca357d 100644
--- a/llvm/include/llvm/MC/MCRegister.h
+++ b/llvm/include/llvm/MC/MCRegister.h
@@ -106,17 +106,17 @@ class MCRegister {
 
 // Provide DenseMapInfo for MCRegister
 template <> struct DenseMapInfo<MCRegister> {
-  static inline unsigned getEmptyKey() {
+  static inline MCRegister getEmptyKey() {
     return DenseMapInfo<unsigned>::getEmptyKey();
   }
-  static inline unsigned getTombstoneKey() {
+  static inline MCRegister getTombstoneKey() {
     return DenseMapInfo<unsigned>::getTombstoneKey();
   }
   static unsigned getHashValue(const MCRegister &Val) {
     return DenseMapInfo<unsigned>::getHashValue(Val.id());
   }
   static bool isEqual(const MCRegister &LHS, const MCRegister &RHS) {
-    return DenseMapInfo<unsigned>::isEqual(LHS.id(), RHS.id());
+    return LHS == RHS;
   }
 };
 


        


More information about the llvm-commits mailing list