@@ -334,6 +334,14 @@ static Register findScratchNonCalleeSaveRegister(MachineBasicBlock *MBB,
334
334
bool HasCall = false );
335
335
static bool requiresSaveVG (const MachineFunction &MF);
336
336
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
+
337
345
static unsigned getStackHazardSize (const MachineFunction &MF) {
338
346
return MF.getSubtarget <AArch64Subtarget>().getStreamingHazardSize ();
339
347
}
@@ -4117,7 +4125,7 @@ void AArch64FrameLowering::determineCalleeSaves(MachineFunction &MF,
4117
4125
4118
4126
// If any callee-saved registers are used, the frame cannot be eliminated.
4119
4127
auto [ZPRLocalStackSize, PPRLocalStackSize] =
4120
- estimateSVEStackObjectOffsets (MF);
4128
+ determineSVEStackSizes (MF, AssignObjectOffsets::No );
4121
4129
int64_t SVELocals = ZPRLocalStackSize + PPRLocalStackSize;
4122
4130
int64_t SVEStackSize =
4123
4131
alignTo (ZPRCSStackSize + PPRCSStackSize + SVELocals, 16 );
@@ -4367,15 +4375,11 @@ static bool getSVECalleeSaveSlotRange(const MachineFrameInfo &MFI,
4367
4375
return Min != std::numeric_limits<int >::max ();
4368
4376
}
4369
4377
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) {
4378
4381
MachineFrameInfo &MFI = MF.getFrameInfo ();
4382
+ auto *AFI = MF.getInfo <AArch64FunctionInfo>();
4379
4383
4380
4384
SVEStackSizes SVEStack{};
4381
4385
@@ -4400,7 +4404,9 @@ determineSVEStackObjectOffsets(MachineFunction &MF, bool AssignOffsets,
4400
4404
: PPRStackTop;
4401
4405
};
4402
4406
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 ;
4404
4410
LLVM_DEBUG (dbgs () << " alloc FI(" << FI << " ) at SP[" << Offset << " ]\n " );
4405
4411
MFI.setObjectOffset (FI, Offset);
4406
4412
};
@@ -4412,8 +4418,7 @@ determineSVEStackObjectOffsets(MachineFunction &MF, bool AssignOffsets,
4412
4418
uint64_t &StackTop = StackForObject (FI, ZPRStackTop, PPRStackTop);
4413
4419
StackTop += MFI.getObjectSize (FI);
4414
4420
StackTop = alignTo (StackTop, MFI.getObjectAlign (FI));
4415
- if (AssignOffsets)
4416
- Assign (FI, -int64_t (StackTop));
4421
+ Assign (FI, -int64_t (StackTop));
4417
4422
}
4418
4423
}
4419
4424
@@ -4458,25 +4463,16 @@ determineSVEStackObjectOffsets(MachineFunction &MF, bool AssignOffsets,
4458
4463
4459
4464
uint64_t &StackTop = StackForObject (FI, ZPRStackTop, PPRStackTop);
4460
4465
StackTop = alignTo (StackTop + MFI.getObjectSize (FI), Alignment);
4461
- if (AssignOffsets)
4462
- Assign (FI, -int64_t (StackTop));
4466
+ Assign (FI, -int64_t (StackTop));
4463
4467
}
4464
4468
4465
4469
PPRStackTop = alignTo (PPRStackTop, Align (16U ));
4466
4470
ZPRStackTop = alignTo (ZPRStackTop, Align (16U ));
4467
- return SVEStack;
4468
- }
4469
4471
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 );
4474
4474
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;
4480
4476
}
4481
4477
4482
4478
// / Attempts to scavenge a register from \p ScavengeableRegs given the used
@@ -4790,7 +4786,7 @@ void AArch64FrameLowering::processFunctionBeforeFrameFinalized(
4790
4786
assert (getStackGrowthDirection () == TargetFrameLowering::StackGrowsDown &&
4791
4787
" Upwards growing stack unsupported" );
4792
4788
4793
- assignSVEStackObjectOffsets (MF );
4789
+ ( void ) determineSVEStackSizes (MF, AssignObjectOffsets::Yes );
4794
4790
4795
4791
// If this function isn't doing Win64-style C++ EH, we don't need to do
4796
4792
// anything.
0 commit comments