[llvm] [LLVM][AArch64]Use load/store with consecutive registers in SME2 or S… (PR #77665)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Wed May 1 03:00:46 PDT 2024


================
@@ -3287,8 +3351,39 @@ void AArch64FrameLowering::determineCalleeSaves(MachineFunction &MF,
           !RegInfo->isReservedReg(MF, PairedReg))
         ExtraCSSpill = PairedReg;
     }
+
+    // Save PReg in FunctionInfo to build PTRUE instruction later. The PTRUE is
+    // being used in the function to save and restore the pair of ZReg
+    AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>();
+    if (Subtarget.hasSVE2p1() || Subtarget.hasSME2()) {
+      if (AArch64::PPRRegClass.contains(Reg) &&
+          (Reg >= AArch64::P8 && Reg <= AArch64::P15) && SavedRegs.test(Reg) &&
+          AFI->getPredicateRegForFillSpill() == 0)
+        AFI->setPredicateRegForFillSpill((Reg - AArch64::P0) + AArch64::PN0);
+
+      // Check if there is a pair of ZRegs, so it can select P8 to create PTRUE,
+      // in case there is no PRege being saved(above)
+      HasPairZReg =
+          HasPairZReg || (AArch64::ZPRRegClass.contains(Reg, CSRegs[i ^ 1]) &&
+                          SavedRegs.test(CSRegs[i ^ 1]));
+    }
   }
 
+  // Make sure there is a PReg saved to be used in save and restore when there
+  // is ZReg pair.
+  if ((Subtarget.hasSVE2p1() || Subtarget.hasSME2()) &&
+      (MF.getFunction().getCallingConv() ==
+           CallingConv::AArch64_SVE_VectorCall ||
+       MF.getFunction().getCallingConv() ==
+           CallingConv::AArch64_SME_ABI_Support_Routines_PreserveMost_From_X0 ||
+       MF.getFunction().getCallingConv() ==
+           CallingConv::AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2))
----------------
sdesmalen-arm wrote:

It's fine to ignore these two calling conventions, because they're not exposed to the front-end for anyone to use. i.e. it won't be possible to write an function that uses this calling convention in any other way than using asm. They were added from the caller's perspective so that we don't spill/fill registers around the SME ABI routine call-sites.

https://github.com/llvm/llvm-project/pull/77665


More information about the llvm-commits mailing list