Skip to content

Commit 18d88a2

Browse files
committed
add struct pass rule and update some description
1 parent c68db6d commit 18d88a2

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

riscv-cc.adoc

+19-15
Original file line numberDiff line numberDiff line change
@@ -327,27 +327,31 @@ provided they hold values no more than ABI_FLEN bits wide.
327327

328328
=== Hardware Vector Calling Convention
329329

330-
The first named scalar argument of vector mask type use v0 to pass. Other named
331-
scalar arguments of the same type pass like the named scalar arguments of
332-
vector data type. See the following description about named scalar arguments
333-
of vector data type.
330+
This section applies only to named arguments. Variadic arguments of vector type are passed by reference.
334331

335-
Named scalar arguments of vector data type has property LMUL. If LMUL is less
336-
than 1, treat it as 1. If it is possible to find unused registers segment
337-
starting from v1 and the first register in segment is LMUL-aligned, use these
338-
registers to pass the argument. Otherwise, pass through the function stack.
332+
The hardware vector calling convention adds 1 argument register for vector mask type argument and 31 argument registers for vector data and tuple type argument which are v0 and v1-v31, respectively. v0 is used for the first vector mask type argument and the vector mask type return value, the rest of the mask type arguments are treated as vector data type arguments. v1-v31 are also used for the vector data and tuple type return value.
339333

340-
Aggregates cannot pass with vector registers.
334+
Vector data type arguments have properties LMUL and NREGS, the current LMUL can be 1/8, 1/4, 1/2, 1, 2, 4, 8, the current NREGS can be 1, 2, 4, 8. For arguments with LMUL less than 1, their LMUL is treated as 1. The LMUL of the vector mask type argument is treated as 1. The NREGS property means the number of registers needed for this argument. For vector data type, NREGS is 1 when LMUL is less than 1, otherwise NREGS is equal to LMUL. If it is possible to find NREGS unused continuous vector register set starting from v1 and its first register is LMUL-aligned, use these registers to pass the argument. Otherwise, the argument is passed by reference.
341335

342-
Variadic vector arguments are passed by reference.
336+
vector tuple type arguments have the same LMUL and NREGS properties as the vector data type, but also have the NF property. NREGS equals NF multiplied by LMUL, but cannot exceed 8. The process of finding the argument registers is the same as for the vector data type.
343337

344-
Vector mask value is rturned in the same manner as a first named argument of the
345-
same type would be passed.
338+
NOTE: The vector mask type, data type and tuple type are defined https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob/master/rvv-intrinsic-rfc.md#type-system[here].
346339

347-
Vector data value is returnd in the same manner as a first named argument of the
348-
same type would be passed.
340+
A struct containing just one vector type value is passed as though it were a standalone vector type value.
349341

350-
NOTE: vector mask type and data type defined https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob/master/rvv-intrinsic-rfc.md#type-system[here]. Data type include tuple type.
342+
A struct containing two vector type values is passed in vector registers, if there are suitable unused continuous vector register sets for them.
343+
344+
A struct containing one vector type value and one integer (or bitfield), in either order, is passed in vector registers and an integer register, provided the integer is no more than XLEN bits wide, and at least one unused continuous vector register set and at least one integer argument register are available.
345+
346+
A struct containing one vector type value and one floating-point real, in either order, is passed in vector registers and an floating-point register, provided the floating-point real is no more than ABI_FLEN bits wide, and at least one unused continuous vector register set and at least one floating-point argument register are available.
347+
348+
A struct is not passed in the above manner, then it is passed according to the integer calling convention.
349+
350+
NOTE: See the Hardware Floating-point Calling Convention section for the definition of struct.
351+
352+
Unions are never flattened and are always passed according to the integer calling convention.
353+
354+
Values are returned in the same manner as the first named argument of the same type would be passed.
351355

352356
=== ILP32E Calling Convention
353357

0 commit comments

Comments
 (0)