@@ -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}
@@ -4117,7 +4125,7 @@ void AArch64FrameLowering::determineCalleeSaves(MachineFunction &MF,
41174125
41184126 // If any callee-saved registers are used, the frame cannot be eliminated.
41194127 auto [ZPRLocalStackSize, PPRLocalStackSize] =
4120- estimateSVEStackObjectOffsets (MF);
4128+ determineSVEStackSizes (MF, AssignObjectOffsets::No );
41214129 int64_t SVELocals = ZPRLocalStackSize + PPRLocalStackSize;
41224130 int64_t SVEStackSize =
41234131 alignTo (ZPRCSStackSize + PPRCSStackSize + SVELocals, 16 );
@@ -4367,15 +4375,11 @@ static bool getSVECalleeSaveSlotRange(const MachineFrameInfo &MFI,
43674375 return Min != std::numeric_limits<int >::max ();
43684376}
43694377
4370- // Process all the SVE stack objects and determine offsets for each
4371- // object. If AssignOffsets is true, the offsets get assigned.
4372- // Fills in the first and last callee-saved frame indices into
4373- // Min/MaxCSFrameIndex, respectively.
4374- // Returns the size of the stack.
4375- static SVEStackSizes
4376- determineSVEStackObjectOffsets (MachineFunction &MF, bool AssignOffsets,
4377- bool SplitSVEObjects = false ) {
4378+ static SVEStackSizes determineSVEStackSizes (MachineFunction &MF,
4379+ AssignObjectOffsets AssignOffsets,
4380+ bool SplitSVEObjects) {
43784381 MachineFrameInfo &MFI = MF.getFrameInfo ();
4382+ auto *AFI = MF.getInfo <AArch64FunctionInfo>();
43794383
43804384 SVEStackSizes SVEStack{};
43814385
@@ -4400,7 +4404,9 @@ determineSVEStackObjectOffsets(MachineFunction &MF, bool AssignOffsets,
44004404 : PPRStackTop;
44014405 };
44024406
4403- auto Assign = [&MFI](int FI, int64_t Offset) {
4407+ auto Assign = [&MFI, AssignOffsets](int FI, int64_t Offset) {
4408+ if (AssignOffsets == AssignObjectOffsets::No)
4409+ return ;
44044410 LLVM_DEBUG (dbgs () << " alloc FI(" << FI << " ) at SP[" << Offset << " ]\n " );
44054411 MFI.setObjectOffset (FI, Offset);
44064412 };
@@ -4412,8 +4418,7 @@ determineSVEStackObjectOffsets(MachineFunction &MF, bool AssignOffsets,
44124418 uint64_t &StackTop = StackForObject (FI, ZPRStackTop, PPRStackTop);
44134419 StackTop += MFI.getObjectSize (FI);
44144420 StackTop = alignTo (StackTop, MFI.getObjectAlign (FI));
4415- if (AssignOffsets)
4416- Assign (FI, -int64_t (StackTop));
4421+ Assign (FI, -int64_t (StackTop));
44174422 }
44184423 }
44194424
@@ -4458,25 +4463,16 @@ determineSVEStackObjectOffsets(MachineFunction &MF, bool AssignOffsets,
44584463
44594464 uint64_t &StackTop = StackForObject (FI, ZPRStackTop, PPRStackTop);
44604465 StackTop = alignTo (StackTop + MFI.getObjectSize (FI), Alignment);
4461- if (AssignOffsets)
4462- Assign (FI, -int64_t (StackTop));
4466+ Assign (FI, -int64_t (StackTop));
44634467 }
44644468
44654469 PPRStackTop = alignTo (PPRStackTop, Align (16U ));
44664470 ZPRStackTop = alignTo (ZPRStackTop, Align (16U ));
4467- return SVEStack;
4468- }
44694471
4470- SVEStackSizes
4471- AArch64FrameLowering::estimateSVEStackObjectOffsets (MachineFunction &MF) const {
4472- return determineSVEStackObjectOffsets (MF, false );
4473- }
4472+ if (AssignOffsets == AssignObjectOffsets::Yes)
4473+ AFI->setStackSizeSVE (SVEStack.ZPRStackSize , SVEStack.PPRStackSize );
44744474
4475- void AArch64FrameLowering::assignSVEStackObjectOffsets (
4476- MachineFunction &MF) const {
4477- auto [ZPRStackSize, PPRStackSize] = determineSVEStackObjectOffsets (MF, true );
4478- MF.getInfo <AArch64FunctionInfo>()->setStackSizeSVE (ZPRStackSize,
4479- PPRStackSize);
4475+ return SVEStack;
44804476}
44814477
44824478// / Attempts to scavenge a register from \p ScavengeableRegs given the used
@@ -4790,7 +4786,7 @@ void AArch64FrameLowering::processFunctionBeforeFrameFinalized(
47904786 assert (getStackGrowthDirection () == TargetFrameLowering::StackGrowsDown &&
47914787 " Upwards growing stack unsupported" );
47924788
4793- assignSVEStackObjectOffsets (MF );
4789+ ( void ) determineSVEStackSizes (MF, AssignObjectOffsets::Yes );
47944790
47954791 // If this function isn't doing Win64-style C++ EH, we don't need to do
47964792 // anything.
0 commit comments