ARM-software / abi-aa

Application Binary Interface for the Arm® Architecture
Other
938 stars 188 forks source link

[AAPCS64] Clarify B.5 and B.6 #262

Open rongcuid opened 4 months ago

rongcuid commented 4 months ago

I would like some clarification of the rules B.5 and B.6 in AAPCS64.

Stage B is defined such that "for each argument in the list the first matching rule from the following list is applied. If no rule matches the argument is used unmodified". However, we see the rules:

Does B.5 already cover all composite types, making B.6's composite type rules redundant? Or are the rules meant to fall through in this case?

smithp35 commented 4 months ago

Thank you for pointing that out. We will need to think carefully about how to update the document. The Rule B.6 was added after B.5 specifically to deal with over or under aligned types, this does seem to clash with B.5 as worded today.

The intention behind the rules is:

It is not clear to me that B.5 has much, if any effect given that C.14 "The NSAA is rounded up to the larger of 8 or the Natural Alignment of the argument’s type." so even if a composite type had a size that was not a multiple of 8, then C.14 would ensure that the next parameter passed on the stack was at least 8-byte aligned.

Hope this helps.

The majority of overaligned types are caught by rule B.4 "If the argument type is a Composite Type that is larger than 16 bytes, then the argument is copied to memory allocated by the caller and the argument is replaced by a pointer to the copy." as the size of an aggregate is a multiple of the alignment.