-
Notifications
You must be signed in to change notification settings - Fork 193
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
[aapcs64] Unclear callee/caller wording in aapcs64.rst #266
Comments
.NET issue that describes SVE support: dotnet/runtime#93095 |
I agree that the sentence can be clarified. Assuming the confusion hasn't been resolved already, there's a couple of other parts that may help parsing the text:
https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#3scope
Combining this with the original text, the |
Thanks! That was the conclusion we came to after reading around the issue elsewhere. But it would be nice for it to be clearer. |
At least one community got confused as to whether it refered to the callee or the caller. Use subroutine instead of it to make it clear that we are referring to the same subroutine that takes z and p registers as arguments. Fixes ARM-software#266
#267 to update wording. |
Just to be clear, here is my understanding. @rsandifo-arm @smithp35 - please correct if I missed anything. Terminology
A()
{
prolog:
save callee-save registers
...
...
save caller-save registers
B();
restore caller-save registers
...
...
epilog:
restore callee-save registers
}
Float/Scalable registers
1 : This is same specification we have for NEON and only applicable when registers are in use or live Predicate registers
|
I'm going to use the official terminology of Just to be sure, apologies if this was already clear, This is my reading of the document. I'm not a SVE expert like @rsandifo-arm so if I've got this wrong please go with his answer/correction rather than mine. I'm more of a linker than a compiler person. I found it easier to describe when not considering the different call scenarios as there is only a caller and a callee and the responsibilities of the caller don't change if the callee is
(*) z16-z23 are extensions of v16-v23 so these are both callee and caller saved.
I do hope I've got this right, if I haven't and it isn't a silly mistake then we may need more clarifications. |
That's how I wanted it to be, but I wanted to be explicit about the situation. For e.g. in your table, for "regular" function type, under "caller-save", the way I interpret is if a "regular" function is a caller, what registers it need to save/restore across a function call. But that depends on what type of function it is calling. If it is a "regular" function, it needs to save/restore Also, for "regular" function type, if it is calling "regular" function, then it should save/restore entire Note: When I say caller should preserve across function call, I mean only the registers that are live across the call. So, in my table, out of the registers mentioned in "callee-trash" column, only the registers that are live across the call will be preserved by the caller.
I feel the same :) |
Regardless of if we get this or not, I think the document needs a clear way of stating these requirements, something equivalent of how we are having this information in the table. Lot of time is being spent by multiple people in trying to interpret couple of lines of the document. |
OK I see where you are coming from. The safest assumption is that what is not callee-saved by the callee must be caller-saved. That would indeed imply that I'll reopen this as I think more work is needed here. |
Functions without SVE types in the signature don't have to save any SVE state. If they had to, then existing function would not be legal anymore. The only things function without SVE types in the signature must worry about are:
|
There is a lot of nuance here and it is easy for developers to miss considerations. A A Thus, if conventions However, if conventions The simplest example of this is that for a What this means is that for For However, for It gets very interesting for |
Thanks for the additional points. This has somewhat spiralled from the meaning of |
I have updated #266 (comment) to use the terminology of "caller-save" instead of "callee-trash". |
Looking at the table that you have updated I think it is best not to try and enumerate the caller-save registers and caller-save registers in the same table. The callee-save registers are a requirement for a function to preserve the values of registers across the call, so that the values of these registers on entry to the function are the same as the values on return. This requirement is invariant of the caller, or whether there are any calls at all. This looks right in your table. The set of caller-save registers are determined per call (a function could call both regular and sve functions). They are the registers that are not guaranteed to be preserved by the function being called (registers not in the callee-saves of the function being called).
I've got more registers that need to be saved when calling regular functions than your table entries for caller-save. Hope I haven't made any mistakes, I'm hoping that we can find the right wording to improve the AAPCS over the next few weeks. |
I assume that includes |
I've edited my * comment to "In practice this means all SVE state including predicate registers". Hopefully that should cover it. |
Yes, I realized it and have updated #266 (comment) accordingly. |
In aapcs64.rst
In both cases in
it must ensure that
it is not clear whetherit
refers to the caller or the callee.Eg: if
it
is the callee then the wording should bethe subroutine must ensure that
.This wording caused issues when designing SVE support for .NET.
The text was updated successfully, but these errors were encountered: