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

Conversation

sdesmalen-arm
Copy link
Contributor

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)

  • If an issue reporting the bug exists, I have mentioned it in the
    PR (do not bother creating the issue if all you want to do is
    fixing the bug yourself).
  • I have added/updated the SPDX-FileCopyrightText lines on top
    of 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 use
    commas to separate gaps, as in 2018-2020, 2022).
  • I have updated the Copyright section of the sources of the
    specification 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.
  • I have run the CI scripts (if applicable, as they might be
    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.
  • I have added an item that describes the changes I have
    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.
  • When modifying content and/or its rendering, I have checked the
    correctness of the result in the PDF output (please refer to the
    instructions on how to build the PDFs
    locally
    ).
  • The variable draftversion is set to true in the YAML header
    of the sources of the specifications I have modified.
  • Please DO NOT add my GitHub profile to the list of contributors
    in the README page of the project.

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.
@sdesmalen-arm
Copy link
Contributor Author

@rsandifo-arm

Copy link
Contributor

@rsandifo-arm rsandifo-arm left a 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` |
Copy link
Contributor

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")`
Copy link
Contributor

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
Copy link
Contributor

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.

sdesmalen-arm added a commit to sdesmalen-arm/llvm-project that referenced this pull request Sep 9, 2024
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
sdesmalen-arm added a commit to sdesmalen-arm/llvm-project that referenced this pull request Sep 9, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants