-
Notifications
You must be signed in to change notification settings - Fork 60
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
[SME] Add __arm_agnostic("sme_za_state") keyword attribute #336
Conversation
The __arm_agnostic keyword attribute enables the user to specify that a function is agnostic to a specified piece of architectural state. That means that the function must preserve this state when it exists, or otherwise ignores its contents. The reason for not naming this something like '__arm_za_compatible' was so that we might want use the attribute keyword for other architectural state in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch should also update the “Inline assembly” section, since ZA can now be “on” on entry to an inline asm in cases that the current text doesn't cover.
main/acle.md
Outdated
@@ -832,6 +833,7 @@ predefine the associated macro to a nonzero value. | |||
| [`__arm_new`](#arm_new) | function declaration | Argument-dependent | | |||
| [`__arm_out`](#ways-of-sharing-state) | function type | Argument-dependent | | |||
| [`__arm_preserves`](#ways-of-sharing-state) | function type | Argument-dependent | | |||
| [`__arm_agnostic`](#arm_agnostic) | function type | `__ARM_FEATURE_SME` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: would be good to keep the entries sorted by name.
main/acle.md
Outdated
function has a “ZA-compatible interface”; see [[AAPCS64]](#AAPCS64) | ||
for more details. | ||
|
||
* It is not valid for a function declaration with `__arm_agnostic("sme_za_state")` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__arm_new
is only meaningful for definitions, not declarations. I'm not sure it should be a semantic requirement, since:
__arm_new("za") void foo(void) …stuff… {
…
}
isn't semantically different from:
__arm_new("za") void foo1(void) {
…
}
void foo(void) …stuff… {
foo1();
}
(It's reasonable for an implementation to say that it doesn't support __arm_new
for now though. This would be the equivalent of a GCC “sorry” diagnostic, but it'd be an implementation choice rather than something that the ACLE should document.)
I think we can then say:
It is not valid … to [share](#shares-state) PSTATE.ZA state with its caller.
main/acle.md
Outdated
|
||
```"sme_za_state"``` | ||
|
||
* If the function is defined and PSTATE.ZA is available, the definition must |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the AAPCS64 patch (rightly) creates a three-way choice between private, shared & agnostic, we should update the description under “Mapping to the Procedure Call Standard” section. I think the text here should then say something like:
This attribute affects the ABI of object code functions, as described under … It is the compiler's responsibility to ensure that such object code functions honor the ABI requirements.
and then delete the following two bullet points. AFAICT, the attribute has no effect on the behaviour of the abstract machine outside of inline asms.
This implements the lowering of calls from agnostic-ZA functions to non-agnostic-ZA functions, using the ABI routines `__arm_sme_state_size`, `__arm_sme_save` and `__arm_sme_restore`. This implements the proposal described in the following PRs: * ARM-software/acle#336 * ARM-software/abi-aa#264
This adds support for parsing the attribute and codegen to map it to "aarch64_za_state_agnostic" LLVM IR attribute. This is proposed in the following PR: ARM-software/acle#336
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous comment about updating the inline asm documentation still stands.
#264) This PR adds a new "agnostic-ZA" interface which is intended to be called from any subroutine without requiring a change to PSTATE.ZA. This PR also adds new SME ABI routines to save/restore state enabled by PSTATE.ZA. The corresponding ACLE PR can be found [here](ARM-software/acle#336).
Thanks, I missed that comment previously. I've now added a comment that I believe is sufficient to cover the agnostic-ZA case, but let me know if there's still anything missing! |
main/acle.md
Outdated
|
||
All other functions have a private-ZA interface. | ||
|
||
If F implements an agnostic-ZA interface and ZA is active, then a call to F must |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think we should drop these two paragraphs. IMO the purpose of this section is to describe how ACLE features map to the ABI, and it's the ABI's job to describe the actual binary interface.
I was hoping the new “The use of this attribute does not imply that SME is available.” statement would replace the second paragraph, since IMO it's more precise. E.g. it's valid to do:
void f() __arm_agnostic("sme_state") __arm_streaming {}
and in that case, the implementation can assume that PSTATE.ZA is available.
In other words, the point is that __arm_agnostic
does not by itself guarantee that SME is available, but the compiler might still know that SME is available from other sources, e.g. from +sme
or from other attributes. __arm_agnostic
doesn't override information from other sources.
main/acle.md
Outdated
@@ -4942,6 +4987,8 @@ following is true: | |||
|
|||
* F [uses](#uses-state) `"zt0"` | |||
|
|||
* F implements an [agnostic ZA](#agnostic-za) interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but this should be reflected in the table at the end of the section as well.
I think we also need to decide what to do about:
* S is not an input to the asm and S is not an output from the asm.
However, the contents of S after executing the asm's instructions might
be different from the contents of S before executing the instructions.
This is indicated by adding S's string to the asm's clobber list.
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.
The current rule implicity assumes that ZA can only be dormant or off. If ZA is active, then is the asm required to preserve ZA despite the clobber? Does the compiler do this? (In which case, does it also handle the lazy-save scheme, meaning that the asm doesn't need to?) Or is this option not valid in agnostic-ZA functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking on this was that for __arm_agnostic("sme_za_state")
functions, if the asm clobbers any of the state enabled by PSTATE.ZA, the user is responsible for letting the function preserve this state using the provided routines such that on return from the function the ABI is honoured.
This implements the lowering of calls from agnostic-ZA functions to non-agnostic-ZA functions, using the ABI routines `__arm_sme_state_size`, `__arm_sme_save` and `__arm_sme_restore`. This implements the proposal described in the following PRs: * ARM-software/acle#336 * ARM-software/abi-aa#264
This implements the lowering of calls from agnostic-ZA functions to non-agnostic-ZA functions, using the ABI routines `__arm_sme_state_size`, `__arm_sme_save` and `__arm_sme_restore`. This implements the proposal described in the following PRs: * ARM-software/acle#336 * ARM-software/abi-aa#264
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This implements the lowering of calls from agnostic-ZA functions to non-agnostic-ZA functions, using the ABI routines `__arm_sme_state_size`, `__arm_sme_save` and `__arm_sme_restore`. This implements the proposal described in the following PRs: * ARM-software/acle#336 * ARM-software/abi-aa#264
This implements the lowering of calls from agnostic-ZA functions to non-agnostic-ZA functions, using the ABI routines `__arm_sme_state_size`, `__arm_sme_save` and `__arm_sme_restore`. This implements the proposal described in the following PRs: * ARM-software/acle#336 * ARM-software/abi-aa#264
The
__arm_agnostic
keyword attribute enables the user to specify that a function is agnostic to a specified piece of architectural state. That means that the function must preserve this state when it exists, or otherwise ignores its contents.The reason for not naming this something like
__arm_za_compatible
was so that we might want use the attribute keyword for other architectural state in the future.name: Pull request
about: Technical issues, document format problems, bugs in scripts or feature proposal.
Thank you for submitting a pull request!
If this PR is about a bugfix:
Please use the bugfix label and make sure to go through the checklist below.
If this PR is about a proposal:
We are looking forward to evaluate your proposal, and if possible to
make it part of the Arm C Language Extension (ACLE) specifications.
We would like to encourage you reading through the contribution
guidelines, in particular the section on submitting
a proposal.
Please use the proposal label.
As for any pull request, please make sure to go through the below
checklist.
Checklist: (mark with
X
those which apply)PR (do not bother creating the issue if all you want to do is
fixing the bug yourself).
SPDX-FileCopyrightText
lines on topof any file I have edited. Format is
SPDX-FileCopyrightText: Copyright {year} {entity or name} <{contact informations}>
(Please update existing copyright lines if applicable. You can
specify year ranges with hyphen , as in
2017-2019
, and usecommas to separate gaps, as in
2018-2020, 2022
).Copyright
section of the sources of thespecification I have edited (this will show up in the text
rendered in the PDF and other output format supported). The
format is the same described in the previous item.
tricky to set up on non-*nix machines). The sequence can be
found in the contribution
guidelines. Don't
worry if you cannot run these scripts on your machine, your
patch will be automatically checked in the Actions of the pull
request.
introduced in this PR in the section Changes for next
release of the section Change Control/Document history
of the document. Create Changes for next release if it does
not exist. Notice that changes that are not modifying the
content and rendering of the specifications (both HTML and PDF)
do not need to be listed.
correctness of the result in the PDF output (please refer to the
instructions on how to build the PDFs
locally).
draftversion
is set totrue
in the YAML headerof the sources of the specifications I have modified.
in the README page of the project.