Skip to content

Commit 2386a73

Browse files
committed
Minor revision
- Reorder rule. - Pass struct as tuple-type in register only when vector arg reg is enough, otherwise passed in reference. - Add NOTE for describe what if ABI_VLEN is smaller than VLEN, also come with an example. - Add NOTE for describe different functions may use different ABI_VLEN values.
1 parent 1039ad6 commit 2386a73

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

riscv-cc.adoc

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -482,22 +482,25 @@ A fixed-length vector argument is passed in eight vector argument registers,
482482
similar to vector data arguments with LMUL=8, if the size of the vector is
483483
greater than 4×ABI_VLEN bit and less than or equal to 8×ABI_VLEN bit.
484484

485+
A fixed-length vector argument is passed by reference and is replaced in the
486+
argument list with the address if it is larger than 8×ABI_VLEN bit or if
487+
there is a shortage of vector argument registers.
488+
485489
A struct containing members with all fixed-length vectors will be passed in
486490
vector argument registers like a vector tuple type if all members have the
487491
same length, the length is less or equal to 8×ABI_VLEN bit, and the size of
488-
the whole struct is less than 8×ABI_VLEN bit. Otherwise, it will use the rule
489-
defined in the hardware floating-point calling convention.
492+
the whole struct is less than 8×ABI_VLEN bit.
493+
If there are not enough vector argument registers to pass the entire struct,
494+
it will pass by reference and is replaced in the argument list with the address.
495+
Otherwise, it will use the rule defined in the hardware floating-point calling
496+
convention.
490497

491498
A struct containing just one fixed-length vector array is passed as though it
492499
were a vector tuple type if the size of the base element for the array is less
493500
or equal to 8×ABI_VLEN bit, and the size of the array is less than 8×ABI_VLEN
494501
bit. Otherwise, it will use the rule defined in the hardware floating-point
495502
calling convention.
496503

497-
A fixed-length vector argument is passed by reference and is replaced in the
498-
argument list with the address if it is larger than 8×ABI_VLEN bit or if
499-
there is a shortage of vector argument registers.
500-
501504
Unions with fixed-length vectors are always passed according to the integer
502505
calling convention.
503506

@@ -508,6 +511,36 @@ NOTE: Functions that use the standard fixed-length vector calling convention
508511
variant must be marked with STO_RISCV_VARIANT_CC. See <<Dynamic Linking>>
509512
for the meaning of STO_RISCV_VARIANT_CC.
510513

514+
[NOTE]
515+
====
516+
When ABI_VLEN is smaller than the VLEN, the number of vector argument
517+
registers utilized remains unchanged. However, in such cases, values are only
518+
placed in a portion of these vector argument registers, corresponding to the
519+
size of ABI_VLEN. The remaining portion of the vector argument registers, which
520+
extends beyond the ABI_VLEN, will remain idle. This means that while the full
521+
capacity of the vector argument registers may not be used, the allocation of
522+
these registers do not change, ensuring consistency in register usage regardless
523+
of the ABI_VLEN to VLEN ratio.
524+
525+
Example: With ABI_VLEN at 32 bits and VLEN at 128 bits, consider passing an
526+
`int32x4_t` parameter (four 32-bit integers).
527+
528+
Allocation: Four vector argument registers are allocated for
529+
`int32x4_t`, based on LMUL=4.
530+
531+
Utilization: All four integers are placed in the first vector register,
532+
utilizing its full 128-bit capacity (VLEN), despite ABI_VLEN being 32 bits.
533+
534+
Remaining Registers: The other three allocated registers remain unused and idle.
535+
====
536+
537+
NOTE: In a single compilation unit, different functions may use different
538+
ABI_VLEN values. This means that ABI_VLEN is not uniform across the entire unit,
539+
allowing for function-specific optimization. However, this necessitates that
540+
users ensure consistency in ABI_VLEN between calling and called functions. It
541+
is the user's responsibility to verify that the ABI_VLEN matches on both sides
542+
of a function call to ensure correct operation and data handling.
543+
511544
=== ILP32E Calling Convention
512545

513546
IMPORTANT: RV32E is not a ratified base ISA and so we cannot guarantee the

0 commit comments

Comments
 (0)