================
@@ -825,32 +823,49 @@ void MachineSMEABI::emitAllocateLazySaveBuffer(
}
}
-void MachineSMEABI::emitNewZAPrologue(MachineBasicBlock &MBB,
- MachineBasicBlock::iterator MBBI) {
+static constexpr unsigned ZERO_ALL_ZA_MASK = 0b11111111;
+
+void MachineSMEABI::emitSMEPrologue(MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator MBBI) {
auto *TLI = Subtarget->getTargetLowering();
DebugLoc DL = getDebugLoc(MBB, MBBI);
- // Get current TPIDR2_EL0.
- Register TPIDR2EL0 = MRI->createVirtualRegister(&AArch64::GPR64RegClass);
- BuildMI(MBB, MBBI, DL, TII->get(AArch64::MRS))
- .addReg(TPIDR2EL0, RegState::Define)
- .addImm(AArch64SysReg::TPIDR2_EL0);
- // If TPIDR2_EL0 is non-zero, commit the lazy save.
- // NOTE: Functions that only use ZT0 don't need to zero ZA.
- bool ZeroZA = AFI->getSMEFnAttrs().hasZAState();
- auto CommitZASave =
- BuildMI(MBB, MBBI, DL, TII->get(AArch64::CommitZASavePseudo))
- .addReg(TPIDR2EL0)
- .addImm(ZeroZA ? 1 : 0)
- .addImm(/*ZeroZT0=*/false)
- .addExternalSymbol(TLI->getLibcallName(RTLIB::SMEABI_TPIDR2_SAVE))
- .addRegMask(TRI->SMEABISupportRoutinesCallPreservedMaskFromX0());
- if (ZeroZA)
- CommitZASave.addDef(AArch64::ZAB0, RegState::ImplicitDefine);
- // Enable ZA (as ZA could have previously been in the OFF state).
- BuildMI(MBB, MBBI, DL, TII->get(AArch64::MSRpstatesvcrImm1))
- .addImm(AArch64SVCR::SVCRZA)
- .addImm(1);
+ bool ZeroZA = AFI->getSMEFnAttrs().isNewZA();
+ bool ZeroZT0 = AFI->getSMEFnAttrs().isNewZT0();
+ if (AFI->getSMEFnAttrs().hasPrivateZAInterface()) {
+ // Get current TPIDR2_EL0.
+ Register TPIDR2EL0 = MRI->createVirtualRegister(&AArch64::GPR64RegClass);
+ BuildMI(MBB, MBBI, DL, TII->get(AArch64::MRS))
+ .addReg(TPIDR2EL0, RegState::Define)
+ .addImm(AArch64SysReg::TPIDR2_EL0);
+ // If TPIDR2_EL0 is non-zero, commit the lazy save.
+ // NOTE: Functions that only use ZT0 don't need to zero ZA.
+ auto CommitZASave =
+ BuildMI(MBB, MBBI, DL, TII->get(AArch64::CommitZASavePseudo))
+ .addReg(TPIDR2EL0)
+ .addImm(ZeroZA)
+ .addImm(ZeroZT0)
+ .addExternalSymbol(TLI->getLibcallName(RTLIB::SMEABI_TPIDR2_SAVE))
+ .addRegMask(TRI->SMEABISupportRoutinesCallPreservedMaskFromX0());
+ if (ZeroZA)
+ CommitZASave.addDef(AArch64::ZAB0, RegState::ImplicitDefine);
+ if (ZeroZT0)
+ CommitZASave.addDef(AArch64::ZT0, RegState::ImplicitDefine);
+ // Enable ZA (as ZA could have previously been in the OFF state).
+ BuildMI(MBB, MBBI, DL, TII->get(AArch64::MSRpstatesvcrImm1))
+ .addImm(AArch64SVCR::SVCRZA)
+ .addImm(1);
+ } else if (AFI->getSMEFnAttrs().hasSharedZAInterface()) {
+ if (ZeroZA) {
+ BuildMI(MBB, MBBI, DL, TII->get(AArch64::ZERO_M))
+ .addImm(ZERO_ALL_ZA_MASK)
+ .addDef(AArch64::ZAB0, RegState::ImplicitDefine);
+ }
+ if (ZeroZT0) {
+ DebugLoc DL = getDebugLoc(MBB, MBBI);
----------------
sdesmalen-arm wrote:
Why does this use a different `DebugLoc DL` ?
https://github.com/llvm/llvm-project/pull/166361
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits