Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SME] Add __arm_agnostic("sme_za_state") keyword attribute #336

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion main/acle.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ Armv8.4-A [[ARMARMv84]](#ARMARMv84). Support is added for the Dot Product intrin
* Added a requirement for function version declaration in Function Multi Versioning.
* Fixed some rendering issues in the online Markdown documentation and fixed
a misplaced anchor.
* Added [`__arm_agnostic`](#arm_agnostic) keyword attribute

### References

Expand Down Expand Up @@ -826,6 +827,7 @@ predefine the associated macro to a nonzero value.

| **Name** | **Target** | **Predefined macro** |
| ----------------------------------------------------------- | --------------------- | --------------------------------- |
| [`__arm_agnostic`](#arm_agnostic) | function type | `__ARM_FEATURE_SME` |
| [`__arm_locally_streaming`](#arm_locally_streaming) | function declaration | `__ARM_FEATURE_LOCALLY_STREAMING` |
| [`__arm_in`](#ways-of-sharing-state) | function type | Argument-dependent |
| [`__arm_inout`](#ways-of-sharing-state) | function type | Argument-dependent |
Expand Down Expand Up @@ -4836,6 +4838,30 @@ if such a restoration is necessary. For example:
}
```

## `__arm_agnostic`

A function with the `__arm_agnostic` [keyword attribute](#keyword-attributes)
must preserve the architectural state that is specified by its arguments when
such state exists at runtime. The function is otherwise unconcerned with this
state.

The `__arm_agnostic` [keyword attribute](#keyword-attributes) applies to
**function types** and accepts the following arguments:

```"sme_za_state"```

* This attribute affects the ABI of a function, which must implement an
[agnostic-ZA interface](#agnostic-za). It is the compiler's responsibility
to ensure that the function's object code honors the ABI requirements.

* The use of `__arm_agnostic("sme_za_state")` allows writing functions that
are compatible with ZA state without having to share ZA state with the
caller, as required by `__arm_preserves`.

* It is not valid for a function declaration with
`__arm_agnostic("sme_za_state")` to [share](#shares-state) PSTATE.ZA state
with its caller.

## Mapping to the Procedure Call Standard

[[AAPCS64]](#AAPCS64) classifies functions as having one of the following
Expand All @@ -4847,6 +4873,10 @@ interfaces:

* a “shared-ZA” interface

<span id="agnostic-za"></span>

* a "agnostic-ZA" interface

If a C or C++ function F forms part of the object code's ABI, that
object code function has a shared-ZA interface if and only if at least
one of the following is true:
Expand All @@ -4855,7 +4885,17 @@ one of the following is true:

* F shares ZT0 with its caller

All other functions have a private-ZA interface.
All other functions have either a private-ZA or an agnostic-ZA interface.

If F implements an agnostic-ZA interface and PSTATE.ZA is available at runtime,
then a call to F must return with its ZA state unchanged in accordance
to the [[AAPCS64]](#AAPCS64). In practice this means that calls to F don't have
to emit code to set up a lazy-save for ZA or to preserve other state like ZT0
when such state is live at the call site.

The implementation of F must not make any assumptions on the availability of
PSTATE.ZA or any architectural state associated with it.


## Function definitions

Expand Down