Skip to content

Commit 42d08e6

Browse files
committed
Tweak naming
1 parent 3d178c0 commit 42d08e6

File tree

2 files changed

+55
-57
lines changed

2 files changed

+55
-57
lines changed

llvm/lib/Target/AArch64/AArch64PrologueEpilogue.cpp

Lines changed: 52 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -363,16 +363,17 @@ SVEFrameSizes AArch64PrologueEpilogueCommon::getSVEStackFrameSizes() const {
363363
StackOffset PPRLocalsSize = AFL.getPPRStackSize(MF) - PPRCalleeSavesSize;
364364
StackOffset ZPRLocalsSize = AFL.getZPRStackSize(MF) - ZPRCalleeSavesSize;
365365
if (AFI->hasSplitSVEObjects())
366-
return {PPRCalleeSavesSize, ZPRCalleeSavesSize, PPRLocalsSize,
367-
ZPRLocalsSize};
366+
return {{PPRCalleeSavesSize, PPRLocalsSize},
367+
{ZPRCalleeSavesSize, ZPRLocalsSize}};
368368
// For simplicity, attribute all locals to ZPRs when split SVE is disabled.
369-
return {PPRCalleeSavesSize, ZPRCalleeSavesSize, StackOffset{},
370-
PPRLocalsSize + ZPRLocalsSize};
369+
return {{PPRCalleeSavesSize, StackOffset{}},
370+
{ZPRCalleeSavesSize, PPRLocalsSize + ZPRLocalsSize}};
371371
}
372372

373373
struct SVEPartitions {
374-
MachineBasicBlock::iterator PPRBegin, PPREnd;
375-
MachineBasicBlock::iterator ZPRBegin, ZPREnd;
374+
struct {
375+
MachineBasicBlock::iterator Begin, End;
376+
} PPR, ZPR;
376377
};
377378

378379
static SVEPartitions partitionSVECS(MachineBasicBlock &MBB,
@@ -399,8 +400,8 @@ static SVEPartitions partitionSVECS(MachineBasicBlock &MBB,
399400
IsEpilogue ? (--ZPRsI) : (++ZPRsI);
400401
}
401402
if (IsEpilogue)
402-
return {PPRsI, MBBI, ZPRsI, PPRsI};
403-
return {MBBI, PPRsI, PPRsI, ZPRsI};
403+
return {{PPRsI, MBBI}, {ZPRsI, PPRsI}};
404+
return {{MBBI, PPRsI}, {PPRsI, ZPRsI}};
404405
}
405406

