riscv-non-isa / riscv-elf-psabi-doc

A RISC-V ELF psABI Document
https://jira.riscv.org/browse/RVG-4
Creative Commons Attribution 4.0 International
691 stars 163 forks source link

Specify the Calling Convention for Fixed-Length Vectors #416

Closed kito-cheng closed 8 months ago

kito-cheng commented 9 months ago

Previously, there was no mention of fixed-length vectors in the psABI, however fortunately, GCC and Clang are implemented same ABI rule for fixed-length vectors, so this PR is document the de factor behavior for that.

kito-cheng commented 9 months ago

cc. @palmer-dabbelt @JeffreyALaw @preames @topperc @rofirrim @lhtin

lhtin commented 9 months ago
  • Fixed-length vector are treat as aggregates.

This proposal is great and avoids complicating the passing of fixed-length vectors. But the problem is that it doesn't take advantage of vector registers. Are there any more details about this issue?

GCC and Clang are implemented same ABI rule for fixed-length vectors

Also I tried, GCC currently passes through reference even if the vector size is less than 2*XLEN, which is not according to this proposal. Here is the example: https://godbolt.org/z/3ooovcz7c

kito-cheng commented 9 months ago

Also I tried, GCC currently passes through reference even if the vector size is less than 2*XLEN, which is not according to this proposal. Here is the example: https://godbolt.org/z/3ooovcz7c

That's bug, try to drop v from the -march and you will see different way to pass the arguments

kito-cheng commented 9 months ago

This proposal is great and avoids complicating the passing of fixed-length vectors. But the problem is that it doesn't take advantage of vector registers. Are there any more details about this issue?

We need separated calling convention for that case, because not every system has v, and here is the working draft for that one:

https://github.com/riscv-non-isa/riscv-elf-psabi-doc/tree/fixed-length-vector-cc