From ba68f64e255f270f42b453654814243c40534af7 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 31 Jan 2024 16:02:20 +0000 Subject: [PATCH] Respond to review feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add __arm_preserves_za to the changelog entry. - Fix the names of the __ARM_STATE macros (pointed out by Sander privately). - Add an example that involves saving and restoring ZT0. - Remove “as described below”. --- main/acle.md | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/main/acle.md b/main/acle.md index 46783550..54c05358 100644 --- a/main/acle.md +++ b/main/acle.md @@ -4633,10 +4633,10 @@ this way. The strings are listed in the table below. -| **String** | **State** | **State macro** | **Feature macro** | -| ---------- | ------------------ | ------------------ | -------------------- | -| `"za"` | SME's ZA storage | `__ARM_STATE_SME` | `__ARM_FEATURE_SME` | -| `"zt0"` | SME2's ZT0 | `__ARM_STATE_SME2` | `__ARM_FEATURE_SME2` | +| **String** | **State** | **State macro** | **Feature macro** | +| ---------- | ------------------ | ----------------- | -------------------- | +| `"za"` | SME's ZA storage | `__ARM_STATE_ZA` | `__ARM_FEATURE_SME` | +| `"zt0"` | SME2's ZT0 | `__ARM_STATE_ZT0` | `__ARM_FEATURE_SME2` | For each string, there are two associated macros: @@ -4649,7 +4649,7 @@ For each string, there are two associated macros: A compiler that predefines the feature macro must also predefine the state macro. -For example, `__ARM_STATE_SME` allows declarations of functions that share ZA. +For example, `__ARM_STATE_ZA` allows declarations of functions that share ZA. `__ARM_FEATURE_SME` allows function definitions to use ZA internally. The strings are case-sensitive. For example, `"za"` cannot be written `"ZA"`. @@ -4861,7 +4861,7 @@ state](#uses-state) S, the two possibilities are: If an asm takes this option for state that is controlled by PSTATE.ZA, the asm itself is responsible for handling the [[AAPCS64]](#AAPCS64) - lazy save scheme, as described below. + lazy save scheme. [[AAPCS64]](#AAPCS64) defines three possible states for ZA: “off”, “dormant” or “active”. These states describe the values @@ -4979,6 +4979,27 @@ internally. The comments describe when ZA should be saved and restored: } ``` +ZT0 cannot be lazily saved, so if ZT0 is live before a call to a +function that does not share ZT0, the compiler must save and restore +ZT0 around the call. For example: + +``` c + void setup_zt0() __arm_out("zt0"); + void use_zt0() __arm_in("zt0"); + void f_private(); + + __arm_new("zt0") void test() { + f_private(); // ZT0 is not live, no save necessary + + setup_zt0(); // ZT0 is live after this call + f_private(); // The compiler should save and restore ZT0 + // around the call ("caller-save") + use_zt0(); // ZT0 is no longer live after this call + + f_private(); // ZT0 is not live, no save necessary + } +``` + # System register access ## Special register intrinsics