[compiler-rt] [Compiler-rt] Add AArch64 routines for __arm_agnostic("sme_za_state") (PR #120059)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 04:15:24 PST 2024


================
@@ -204,6 +206,161 @@ DEFINE_COMPILERRT_FUNCTION(__arm_get_current_vg)
   ret
 END_COMPILERRT_FUNCTION(__arm_get_current_vg)
 
+DEFINE_COMPILERRT_FUNCTION(__arm_sme_state_size)
+  .variant_pcs __arm_sme_state_size
+  BTI_C
+
+  // Test if SME is available and PSTATE = 1.
+  adrp    x16, CPU_FEATS_SYMBOL
+  ldr     x16, [x16, CPU_FEATS_SYMBOL_OFFSET]
+  tbz     x16, #FEAT_SME_BIT, 0f
+  mrs     x16, SVCR
+  tbz     x16, #1, 0f
----------------
sdesmalen-arm wrote:

>From the specification:
> If the ZA state is active, X0 contains the total size required to save and restore all SME state enabled by PSTATE.ZA.

So yes, there's no need to allocate more size than necessary. Good catch!

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


More information about the llvm-commits mailing list