Skip to content

Commit 92ddbbd

Browse files
committed
[CodeGen] Remove static member functions Register::stackSlot2Index/isStackSlot. NFC
Migrate the few users to the nonstatic member functions.
1 parent 57bac14 commit 92ddbbd

File tree

4 files changed

+7
-23
lines changed

4 files changed

+7
-23
lines changed

llvm/include/llvm/CodeGen/RDFRegisters.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ struct RegisterRef {
116116
static constexpr bool isUnitId(unsigned Id) {
117117
return Register::isVirtualRegister(Id);
118118
}
119-
static constexpr bool isMaskId(unsigned Id) {
120-
return Register::isStackSlot(Id);
121-
}
119+
static constexpr bool isMaskId(unsigned Id) { return Register(Id).isStack(); }
122120

123121
static constexpr RegisterId toUnitId(unsigned Idx) {
124122
return Idx | MCRegister::VirtualRegFlag;
@@ -147,7 +145,7 @@ struct PhysicalRegisterInfo {
147145
}
148146

149147
const uint32_t *getRegMaskBits(RegisterId R) const {
150-
return RegMasks.get(Register::stackSlot2Index(R));
148+
return RegMasks.get(Register(R).stackSlotIndex());
151149
}
152150

153151
bool alias(RegisterRef RA, RegisterRef RB) const;
@@ -160,7 +158,7 @@ struct PhysicalRegisterInfo {
160158
}
161159

162160
const BitVector &getMaskUnits(RegisterId MaskId) const {
163-
return MaskInfos[Register::stackSlot2Index(MaskId)].Units;
161+
return MaskInfos[Register(MaskId).stackSlotIndex()].Units;
164162
}
165163

166164
std::set<RegisterId> getUnits(RegisterRef RR) const;

llvm/include/llvm/CodeGen/Register.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,12 @@ class Register {
3636
static_assert(std::numeric_limits<decltype(Reg)>::max() >= 0xFFFFFFFF,
3737
"Reg isn't large enough to hold full range.");
3838

39-
/// isStackSlot - Sometimes it is useful to be able to store a non-negative
40-
/// frame index in a variable that normally holds a register. isStackSlot()
41-
/// returns true if Reg is in the range used for stack slots.
42-
///
43-
/// FIXME: remove in favor of member.
44-
static constexpr bool isStackSlot(unsigned Reg) {
39+
/// Return true if this is a stack slot.
40+
constexpr bool isStack() const {
4541
return MCRegister::FirstStackSlot <= Reg &&
4642
Reg < MCRegister::VirtualRegFlag;
4743
}
4844

49-
/// Return true if this is a stack slot.
50-
constexpr bool isStack() const { return isStackSlot(Reg); }
51-
52-
/// Compute the frame index from a register value representing a stack slot.
53-
static int stackSlot2Index(Register Reg) {
54-
assert(Reg.isStack() && "Not a stack slot");
55-
return int(Reg.id() - MCRegister::FirstStackSlot);
56-
}
57-
5845
/// Convert a non-negative frame index to a stack slot register value.
5946
static Register index2StackSlot(int FI) {
6047
assert(FI >= 0 && "Cannot hold a negative frame index.");

llvm/lib/CodeGen/InlineSpiller.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,8 +1285,7 @@ void InlineSpiller::spillAll() {
12851285
void InlineSpiller::spill(LiveRangeEdit &edit) {
12861286
++NumSpilledRanges;
12871287
Edit = &edit;
1288-
assert(!Register::isStackSlot(edit.getReg()) &&
1289-
"Trying to spill a stack slot.");
1288+
assert(!edit.getReg().isStack() && "Trying to spill a stack slot.");
12901289
// Share a stack slot among all descendants of Original.
12911290
Original = VRM.getOriginal(edit.getReg());
12921291
StackSlot = VRM.getStackSlot(Original);

llvm/lib/CodeGen/RDFRegisters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void PhysicalRegisterInfo::print(raw_ostream &OS, RegisterRef A) const {
263263
} else {
264264
assert(A.isMask());
265265
// RegMask SS flag is preserved by idx().
266-
unsigned Idx = Register::stackSlot2Index(A.idx());
266+
unsigned Idx = Register(A.idx()).stackSlotIndex();
267267
const char *Fmt = Idx < 0x10000 ? "%04x" : "%08x";
268268
OS << "M#" << format(Fmt, Idx);
269269
}

0 commit comments

Comments
 (0)