406407
AArch64PrologueEmitter::AArch64PrologueEmitter(MachineFunction &MF,
@@ -763,61 +764,59 @@ void AArch64PrologueEmitter::emitPrologue() {
763764
if (AFL.windowsRequiresStackProbe(MF, NumBytes + RealignmentPadding))
764765
emitWindowsStackProbe(AfterGPRSavesI, DL, NumBytes, RealignmentPadding);
765766

766-
assert(!(AFL.canUseRedZone(MF) && NeedsRealignment) &&
767-
"Cannot use redzone with stack realignment");
768-
769-
auto [PPRCalleeSavesSize, ZPRCalleeSavesSize, PPRLocalsSize, ZPRLocalsSize] =
770-
getSVEStackFrameSizes();
767+
auto [PPR, ZPR] = getSVEStackFrameSizes();
771768

772769
StackOffset NonSVELocalsSize = StackOffset::getFixed(NumBytes);
773-
StackOffset SVECalleeSavesSize = ZPRCalleeSavesSize + PPRCalleeSavesSize;
770+
StackOffset SVECalleeSavesSize = ZPR.CalleeSavesSize + PPR.CalleeSavesSize;
774771
StackOffset CFAOffset =
775772
StackOffset::getFixed(MFI.getStackSize()) - NonSVELocalsSize;
776773

777774
MachineBasicBlock::iterator AfterSVESavesI = AfterGPRSavesI;
778775
// Allocate space for the callee saves and PPR locals (if any).
779776
if (SVELayout != SVEStackLayout::CalleeSavesAboveFrameRecord) {
780-
SVEPartitions SVECSPartitions =
781-
partitionSVECS(MBB, AfterGPRSavesI, PPRCalleeSavesSize,
782-
ZPRCalleeSavesSize, /*IsEpilogue=*/false);
783-
AfterSVESavesI = SVECSPartitions.ZPREnd;
777+
auto [PPRRange, ZPRRange] =
778+
partitionSVECS(MBB, AfterGPRSavesI, PPR.CalleeSavesSize,
779+
ZPR.CalleeSavesSize, /*IsEpilogue=*/false);
780+
AfterSVESavesI = ZPRRange.End;
784781
if (EmitAsyncCFI)
785782
emitCalleeSavedSVELocations(AfterSVESavesI);
786783

787784
StackOffset AllocateBeforePPRs = SVECalleeSavesSize;
788-
StackOffset AllocateAfterPPRs = PPRLocalsSize;
785+
StackOffset AllocateAfterPPRs = PPR.LocalsSize;
789786
if (SVELayout == SVEStackLayout::Split) {
790-
AllocateBeforePPRs = PPRCalleeSavesSize;
791-
AllocateAfterPPRs = PPRLocalsSize + ZPRCalleeSavesSize;
787+
AllocateBeforePPRs = PPR.CalleeSavesSize;
788+
AllocateAfterPPRs = PPR.LocalsSize + ZPR.CalleeSavesSize;
792789
}
793-
allocateStackSpace(SVECSPartitions.PPRBegin, 0, AllocateBeforePPRs,
790+
allocateStackSpace(PPRRange.Begin, 0, AllocateBeforePPRs,
794791
EmitAsyncCFI && !HasFP, CFAOffset,
795792
MFI.hasVarSizedObjects() || AllocateAfterPPRs ||
796-
ZPRLocalsSize || NonSVELocalsSize);
793+
ZPR.LocalsSize || NonSVELocalsSize);
797794
CFAOffset += AllocateBeforePPRs;
798-
assert(SVECSPartitions.PPREnd == SVECSPartitions.ZPRBegin &&
795+
assert(PPRRange.End == ZPRRange.Begin &&
799796
"Expected ZPR callee saves after PPR locals");
800-
allocateStackSpace(SVECSPartitions.PPREnd, RealignmentPadding,
801-
AllocateAfterPPRs, EmitAsyncCFI && !HasFP, CFAOffset,
802-
MFI.hasVarSizedObjects() || ZPRLocalsSize ||
797+
allocateStackSpace(PPRRange.End, RealignmentPadding, AllocateAfterPPRs,
798+
EmitAsyncCFI && !HasFP, CFAOffset,
799+
MFI.hasVarSizedObjects() || ZPR.LocalsSize ||
803800
NonSVELocalsSize);
804801
CFAOffset += AllocateAfterPPRs;
805802
} else {
806803
// Note: With CalleeSavesAboveFrameRecord the SVE CS have already been
807804
// allocated (and separate PPRLocals are not supported).
808-
assert(!PPRLocalsSize && "Unexpected PPR locals!");
805+
assert(!PPR.LocalsSize && "Unexpected PPR locals!");
809806
CFAOffset += SVECalleeSavesSize;
810807
}
811808

812809
// Allocate space for the rest of the frame including ZPR locals. Align the
813810
// stack as necessary.
811+
assert(!(AFL.canUseRedZone(MF) && NeedsRealignment) &&
812+
"Cannot use redzone with stack realignment");
814813
if (!AFL.canUseRedZone(MF)) {
815814
// FIXME: in the case of dynamic re-alignment, NumBytes doesn't have the
816815
// correct value here, as NumBytes also includes padding bytes, which
817816
// shouldn't be counted here.
818-
allocateStackSpace(AfterSVESavesI, RealignmentPadding,
819-
ZPRLocalsSize + NonSVELocalsSize, EmitAsyncCFI && !HasFP,
820-
CFAOffset, MFI.hasVarSizedObjects());
817+
allocateStackSpace(
818+
AfterSVESavesI, RealignmentPadding, ZPR.LocalsSize + NonSVELocalsSize,
819+
EmitAsyncCFI && !HasFP, CFAOffset, MFI.hasVarSizedObjects());
821820
}
822821

823822
// If we need a base pointer, set it up here. It's whatever the value of the
@@ -1439,24 +1438,24 @@ void AArch64EpilogueEmitter::emitEpilogue() {
14391438
NumBytes -= PrologueSaveSize;
14401439
assert(NumBytes >= 0 && "Negative stack allocation size!?");
14411440

1442-
auto [PPRCalleeSavesSize, ZPRCalleeSavesSize, PPRLocalsSize, ZPRLocalsSize] =
1443-
getSVEStackFrameSizes();
1444-
StackOffset SVECalleeSavesSize = ZPRCalleeSavesSize + PPRCalleeSavesSize;
1445-
StackOffset SVEStackSize = SVECalleeSavesSize + PPRLocalsSize + ZPRLocalsSize;
1441+
auto [PPR, ZPR] = getSVEStackFrameSizes();
1442+
StackOffset SVECalleeSavesSize = ZPR.CalleeSavesSize + PPR.CalleeSavesSize;
1443+
StackOffset SVEStackSize =
1444+
SVECalleeSavesSize + PPR.LocalsSize + ZPR.LocalsSize;
14461445

1447-
auto SVECSPartitions = partitionSVECS(
1446+
auto [PPRRange, ZPRRange] = partitionSVECS(
14481447
MBB,
14491448
SVELayout == SVEStackLayout::CalleeSavesAboveFrameRecord
14501449
? MBB.getFirstTerminator()
14511450
: FirstGPRRestoreI,
1452-
PPRCalleeSavesSize, ZPRCalleeSavesSize, /*IsEpilogue=*/true);
1451+
PPR.CalleeSavesSize, ZPR.CalleeSavesSize, /*IsEpilogue=*/true);
14531452

1454-
MachineBasicBlock::iterator RestoreBegin = SVECSPartitions.ZPRBegin;
1455-
MachineBasicBlock::iterator RestoreEnd = SVECSPartitions.PPREnd;
1453+
MachineBasicBlock::iterator RestoreBegin = ZPRRange.Begin;
1454+
MachineBasicBlock::iterator RestoreEnd = PPRRange.End;
14561455

14571456
// Deallocate the SVE area.
14581457
if (SVELayout == SVEStackLayout::CalleeSavesAboveFrameRecord) {
1459-
StackOffset SVELocalsSize = ZPRLocalsSize + PPRLocalsSize;
1458+
StackOffset SVELocalsSize = ZPR.LocalsSize + PPR.LocalsSize;
14601459
// If the callee-save area is before FP, restoring the FP implicitly
14611460
// deallocates non-callee-save SVE allocations. Otherwise, deallocate them
14621461
// explicitly.
@@ -1481,8 +1480,6 @@ void AArch64EpilogueEmitter::emitEpilogue() {
14811480
SVECalleeSavesSize, TII, MachineInstr::FrameDestroy, false,
14821481
NeedsWinCFI, &HasWinCFI);
14831482
} else if (AFI->hasSVEStackSize()) {
1484-
auto [PPRRestoreBegin, PPRRestoreEnd, ZPRRestoreBegin, ZPRRestoreEnd] =
1485-
SVECSPartitions;
14861483
// If we have stack realignment or variable-sized objects we must use the FP
14871484
// to restore SVE callee saves (as there is an unknown amount of
14881485
// data/padding between the SP and SVE CS area).
@@ -1520,44 +1517,44 @@ void AArch64EpilogueEmitter::emitEpilogue() {
15201517
// Deallocate the non-SVE locals first before we can deallocate (and
15211518
// restore callee saves) from the SVE area.
15221519
auto NonSVELocals = StackOffset::getFixed(NumBytes);
1523-
emitFrameOffset(MBB, ZPRRestoreBegin, DL, AArch64::SP, AArch64::SP,
1520+
emitFrameOffset(MBB, ZPRRange.Begin, DL, AArch64::SP, AArch64::SP,
15241521
NonSVELocals, TII, MachineInstr::FrameDestroy, false,
15251522
NeedsWinCFI, &HasWinCFI, EmitCFI && !HasFP, CFAOffset);
15261523
CFAOffset -= NonSVELocals;
15271524
NumBytes = 0;
15281525
}
15291526

1530-
if (ZPRLocalsSize) {
1531-
emitFrameOffset(MBB, ZPRRestoreBegin, DL, AArch64::SP, AArch64::SP,
1532-
ZPRLocalsSize, TII, MachineInstr::FrameDestroy, false,
1527+
if (ZPR.LocalsSize) {
1528+
emitFrameOffset(MBB, ZPRRange.Begin, DL, AArch64::SP, AArch64::SP,
1529+
ZPR.LocalsSize, TII, MachineInstr::FrameDestroy, false,
15331530
NeedsWinCFI, &HasWinCFI, EmitCFI && !HasFP, CFAOffset);
1534-
CFAOffset -= ZPRLocalsSize;
1531+
CFAOffset -= ZPR.LocalsSize;
15351532
}
15361533

15371534
StackOffset SVECalleeSavesToDealloc = SVECalleeSavesSize;
15381535
if (SVELayout == SVEStackLayout::Split &&
1539-
(PPRLocalsSize || ZPRCalleeSavesSize)) {
1540-
assert(PPRRestoreBegin == ZPRRestoreEnd &&
1536+
(PPR.LocalsSize || ZPR.CalleeSavesSize)) {
1537+
assert(PPRRange.Begin == ZPRRange.End &&
15411538
"Expected PPR restores after ZPR");
1542-
emitFrameOffset(MBB, PPRRestoreBegin, DL, AArch64::SP, AArch64::SP,
1543-
PPRLocalsSize + ZPRCalleeSavesSize, TII,
1539+
emitFrameOffset(MBB, PPRRange.Begin, DL, AArch64::SP, AArch64::SP,
1540+
PPR.LocalsSize + ZPR.CalleeSavesSize, TII,
15441541
MachineInstr::FrameDestroy, false, NeedsWinCFI,
15451542
&HasWinCFI, EmitCFI && !HasFP, CFAOffset);
1546-
CFAOffset -= PPRLocalsSize + ZPRCalleeSavesSize;
1547-
SVECalleeSavesToDealloc -= ZPRCalleeSavesSize;
1543+
CFAOffset -= PPR.LocalsSize + ZPR.CalleeSavesSize;
1544+
SVECalleeSavesToDealloc -= ZPR.CalleeSavesSize;
15481545
}
15491546

15501547
// If split SVE is on, this dealloc PPRs, otherwise, deallocs ZPRs + PPRs:
15511548
if (SVECalleeSavesToDealloc)
1552-
emitFrameOffset(MBB, PPRRestoreEnd, DL, AArch64::SP, AArch64::SP,
1549+
emitFrameOffset(MBB, PPRRange.End, DL, AArch64::SP, AArch64::SP,
15531550
SVECalleeSavesToDealloc, TII,
15541551
MachineInstr::FrameDestroy, false, NeedsWinCFI,
15551552
&HasWinCFI, EmitCFI && !HasFP, CFAOffset);
15561553
}
15571554

15581555
if (EmitCFI)
15591556
emitCalleeSavedSVERestores(
1560-
SVELayout == SVEStackLayout::Split ? ZPRRestoreEnd : PPRRestoreEnd);
1557+
SVELayout == SVEStackLayout::Split ? ZPRRange.End : PPRRange.End);
15611558
}
15621559

15631560
if (!HasFP) {

llvm/lib/Target/AArch64/AArch64PrologueEpilogue.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ class AArch64FunctionInfo;
2828
class AArch64FrameLowering;
2929

3030
struct SVEFrameSizes {
31-
StackOffset PPRCalleeSavesSize, ZPRCalleeSavesSize;
32-
StackOffset PPRLocalsSize, ZPRLocalsSize;
31+
struct {
32+
StackOffset CalleeSavesSize, LocalsSize;
33+
} PPR, ZPR;
3334
};
3435

3536
class AArch64PrologueEpilogueCommon {

0 commit comments

Comments
 (0)