@@ -4285,7 +4285,7 @@ static void expandSpillPPRToZPRSlotPseudo(MachineBasicBlock &MBB,
4285
4285
MachineInstr &MI,
4286
4286
const TargetRegisterInfo &TRI,
4287
4287
LiveRegUnits const &UsedRegs,
4288
- ScavengeableRegs const &Regs ,
4288
+ ScavengeableRegs const &SR ,
4289
4289
EmergencyStackSlots &SpillSlots) {
4290
4290
MachineFunction &MF = *MBB.getParent ();
4291
4291
auto *TII =
@@ -4294,7 +4294,7 @@ static void expandSpillPPRToZPRSlotPseudo(MachineBasicBlock &MBB,
4294
4294
Register ZPredReg = AArch64::NoRegister;
4295
4295
ScopedScavengeOrSpill FindZPRReg (
4296
4296
MF, MBB, MachineBasicBlock::iterator (MI), ZPredReg, AArch64::Z0,
4297
- AArch64::ZPRRegClass, UsedRegs, Regs .ZPRRegs ,
4297
+ AArch64::ZPRRegClass, UsedRegs, SR .ZPRRegs ,
4298
4298
isInPrologueOrEpilogue (MI) ? nullptr : &SpillSlots.ZPRSpillFI );
4299
4299
4300
4300
SmallVector<MachineInstr *, 2 > MachineInstrs;
@@ -4332,7 +4332,7 @@ static bool expandFillPPRFromZPRSlotPseudo(MachineBasicBlock &MBB,
4332
4332
MachineInstr &MI,
4333
4333
const TargetRegisterInfo &TRI,
4334
4334
LiveRegUnits const &UsedRegs,
4335
- ScavengeableRegs const &Regs ,
4335
+ ScavengeableRegs const &SR ,
4336
4336
EmergencyStackSlots &SpillSlots) {
4337
4337
MachineFunction &MF = *MBB.getParent ();
4338
4338
auto *TII =
@@ -4341,13 +4341,13 @@ static bool expandFillPPRFromZPRSlotPseudo(MachineBasicBlock &MBB,
4341
4341
Register ZPredReg = AArch64::NoRegister;
4342
4342
ScopedScavengeOrSpill FindZPRReg (
4343
4343
MF, MBB, MachineBasicBlock::iterator (MI), ZPredReg, AArch64::Z0,
4344
- AArch64::ZPRRegClass, UsedRegs, Regs .ZPRRegs ,
4344
+ AArch64::ZPRRegClass, UsedRegs, SR .ZPRRegs ,
4345
4345
isInPrologueOrEpilogue (MI) ? nullptr : &SpillSlots.ZPRSpillFI );
4346
4346
4347
4347
Register PredReg = AArch64::NoRegister;
4348
4348
ScopedScavengeOrSpill FindPPR3bReg (
4349
4349
MF, MBB, MachineBasicBlock::iterator (MI), PredReg, AArch64::P0,
4350
- AArch64::PPR_3bRegClass, UsedRegs, Regs .PPR3bRegs ,
4350
+ AArch64::PPR_3bRegClass, UsedRegs, SR .PPR3bRegs ,
4351
4351
isInPrologueOrEpilogue (MI) ? nullptr : &SpillSlots.PPRSpillFI );
4352
4352
4353
4353
// Elide NZCV spills if we know it is not used.
@@ -4357,7 +4357,7 @@ static bool expandFillPPRFromZPRSlotPseudo(MachineBasicBlock &MBB,
4357
4357
if (IsNZCVUsed)
4358
4358
FindGPRReg.emplace (
4359
4359
MF, MBB, MachineBasicBlock::iterator (MI), NZCVSaveReg, AArch64::X0,
4360
- AArch64::GPR64RegClass, UsedRegs, Regs .GPRRegs ,
4360
+ AArch64::GPR64RegClass, UsedRegs, SR .GPRRegs ,
4361
4361
isInPrologueOrEpilogue (MI) ? nullptr : &SpillSlots.GPRSpillFI );
4362
4362
SmallVector<MachineInstr *, 4 > MachineInstrs;
4363
4363
const DebugLoc &DL = MI.getDebugLoc ();
@@ -4397,27 +4397,23 @@ static bool expandFillPPRFromZPRSlotPseudo(MachineBasicBlock &MBB,
4397
4397
4398
4398
// / Expands all FILL_PPR_FROM_ZPR_SLOT_PSEUDO and SPILL_PPR_TO_ZPR_SLOT_PSEUDO
4399
4399
// / operations within the MachineBasicBlock \p MBB.
4400
- static bool expandSMEPPRToZPRSpillPseudos (
4401
- MachineBasicBlock &MBB, const TargetRegisterInfo &TRI,
4402
- ScavengeableRegs const &ScavengeableRegsBody,
4403
- ScavengeableRegs const &ScavengeableRegsFrameSetup,
4404
- EmergencyStackSlots &SpillSlots) {
4400
+ static bool expandSMEPPRToZPRSpillPseudos (MachineBasicBlock &MBB,
4401
+ const TargetRegisterInfo &TRI,
4402
+ ScavengeableRegs const &SR,
4403
+ EmergencyStackSlots &SpillSlots) {
4405
4404
LiveRegUnits UsedRegs (TRI);
4406
4405
UsedRegs.addLiveOuts (MBB);
4407
4406
bool HasPPRSpills = false ;
4408
4407
for (MachineInstr &MI : make_early_inc_range (reverse (MBB))) {
4409
4408
UsedRegs.stepBackward (MI);
4410
- ScavengeableRegs const &Regs = isInPrologueOrEpilogue (MI)
4411
- ? ScavengeableRegsFrameSetup
4412
- : ScavengeableRegsBody;
4413
4409
switch (MI.getOpcode ()) {
4414
4410
case AArch64::FILL_PPR_FROM_ZPR_SLOT_PSEUDO:
4415
- HasPPRSpills |= expandFillPPRFromZPRSlotPseudo (MBB, MI, TRI, UsedRegs,
4416
- Regs, SpillSlots);
4411
+ HasPPRSpills |= expandFillPPRFromZPRSlotPseudo (MBB, MI, TRI, UsedRegs, SR,
4412
+ SpillSlots);
4417
4413
MI.eraseFromParent ();
4418
4414
break ;
4419
4415
case AArch64::SPILL_PPR_TO_ZPR_SLOT_PSEUDO:
4420
- expandSpillPPRToZPRSlotPseudo (MBB, MI, TRI, UsedRegs, Regs , SpillSlots);
4416
+ expandSpillPPRToZPRSlotPseudo (MBB, MI, TRI, UsedRegs, SR , SpillSlots);
4421
4417
MI.eraseFromParent ();
4422
4418
break ;
4423
4419
default :
@@ -4434,56 +4430,21 @@ void AArch64FrameLowering::processFunctionBeforeFrameFinalized(
4434
4430
AArch64FunctionInfo *AFI = MF.getInfo <AArch64FunctionInfo>();
4435
4431
const TargetSubtargetInfo &TSI = MF.getSubtarget ();
4436
4432
const TargetRegisterInfo &TRI = *TSI.getRegisterInfo ();
4437
- if (AFI->hasStackFrame () && TRI.getSpillSize (AArch64::PPRRegClass) == 16 ) {
4438
- // If predicates spills are 16-bytes we may need to expand
4439
- // SPILL_PPR_TO_ZPR_SLOT_PSEUDO/FILL_PPR_FROM_ZPR_SLOT_PSEUDO.
4440
-
4441
- const uint32_t *CSRMask =
4442
- TRI.getCallPreservedMask (MF, MF.getFunction ().getCallingConv ());
4443
4433
4434
+ // If predicates spills are 16-bytes we may need to expand
4435
+ // SPILL_PPR_TO_ZPR_SLOT_PSEUDO/FILL_PPR_FROM_ZPR_SLOT_PSEUDO.
4436
+ if (AFI->hasStackFrame () && TRI.getSpillSize (AArch64::PPRRegClass) == 16 ) {
4444
4437
auto ComputeScavengeableRegisters = [&](unsigned RegClassID) {
4445
4438
BitVector Regs = TRI.getAllocatableSet (MF, TRI.getRegClass (RegClassID));
4446
- if (CSRMask)
4447
- Regs.clearBitsInMask (CSRMask);
4448
4439
assert (Regs.count () > 0 && " Expected scavengeable registers" );
4449
4440
return Regs;
4450
4441
};
4451
4442
4452
- // Registers free to scavenge in the prologue/epilogue.
4453
- ScavengeableRegs ScavengeableRegsFrameSetup;
4454
- ScavengeableRegsFrameSetup.ZPRRegs =
4455
- ComputeScavengeableRegisters (AArch64::ZPRRegClassID);
4443
+ ScavengeableRegs SR{};
4444
+ SR.ZPRRegs = ComputeScavengeableRegisters (AArch64::ZPRRegClassID);
4456
4445
// Only p0-7 are possible as the second operand of cmpne (needed for fills).
4457
- ScavengeableRegsFrameSetup.PPR3bRegs =
4458
- ComputeScavengeableRegisters (AArch64::PPR_3bRegClassID);
4459
- ScavengeableRegsFrameSetup.GPRRegs =
4460
- ComputeScavengeableRegisters (AArch64::GPR64RegClassID);
4461
-
4462
- const MachineFrameInfo &MFI = MF.getFrameInfo ();
4463
- assert (MFI.isCalleeSavedInfoValid ());
4464
- const std::vector<CalleeSavedInfo> &CSI = MFI.getCalleeSavedInfo ();
4465
- auto MarkSavedRegistersAsAvailable =
4466
- [&, &Reserved = MF.getRegInfo ().getReservedRegs ()](
4467
- BitVector &Regs, unsigned RegClassID) {
4468
- for (const CalleeSavedInfo &I : CSI)
4469
- if (!Reserved[I.getReg ()] &&
4470
- TRI.getRegClass (RegClassID)->contains (I.getReg ()))
4471
- Regs.set (I.getReg ());
4472
- };
4473
-
4474
- // Registers free to scavenge in the function body.
4475
- ScavengeableRegs ScavengeableRegsBody = ScavengeableRegsFrameSetup;
4476
- MarkSavedRegistersAsAvailable (ScavengeableRegsBody.ZPRRegs ,
4477
- AArch64::ZPRRegClassID);
4478
- MarkSavedRegistersAsAvailable (ScavengeableRegsBody.PPR3bRegs ,
4479
- AArch64::PPR_3bRegClassID);
4480
- MarkSavedRegistersAsAvailable (ScavengeableRegsBody.GPRRegs ,
4481
- AArch64::GPR64RegClassID);
4482
-
4483
- // p4 (CSR) is reloaded last in the epilogue, so if it is saved, it can be
4484
- // used to reload other predicates.
4485
- if (ScavengeableRegsBody.PPR3bRegs [AArch64::P4])
4486
- ScavengeableRegsFrameSetup.PPR3bRegs .set (AArch64::P4);
4446
+ SR.PPR3bRegs = ComputeScavengeableRegisters (AArch64::PPR_3bRegClassID);
4447
+ SR.GPRRegs = ComputeScavengeableRegisters (AArch64::GPR64RegClassID);
4487
4448
4488
4449
EmergencyStackSlots SpillSlots;
4489
4450
for (MachineBasicBlock &MBB : MF) {
@@ -4493,9 +4454,8 @@ void AArch64FrameLowering::processFunctionBeforeFrameFinalized(
4493
4454
// most two expansion passes, as spilling/filling a predicate in the range
4494
4455
// p0-p7 never requires spilling another predicate.
4495
4456
for (int Pass = 0 ; Pass < 2 ; Pass++) {
4496
- bool HasPPRSpills = expandSMEPPRToZPRSpillPseudos (
4497
- MBB, TRI, ScavengeableRegsBody, ScavengeableRegsFrameSetup,
4498
- SpillSlots);
4457
+ bool HasPPRSpills =
4458
+ expandSMEPPRToZPRSpillPseudos (MBB, TRI, SR, SpillSlots);
4499
4459
assert ((Pass == 0 || !HasPPRSpills) && " Did not expect PPR spills" );
4500
4460
if (!HasPPRSpills)
4501
4461
break ;
0 commit comments