@@ -334,6 +334,14 @@ static Register findScratchNonCalleeSaveRegister(MachineBasicBlock *MBB,
334334 bool HasCall = false );
335335static bool requiresSaveVG (const MachineFunction &MF);
336336
337+ enum class AssignObjectOffsets { No, Yes };
338+ // / Process all the SVE stack objects and the SVE stack size and offsets for
339+ // / each object. If AssignOffsets is "Yes", the offsets get assigned (and SVE
340+ // / stack sizes set). Returns the size of the SVE stack.
341+ static SVEStackSizes determineSVEStackSizes (MachineFunction &MF,
342+ AssignObjectOffsets AssignOffsets,
343+ bool SplitSVEObjects = false );
344+
337345static unsigned getStackHazardSize (const MachineFunction &MF) {
338346 return MF.getSubtarget <AArch64Subtarget>().getStreamingHazardSize ();
339347}
@@ -4176,7 +4184,7 @@ void AArch64FrameLowering::determineCalleeSaves(MachineFunction &MF,
41764184
41774185 // If any callee-saved registers are used, the frame cannot be eliminated.
41784186 auto [ZPRLocalStackSize, PPRLocalStackSize] =
4179- estimateSVEStackObjectOffsets (MF);
4187+ determineSVEStackSizes (MF, AssignObjectOffsets::No );
41804188 int64_t SVELocals = ZPRLocalStackSize + PPRLocalStackSize;
41814189 int64_t SVEStackSize =
41824190 alignTo (ZPRCSStackSize + PPRCSStackSize + SVELocals, 16 );
@@ -4410,15 +4418,11 @@ static bool getSVECalleeSaveSlotRange(const MachineFrameInfo &MFI,
44104418 return Min != std::numeric_limits<int >::max ();
44114419}
44124420
4413- // Process all the SVE stack objects and determine offsets for each
4414- // object. If AssignOffsets is true, the offsets get assigned.
4415- // Fills in the first and last callee-saved frame indices into
4416- // Min/MaxCSFrameIndex, respectively.
4417- // Returns the size of the stack.
4418- static SVEStackSizes
4419- determineSVEStackObjectOffsets (MachineFunction &MF, bool AssignOffsets,
4420- bool SplitSVEObjects = false ) {
4421+ static SVEStackSizes determineSVEStackSizes (MachineFunction &MF,
4422+ AssignObjectOffsets AssignOffsets,
4423+ bool SplitSVEObjects) {
44214424 MachineFrameInfo &MFI = MF.getFrameInfo ();
4425+ auto *AFI = MF.getInfo <AArch64FunctionInfo>();
44224426
44234427 SVEStackSizes SVEStack{};
44244428
@@ -4443,7 +4447,9 @@ determineSVEStackObjectOffsets(MachineFunction &MF, bool AssignOffsets,
44434447 : PPRStackTop;
44444448 };
44454449
4446- auto Assign = [&MFI](int FI, int64_t Offset) {
4450+ auto Assign = [&MFI, AssignOffsets](int FI, int64_t Offset) {
4451+ if (AssignOffsets == AssignObjectOffsets::No)
4452+ return ;
44474453 LLVM_DEBUG (dbgs () << " alloc FI(" << FI << " ) at SP[" << Offset << " ]\n " );
44484454 MFI.setObjectOffset (FI, Offset);
44494455 };
@@ -4455,8 +4461,7 @@ determineSVEStackObjectOffsets(MachineFunction &MF, bool AssignOffsets,
44554461 uint64_t &StackTop = StackForObject (FI, ZPRStackTop, PPRStackTop);
44564462 StackTop += MFI.getObjectSize (FI);
44574463 StackTop = alignTo (StackTop, MFI.getObjectAlign (FI));
4458- if (AssignOffsets)
4459- Assign (FI, -int64_t (StackTop));
4464+ Assign (FI, -int64_t (StackTop));
44604465 }
44614466 }
44624467
@@ -4501,25 +4506,16 @@ determineSVEStackObjectOffsets(MachineFunction &MF, bool AssignOffsets,
45014506
45024507 uint64_t &StackTop = StackForObject (FI, ZPRStackTop, PPRStackTop);
45034508 StackTop = alignTo (StackTop + MFI.getObjectSize (FI), Alignment);
4504- if (AssignOffsets)
4505- Assign (FI, -int64_t (StackTop));
4509+ Assign (FI, -int64_t (StackTop));
45064510 }
45074511
45084512 PPRStackTop = alignTo (PPRStackTop, Align (16U ));
45094513 ZPRStackTop = alignTo (ZPRStackTop, Align (16U ));
4510- return SVEStack;
4511- }
45124514
4513- SVEStackSizes
4514- AArch64FrameLowering::estimateSVEStackObjectOffsets (MachineFunction &MF) const {
4515- return determineSVEStackObjectOffsets (MF, false );
4516- }
4515+ if (AssignOffsets == AssignObjectOffsets::Yes)
4516+ AFI->setStackSizeSVE (SVEStack.ZPRStackSize , SVEStack.PPRStackSize );
45174517
4518- void AArch64FrameLowering::assignSVEStackObjectOffsets (
4519- MachineFunction &MF) const {
4520- auto [ZPRStackSize, PPRStackSize] = determineSVEStackObjectOffsets (MF, true );
4521- MF.getInfo <AArch64FunctionInfo>()->setStackSizeSVE (ZPRStackSize,
4522- PPRStackSize);
4518+ return SVEStack;
45234519}
45244520
45254521// / Attempts to scavenge a register from \p ScavengeableRegs given the used
@@ -4833,7 +4829,7 @@ void AArch64FrameLowering::processFunctionBeforeFrameFinalized(
48334829 assert (getStackGrowthDirection () == TargetFrameLowering::StackGrowsDown &&
48344830 " Upwards growing stack unsupported" );
48354831
4836- assignSVEStackObjectOffsets (MF );
4832+ ( void ) determineSVEStackSizes (MF, AssignObjectOffsets::Yes );
48374833
48384834 // If this function isn't doing Win64-style C++ EH, we don't need to do
48394835 // anything.
0 commit comments