[NFC] MCRegister fixes in RegisterClassInfo, and const-ed APIs
authorMircea Trofin <mtrofin@google.com>
Fri, 26 Feb 2021 16:52:34 +0000 (08:52 -0800)
committerMircea Trofin <mtrofin@google.com>
Fri, 26 Feb 2021 16:53:57 +0000 (08:53 -0800)
llvm/include/llvm/CodeGen/RegisterClassInfo.h

index 00b8535..d82f1db 100644 (file)
@@ -111,24 +111,26 @@ public:
   }
 
   /// getLastCalleeSavedAlias - Returns the last callee saved register that
-  /// overlaps PhysReg, or 0 if Reg doesn't overlap a CalleeSavedAliases.
-  unsigned getLastCalleeSavedAlias(unsigned PhysReg) const {
-    assert(Register::isPhysicalRegister(PhysReg));
-    if (PhysReg < CalleeSavedAliases.size())
+  /// overlaps PhysReg, or NoRegister if Reg doesn't overlap a
+  /// CalleeSavedAliases.
+  MCRegister getLastCalleeSavedAlias(MCRegister PhysReg) const {
+    if (PhysReg.id() < CalleeSavedAliases.size())
       return CalleeSavedAliases[PhysReg];
-    return 0;
+    return MCRegister::NoRegister;
   }
 
   /// Get the minimum register cost in RC's allocation order.
   /// This is the smallest value in RegCosts[Reg] for all
   /// the registers in getOrder(RC).
-  uint8_t getMinCost(const TargetRegisterClass *RC) { return get(RC).MinCost; }
+  uint8_t getMinCost(const TargetRegisterClass *RC) const {
+    return get(RC).MinCost;
+  }
 
   /// Get the position of the last cost change in getOrder(RC).
   ///
   /// All registers in getOrder(RC).slice(getLastCostChange(RC)) will have the
   /// same cost according to RegCosts[Reg].
-  unsigned getLastCostChange(const TargetRegisterClass *RC) {
+  unsigned getLastCostChange(const TargetRegisterClass *RC) const {
     return get(RC).LastCostChange;
   }