[llvm] e902269 - [NFC][Regalloc] Type 2 statics in terms of Register

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 20 11:27:53 PDT 2020


Author: Mircea Trofin
Date: 2020-10-20T11:27:41-07:00
New Revision: e902269c493cafde23d031a825b4de5868194f6f

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

LOG: [NFC][Regalloc] Type 2 statics in terms of Register

Using Register instead of unsigned.

Also added isStack to mirror the other members, and eventually remove
the static testers.

Differential Revision: https://reviews.llvm.org/D89718

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/Register.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/Register.h b/llvm/include/llvm/CodeGen/Register.h
index 86dde8ed2903..d7057cfb76e0 100644
--- a/llvm/include/llvm/CodeGen/Register.h
+++ b/llvm/include/llvm/CodeGen/Register.h
@@ -40,20 +40,24 @@ class Register {
   /// frame index in a variable that normally holds a register. isStackSlot()
   /// returns true if Reg is in the range used for stack slots.
   ///
+  /// FIXME: remove in favor of member.
   static bool isStackSlot(unsigned Reg) {
     return MCRegister::isStackSlot(Reg);
   }
 
+  /// Return true if this is a stack slot.
+  bool isStack() const { return MCRegister::isStackSlot(Reg); }
+
   /// Compute the frame index from a register value representing a stack slot.
-  static int stackSlot2Index(unsigned Reg) {
-    assert(isStackSlot(Reg) && "Not a stack slot");
+  static int stackSlot2Index(Register Reg) {
+    assert(Reg.isStack() && "Not a stack slot");
     return int(Reg - MCRegister::FirstStackSlot);
   }
 
   /// Convert a non-negative frame index to a stack slot register value.
-  static unsigned index2StackSlot(int FI) {
+  static Register index2StackSlot(int FI) {
     assert(FI >= 0 && "Cannot hold a negative frame index.");
-    return FI + MCRegister::FirstStackSlot;
+    return Register(FI + MCRegister::FirstStackSlot);
   }
 
   /// Return true if the specified register number is in
@@ -70,14 +74,14 @@ class Register {
 
   /// Convert a virtual register number to a 0-based index.
   /// The first virtual register in a function will get the index 0.
-  static unsigned virtReg2Index(unsigned Reg) {
+  static unsigned virtReg2Index(Register Reg) {
     assert(isVirtualRegister(Reg) && "Not a virtual register");
     return Reg & ~MCRegister::VirtualRegFlag;
   }
 
   /// Convert a 0-based index to a virtual register number.
   /// This is the inverse operation of VirtReg2IndexFunctor below.
-  static unsigned index2VirtReg(unsigned Index) {
+  static Register index2VirtReg(unsigned Index) {
     assert(Index < (1u << 31) && "Index too large for virtual register range.");
     return Index | MCRegister::VirtualRegFlag;
   }


        


More information about the llvm-commits mailing list