[llvm] [AArch64][SME2] Extend SMEABIPass to handle functions with new ZT0 state (PR #78848)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 22 01:47:44 PST 2024


================
@@ -76,56 +77,79 @@ void emitTPIDR2Save(Module *M, IRBuilder<> &Builder) {
                      Builder.getInt64(0));
 }
 
-/// This function generates code to commit a lazy save at the beginning of a
-/// function marked with `aarch64_pstate_za_new`. If the value read from
-/// TPIDR2_EL0 is not null on entry to the function then the lazy-saving scheme
-/// is active and we should call __arm_tpidr2_save to commit the lazy save.
-/// Additionally, PSTATE.ZA should be enabled at the beginning of the function
-/// and disabled before returning.
-bool SMEABI::updateNewZAFunctions(Module *M, Function *F,
-                                  IRBuilder<> &Builder) {
+/// This function generates code at the beginning and end of a function marked
+/// with either `aarch64_pstate_za_new` or `arm_new_zt0`.
+/// At the beginning of the function, the following code is generated:
+///  - Commit lazy-save if active   [Private-ZA Interface]
----------------
sdesmalen-arm wrote:

Can you add some rationale why we need to do this for ZT0-new functions?

My understanding of the rationale for a function with only `__arm_new("zt0")` is as follows;
* PSTATE.ZA may be 1 on entry to the function, which would indicate the lazy-save mechanism is active.
* ZA is untouched by this function, so there is no _need_ to commit the lazy-save here.
* However, when this function calls other functions that don't share ZT0, it would always require a conditional `smstop za` before the call to honour the ABI (either no lazy-save is active and PSTATE must be 0, or the lazy-save is active and PSTATE is 1)
* It is therefore easier to just commit the lazy-save at the start of the function once.

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


More information about the llvm-commits mailing list