Hello,
On Tue, 15 Aug 2023, connor horman wrote:
> The current specification passes vector types in a manner that indicates
> the whole value is passed in one vector register
> > If the class is SSEUP, it is passed in the next eightbyte of the last
> used vector register.
The psABI actually says this:
If the class is SSEUP, the \eightbyte is passed in the next
available \eightbyte chunk of the last used vector register.
Note the word "available". Without avx (or avx512f for __m512) there's no
next available eightbyte for the higher SSEUP parts, at which point this
wording comes into play:
If there are no registers available for any \eightbyte of an
argument, the whole argument is passed on the stack. If registers have
already been assigned for some \eightbytes of such an argument, the
assignments get reverted.
> * Returning when disabled globally and locally differs: gcc returns in
> memory using rdi. clang returns in two vector (or four for __mm512)
> registers, xmm0 and xmm1 (xmm0 through xmm3 for __m512).
Returning of values is defined in terms of eightbyte classification in the
same way as argument passing. In particular __m256 has four eightbytes of
type SSE and three times SSEUP and the same language for how to assign
SSEUP parts. The section about returning values misses the wording that
when there are no available regs for an eightbyte that it should be
returned via memory, but that seems obvious.
So, the above is simply a clang bug.;
> * When feature is enabled locally only: gcc passes and returns correctly
> according to abi. clang still passes on the stack but returns properly
>
> The Sys-V abi should clarify (at least) one of the following:
> * That code which passes __m256 and __m512 without the required feature
> available explicitly does not conform to the abi, and compilers should warn
> or error when code attempts to do so (gcc does warn here, but clang does
> not),
Actually it does conform to the psABI. But a warning is very sensible as
the ABI changes for passing/returning __m256/512 depending on available
ISA.
> * What the abi of these types are when the features are globally disabled,
> and when they are enabled per-function.
It does say so, see above. Passing and returning in memory.
Ciao,
Michael.