-
Notifications
You must be signed in to change notification settings - Fork 163
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
representation of GNU C fixed-size vectors #390
Comments
Ooops, thanks for dig out this issue which created years ago...I think we should spend some time on standardize that.
Yeah, that's kind of known issue,
Has some off-list discussion with @lhtin, and let me dump some of our discussion here: Short answer in my heart is: yes, we should consider pass fixed-size vector in vector register. However there is really complicate compatibility issue between zvl32b, zvl64b and zvl128b... NOTE: I didn't use zve32* or zve64* here since those zve* could still combine with zvl128b, and issues describe bellow will be gone, so I use zvl32b and zvl64b would be more precise. Let me try describe this by two different options: 1) better compatibility, 2) better performance/usability.
If we consider the compatibility among That's would be bad design because we can expect linux class RISC-V cpu will having But this the way if we don't want to define multiple ABI/calling convention variant for
However this design can't be apply on So...here is a aggressive idea is we could design a calling convention with argument: e.g. And then default How about This design also come with one more advantage is user can pass 256 bit fixed size vector if they want to optimize program. Or last alternative is we don't do anything on the psABI land, just let compiler use their module-internal fastcc. |
I think I agree that this needs to be parameterized and controlled by (ABI perspective) language-specific mechanisms (riscv-c-api-doc perspective) some combination of GNU attributes, explicitly ABI-affecting compiler options, and implementation-dependent fastcc mechanisms. We have three options to choose from (or for the compiler to choose from for fastcc) on a per-function basis:
Functions using option 2 should probably have call-saved registers under the same rules as eventually adopted for vector types. Should the default behavior be 1 or 3? If we treat the behavior of gcc without The attribute name should express the fact that it is specific to fixed-size vectors. I am thinking something like (Besides the ratification of C23, what else needs to happen before we can start talking about Maybe, there is an argument for defining Do you have a sense of the amount of new code being written using fixed-size vectors for RISC-V? If the major use case is legacy code using portable fixed-size vectors or a RISC-V implementation of the SSE / NEON intrinsics, then it would make sense to focus more on fastcc support than defining the attributes. The default / externally visible calling convention needs to be defined in any case. |
This was raised in the context of Rust support for the V extension. The specific concern is in the context of a program compiled without the V extension enabled, but where certain functions are marked If the default calling convention allows passing fixed-length vectors in vector registers, then this really should be a separate This is not a concern for scalable vectors since, unlike fixed-length vectors, no values of this type can be instantiated without the V extension. |
For the base calling convention part: Vector calling convention will be separated PR and create later. |
We have an existing issue (#45) for the alignment, which appears to differ between gcc and clang for size > 16 bytes, but I noticed gcc isn't even compatible with itself (compiler explorer link): for vector size = 2*XLEN, the vector is passed in memory if vectorization is enabled, in integer registers otherwise.
Do we want to pass fixed-size vectors in vector registers if an appropriate vector calling convention is in use? (This would have been a comment on #389 without the above issue.) This would substantially complicate the compatibility story, since the vector calling convention could no longer be treated as a strict superset of the non-vector calling convention, and we may be able to get most of the benefit using module-internal fastcc-type optimizations.
The text was updated successfully, but these errors were encountered: