https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114416

--- Comment #10 from Jakub Kulik <jakub.kulik at oracle dot com> ---
Sorry for longer response.

I asked internally again and was told by a colleague who was in the room when
the spec was created, that: "the intent was (and is) that the individual
elements/atoms/fundamental types that make up a small structure, no matter how
those elements/atoms/fundamental types are aggregated within the structure, are
passed in registers appropriate for the fundamental type in question. (That is,
pointers and integral types are passed in the %o registers, and floating point
types are passed in the floating-point registers.) So a structure that contains
an array of two floats is treated the same as a structure that contains two
floats."

That said, he agreed that the spec could perhaps be better written. He also
added:

Page 3P-11 says this, under "Function Argument Passing":

"It is convenient to describe parameter linkage in terms of an array.
Conceptually, parameters are assigned into an array of extended words,
left-to-right, with an occasional “hole” to satisfy alignment restrictions.
Typically, most parameter values will be “promoted” from their memory locations
into registers, and most calls are expected to execute this way with less
overhead."

There is then a diagram that shows the correspondence between parameter
registers and the parameter array.

On page 3P-12, under "Structure and Union arguments", it says this:

"Structure or union types up to eight bytes in size are assigned to one
parameter array word, and align to eight-byte boundaries.

"Structure or union types larger than eight bytes, and up to sixteen bytes in
size are assigned to two consecutive parameter array words, and align according
to the alignment requirements of the structure or at least to an eight-byte
boundary."

So perhaps instead of saying "The individual fields of a structure ... are
subject to promotion into registers based on their type using the same rules as
apply to scalar values" the spec should have said "The individual parameter
array words assigned to a structure ... are subject to promotion into registers
based on their type using the same rules as apply to scalar values."

Reply via email to