-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[TRI] Remove reserved registers in getRegPressureSetLimit #118787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: users/wangpc-pp/spr/main.tri-remove-reserved-registers-in-getregpressuresetlimit
Are you sure you want to change the base?
Changes from all commits
2ec06c7
fae615d
723597a
5adec35
9737ec8
538b48d
f5de3e9
47c3275
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -715,6 +715,49 @@ TargetRegisterInfo::prependOffsetExpression(const DIExpression *Expr, | |
PrependFlags & DIExpression::EntryValue); | ||
} | ||
|
||
unsigned TargetRegisterInfo::getRegPressureSetLimit(const MachineFunction &MF, | ||
wangpc-pp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
unsigned Idx) const { | ||
const TargetRegisterClass *RC = nullptr; | ||
unsigned NumRCUnits = 0; | ||
for (const TargetRegisterClass *C : regclasses()) { | ||
const int *PSetID = getRegClassPressureSets(C); | ||
for (; *PSetID != -1; ++PSetID) { | ||
if ((unsigned)*PSetID == Idx) | ||
break; | ||
} | ||
if (*PSetID == -1) | ||
continue; | ||
|
||
// Found a register class that counts against this pressure set. | ||
// For efficiency, only compute the set order for the largest set. | ||
unsigned NUnits = getRegClassWeight(C).WeightLimit; | ||
if (!RC || NUnits > NumRCUnits) { | ||
RC = C; | ||
NumRCUnits = NUnits; | ||
} | ||
} | ||
assert(RC && "Failed to find register class"); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason we drop the call to
It looks like this is related to what is in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason why we need a // ...
compute(RC);
unsigned NAllocatableRegs = getNumAllocatableRegs(RC);
// ...
unsigned NReserved = RC->getNumRegs() - NAllocatableRegs; unsigned getNumAllocatableRegs(const TargetRegisterClass *RC) const {
return get(RC).NumRegs;
} The logic of calculating // FIXME: Once targets reserve registers instead of removing them from the
// allocation order, we can simply use begin/end here.
ArrayRef<MCPhysReg> RawOrder = RC->getRawAllocationOrder(*MF);
for (unsigned PhysReg : RawOrder) {
// Remove reserved registers from the allocation order.
if (Reserved.test(PhysReg))
continue;
uint8_t Cost = RegCosts[PhysReg];
MinCost = std::min(MinCost, Cost);
if (getLastCalleeSavedAlias(PhysReg) &&
!STI.ignoreCSRForAllocationOrder(*MF, PhysReg))
// PhysReg aliases a CSR, save it for later.
CSRAlias.push_back(PhysReg);
else {
if (Cost != LastCost)
LastCostChange = N;
RCI.Order[N++] = PhysReg;
LastCost = Cost;
}
}
RCI.NumRegs = N + CSRAlias.size();
|
||
unsigned NAllocatableRegs = 0; | ||
const BitVector &Reserved = MF.getRegInfo().getReservedRegs(); | ||
for (MCPhysReg PhysReg : RC->getRawAllocationOrder(MF)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's still the pre-existing bug where the pressure number is wrong for overlapping registers in the allocation order, and should probably be reporting number of distinct allocatable registers There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I already had a WIP patch to generate the mapping from pressure set to RegisterClass, I wil post it when it's ready. |
||
if (!Reserved.test(PhysReg)) | ||
NAllocatableRegs++; | ||
|
||
unsigned RegPressureSetLimit = getRawRegPressureSetLimit(MF, Idx); | ||
// If all the regs are reserved, return raw RegPressureSetLimit. | ||
// One example is VRSAVERC in PowerPC. | ||
// Avoid returning zero, RegisterClassInfo::getRegPressureSetLimit(Idx) | ||
// assumes this returns non-zero value. | ||
if (NAllocatableRegs == 0) { | ||
LLVM_DEBUG(dbgs() << "All registers of " << getRegClassName(RC) | ||
<< " are reserved!\n";); | ||
return RegPressureSetLimit; | ||
} | ||
unsigned NReserved = RC->getNumRegs() - NAllocatableRegs; | ||
return RegPressureSetLimit - getRegClassWeight(RC).RegWeight * NReserved; | ||
} | ||
|
||
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) | ||
LLVM_DUMP_METHOD | ||
void TargetRegisterInfo::dumpReg(Register Reg, unsigned SubRegIndex, | ||
|
Uh oh!
There was an error while loading. Please reload this page.