-
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
Include SME attributes in the name mangling of types #358
Include SME attributes in the name mangling of types #358
Conversation
main/acle.md
Outdated
with the arguments: | ||
|
||
``` c | ||
__SME_ATTRS<normal_function_type, streaming_mode, za_state, zt0_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.
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.
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.
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
| 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 | |
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: use the ACLE names of the properties, also moved __arm_agnostic to bit 2.
| 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; |
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.
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. |
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.
* 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. |
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 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. |
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.
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.
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.
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") | |
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.
Sorry I misspelled this one, it's __arm_preserves
(not __arm_preserved
)
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 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. |
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.
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. |
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: do we need to maintain 80char line-wrapping in this file?
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 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.
a2d1e06
to
8c888a3
Compare
…ion types (#114209) Similar to arm_sve_vector_bits, the mangling of function types is implemented as a pseudo template if there are any SME attributes present, i.e. `__SME_ATTRS<normal_function_type, sme_state>` For example, the following function: `void f(svint8_t (*fn)() __arm_streaming) { fn(); }` would be mangled as: `_Z1fP11__SME_ATTRSIFu10__SVInt8_tELj1EE` See ARM-software/acle#358
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:
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)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.