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

Include SME attributes in the name mangling of types #358

Merged

Conversation

kmclaughlin-arm
Copy link
Contributor

This change extends the name mangling of types to include the SME streaming
and ZA interface. This will avoid naming conflicts which can currently arise such
as in the following example:

  void foo(void (*f)()) { f(); }
  void foo(void (*f)() __arm_streaming) { f(); }

Without this change, both functions 'foo' above will mangle to the same
name, despite the function pointers being different.


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.

@kmclaughlin-arm
Copy link
Contributor Author

main/acle.md Outdated
with the arguments:

``` c
__SME_ATTRS<normal_function_type, streaming_mode, za_state, zt0_state>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is modelling za_state and zt0_state with separate template arguments going to work if future architecture revisions might add new SME state? Say, for example, some new state Znew would be added then I'd expect functions that don't know about Znew to be mangled as if the template argument did not exist, but when it does know about Znew for it to get mangled with an extra 0 argument. This name would then not be compatible.

Should we instead define this with a single uint64_t bitmask where we define the upper bits as leading zeroes to mean "unknown state" or "no state"? At least that ensures that the name mangling doesn't change depending on what version of the ACLE is implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would not have worked for any new attributes which could be introduced in future. As suggested I have changed the template to use a single integer to represent all of the possible SME states, leaving the upper bits reserved for future state.

main/acle.md Outdated
Comment on lines 10124 to 10134
| 0 | 0x001 | Streaming Mode |
| 1 | 0x002 | Streaming-Compatible |
| 2 | 0x004 | ZA-In |
| 3 | 0x008 | ZA-InOut |
| 4 | 0x010 | ZA-Out |
| 5 | 0x020 | ZA-Preserved |
| 6 | 0x040 | ZT0-In |
| 7 | 0x080 | ZT0-Out |
| 8 | 0x100 | ZT0-InOut |
| 9 | 0x200 | ZT0-Preserved |
| 10 | 0x400 | ZA State Agnostic |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use the ACLE names of the properties, also moved __arm_agnostic to bit 2.

Suggested change
| 0 | 0x001 | Streaming Mode |
| 1 | 0x002 | Streaming-Compatible |
| 2 | 0x004 | ZA-In |
| 3 | 0x008 | ZA-InOut |
| 4 | 0x010 | ZA-Out |
| 5 | 0x020 | ZA-Preserved |
| 6 | 0x040 | ZT0-In |
| 7 | 0x080 | ZT0-Out |
| 8 | 0x100 | ZT0-InOut |
| 9 | 0x200 | ZT0-Preserved |
| 10 | 0x400 | ZA State Agnostic |
| 0 | 0x001 | __arm_streaming |
| 1 | 0x002 | __arm_streaming_compatible |
| 2 | 0x004 | __arm_agnostic("sme_za_state") |
| 3 | 0x008 | __arm_in("za") |
| 4 | 0x010 | __arm_inout("za") |
| 5 | 0x020 | __arm_out("za") |
| 6 | 0x040 | __arm_preserved("za") |
| 7 | 0x080 | __arm_in("zt0") |
| 8 | 0x100 | __arm_out("zt0") |
| 9 | 0x200 | __arm_inout("zt0") |
| 10 | 0x400 | __arm_preserved("zt0") |

We could save some bits by encoding 'none, in, out, inout, preserved' using 3 bits, rather than 4.

main/acle.md Outdated
SME attributes are mangled in the same way as a template:

``` c
template<typename, unsigned> __SME_ATTRS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template<typename, unsigned> __SME_ATTRS;
template<typename, uint64_t> __SME_ATTRS;

main/acle.md Outdated

* normal_function_type is the function type without any SME attributes.

* sme_state is an unsigned 64-bit integer representing the streaming mode, ZA state and ZT0 state of the function.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* sme_state is an unsigned 64-bit integer representing the streaming mode, ZA state and ZT0 state of the function.
* sme_state is an unsigned 64-bit integer representing the streaming and ZA properties of the function's interface.

main/acle.md Outdated
| 9 | 0x200 | ZT0-Preserved |
| 10 | 0x400 | ZA State Agnostic |

The upper bits 11-63 are defined as leading zeroes, reserved for representing any future interface types.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The upper bits 11-63 are defined as leading zeroes, reserved for representing any future interface types.
Bits 11-63 are defined to be zero by this revision of the ACLE and are reserved for future type attributes.

main/acle.md Outdated
| 7 | 0x080 | __arm_out("zt0") |
| 8 | 0x100 | __arm_preserved("zt0") |

Bits 9-63 are defined to be zero by this revision of the ACLE and are reserved for future type attributes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not what I actually meant with encoding with 3 bits. I meant:

 0 = no state
 1 = __arm_in
 2 = __arm_out
 3 = __arm_inout
 4 = __arm_preserves

which is 5 values, and so can be encoded with 3 bits, rather than 4.

Because __arm_inout, __arm_in and __arm_out for the same state are all mutually exclusive, I think we should encode these separately.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ironically the actual encoding is the same, but I prefer the way this is phrased :)

main/acle.md Outdated
| 2 | 0x004 | __arm_agnostic("sme_za_state") |
| 3 | 0x008 | __arm_in("za") |
| 4 | 0x010 | __arm_out("za") |
| 5 | 0x020 | __arm_preserved("za") |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I misspelled this one, it's __arm_preserves (not __arm_preserved)

Copy link
Contributor

@sdesmalen-arm sdesmalen-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nit addressed. Please wait for @rsandifo-arm to confirm as well.

main/acle.md Outdated
| 7 | 0x080 | __arm_out("zt0") |
| 8 | 0x100 | __arm_preserved("zt0") |

Bits 9-63 are defined to be zero by this revision of the ACLE and are reserved for future type attributes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ironically the actual encoding is the same, but I prefer the way this is phrased :)

main/acle.md Outdated

* normal_function_type is the function type without any SME attributes.

* sme_state is an unsigned 64-bit integer representing the streaming and ZA properties of the function's interface.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: do we need to maintain 80char line-wrapping in this file?

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.

LGTM as well.

This change extends the name mangling of types to include the SME streaming
and ZA interface. This will avoid naming conflicts which can currently
arise such as in the following example:

  void foo(void (*f)()) { f(); }
  void foo(void (*f)() __arm_streaming) { f(); }

Without this change, both functions 'foo' above will mangle to the same
name, despite the function pointers being different.
…ll attributes.

- Include __arm_agnostic("sme_za_state") in the bitmask
- Removed bits for ZA/ZT0 'inout', as this can be represented by
  setting both 'in' and 'out'.
- Added default ZA & ZT0 states to the sme_state table.
@kmclaughlin-arm kmclaughlin-arm merged commit f6190ce into ARM-software:main Nov 26, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants