diff --git a/llvm/include/llvm/CodeGen/RDFRegisters.h b/llvm/include/llvm/CodeGen/RDFRegisters.h index 7eed0b4e1e7b..dcce190f0f30 100644 --- a/llvm/include/llvm/CodeGen/RDFRegisters.h +++ b/llvm/include/llvm/CodeGen/RDFRegisters.h @@ -116,9 +116,7 @@ struct RegisterRef { static constexpr bool isUnitId(unsigned Id) { return Register::isVirtualRegister(Id); } - static constexpr bool isMaskId(unsigned Id) { - return Register::isStackSlot(Id); - } + static constexpr bool isMaskId(unsigned Id) { return Register(Id).isStack(); } static constexpr RegisterId toUnitId(unsigned Idx) { return Idx | MCRegister::VirtualRegFlag; @@ -147,7 +145,7 @@ struct PhysicalRegisterInfo { } const uint32_t *getRegMaskBits(RegisterId R) const { - return RegMasks.get(Register::stackSlot2Index(R)); + return RegMasks.get(Register(R).stackSlotIndex()); } bool alias(RegisterRef RA, RegisterRef RB) const; @@ -160,7 +158,7 @@ struct PhysicalRegisterInfo { } const BitVector &getMaskUnits(RegisterId MaskId) const { - return MaskInfos[Register::stackSlot2Index(MaskId)].Units; + return MaskInfos[Register(MaskId).stackSlotIndex()].Units; } std::set getUnits(RegisterRef RR) const; diff --git a/llvm/include/llvm/CodeGen/Register.h b/llvm/include/llvm/CodeGen/Register.h index ad05368bea6a..b5ffe079de12 100644 --- a/llvm/include/llvm/CodeGen/Register.h +++ b/llvm/include/llvm/CodeGen/Register.h @@ -36,25 +36,12 @@ public: static_assert(std::numeric_limits::max() >= 0xFFFFFFFF, "Reg isn't large enough to hold full range."); - /// isStackSlot - Sometimes it is useful to be able to store a non-negative - /// 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 constexpr bool isStackSlot(unsigned Reg) { + /// Return true if this is a stack slot. + constexpr bool isStack() const { return MCRegister::FirstStackSlot <= Reg && Reg < MCRegister::VirtualRegFlag; } - /// Return true if this is a stack slot. - constexpr bool isStack() const { return isStackSlot(Reg); } - - /// Compute the frame index from a register value representing a stack slot. - static int stackSlot2Index(Register Reg) { - assert(Reg.isStack() && "Not a stack slot"); - return int(Reg.id() - MCRegister::FirstStackSlot); - } - /// Convert a non-negative frame index to a stack slot register value. static Register index2StackSlot(int FI) { assert(FI >= 0 && "Cannot hold a negative frame index."); diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp index 302dd37ff3d6..3834a6d7a355 100644 --- a/llvm/lib/CodeGen/InlineSpiller.cpp +++ b/llvm/lib/CodeGen/InlineSpiller.cpp @@ -1285,8 +1285,7 @@ void InlineSpiller::spillAll() { void InlineSpiller::spill(LiveRangeEdit &edit) { ++NumSpilledRanges; Edit = &edit; - assert(!Register::isStackSlot(edit.getReg()) && - "Trying to spill a stack slot."); + assert(!edit.getReg().isStack() && "Trying to spill a stack slot."); // Share a stack slot among all descendants of Original. Original = VRM.getOriginal(edit.getReg()); StackSlot = VRM.getStackSlot(Original); diff --git a/llvm/lib/CodeGen/RDFRegisters.cpp b/llvm/lib/CodeGen/RDFRegisters.cpp index 7ce00a66b3ae..b8d54cadc07f 100644 --- a/llvm/lib/CodeGen/RDFRegisters.cpp +++ b/llvm/lib/CodeGen/RDFRegisters.cpp @@ -263,7 +263,7 @@ void PhysicalRegisterInfo::print(raw_ostream &OS, RegisterRef A) const { } else { assert(A.isMask()); // RegMask SS flag is preserved by idx(). - unsigned Idx = Register::stackSlot2Index(A.idx()); + unsigned Idx = Register(A.idx()).stackSlotIndex(); const char *Fmt = Idx < 0x10000 ? "%04x" : "%08x"; OS << "M#" << format(Fmt, Idx); }