mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-19 02:25:01 +00:00
[StackMap] Use lambdas to specify the sort and erase conditions. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241823 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -152,13 +152,6 @@ public:
|
|||||||
unsigned short DwarfRegNum;
|
unsigned short DwarfRegNum;
|
||||||
unsigned short Size;
|
unsigned short Size;
|
||||||
|
|
||||||
void MarkInvalid() { Reg = 0; }
|
|
||||||
|
|
||||||
// Only sort by the dwarf register number.
|
|
||||||
bool operator<(const LiveOutReg &LO) const {
|
|
||||||
return DwarfRegNum < LO.DwarfRegNum;
|
|
||||||
}
|
|
||||||
static bool IsInvalid(const LiveOutReg &LO) { return LO.Reg == 0; }
|
|
||||||
LiveOutReg() : Reg(0), DwarfRegNum(0), Size(0) {}
|
LiveOutReg() : Reg(0), DwarfRegNum(0), Size(0) {}
|
||||||
LiveOutReg(unsigned short Reg, unsigned short DwarfRegNum,
|
LiveOutReg(unsigned short Reg, unsigned short DwarfRegNum,
|
||||||
unsigned short Size)
|
unsigned short Size)
|
||||||
|
@@ -248,10 +248,15 @@ StackMaps::parseRegisterLiveOutMask(const uint32_t *Mask) const {
|
|||||||
// We don't need to keep track of a register if its super-register is already
|
// We don't need to keep track of a register if its super-register is already
|
||||||
// in the list. Merge entries that refer to the same dwarf register and use
|
// in the list. Merge entries that refer to the same dwarf register and use
|
||||||
// the maximum size that needs to be spilled.
|
// the maximum size that needs to be spilled.
|
||||||
std::sort(LiveOuts.begin(), LiveOuts.end());
|
|
||||||
for (LiveOutVec::iterator I = LiveOuts.begin(), E = LiveOuts.end(); I != E;
|
std::sort(LiveOuts.begin(), LiveOuts.end(),
|
||||||
++I) {
|
[](const LiveOutReg &LHS, const LiveOutReg &RHS) {
|
||||||
for (LiveOutVec::iterator II = std::next(I); II != E; ++II) {
|
// Only sort by the dwarf register number.
|
||||||
|
return LHS.DwarfRegNum < RHS.DwarfRegNum;
|
||||||
|
});
|
||||||
|
|
||||||
|
for (auto I = LiveOuts.begin(), E = LiveOuts.end(); I != E; ++I) {
|
||||||
|
for (auto II = std::next(I); II != E; ++II) {
|
||||||
if (I->DwarfRegNum != II->DwarfRegNum) {
|
if (I->DwarfRegNum != II->DwarfRegNum) {
|
||||||
// Skip all the now invalid entries.
|
// Skip all the now invalid entries.
|
||||||
I = --II;
|
I = --II;
|
||||||
@@ -260,12 +265,15 @@ StackMaps::parseRegisterLiveOutMask(const uint32_t *Mask) const {
|
|||||||
I->Size = std::max(I->Size, II->Size);
|
I->Size = std::max(I->Size, II->Size);
|
||||||
if (TRI->isSuperRegister(I->Reg, II->Reg))
|
if (TRI->isSuperRegister(I->Reg, II->Reg))
|
||||||
I->Reg = II->Reg;
|
I->Reg = II->Reg;
|
||||||
II->MarkInvalid();
|
II->Reg = 0; // mark for deletion.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LiveOuts.erase(
|
LiveOuts.erase(
|
||||||
std::remove_if(LiveOuts.begin(), LiveOuts.end(), LiveOutReg::IsInvalid),
|
std::remove_if(LiveOuts.begin(), LiveOuts.end(),
|
||||||
|
[](const LiveOutReg &LO) { return LO.Reg == 0; }),
|
||||||
LiveOuts.end());
|
LiveOuts.end());
|
||||||
|
|
||||||
return LiveOuts;
|
return LiveOuts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user