Skip to content

Commit 9a81ba4

Browse files
committed
Clarify how struct pass in register
`first half` is incorrect description if the struct size is less than 2 x XLEN bits, for example a 48 byte struct passed in register pair for RV32, first 32-bits will hold in first register and the remaining 16-bits will hold in second register, but `first half` means 24 bits in first register and next 24 bits in next register, that is not we implement on both LLVM and GCC. Example code for demonstrate that: ``` struct X { short x; int y; } __attribute__ ((packed)); int foo(int a0, int a1, int a2, int a3, int a4, int a5, int a6, struct X a7) { return a7.y; } int bar(struct X a7) { return a7.y; } ``` Address review comment come from LLVM community[1]. [1] https://lists.llvm.org/pipermail/llvm-dev/2022-January/154600.html
1 parent faf9a9d commit 9a81ba4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

riscv-cc.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ Aggregates whose total size is no more than XLEN bits are passed in
109109
a register, with the fields laid out as though they were passed in memory. If
110110
no register is available, the aggregate is passed on the stack.
111111
Aggregates whose total size is no more than 2×XLEN bits are passed in a pair
112-
of registers; if only one register is available, the first half is passed in
113-
a register and the second half is passed on the stack. If no registers are
112+
of registers; if only one register is available, the first XLEN bits are passed
113+
in a register and the remaining bits are passed on the stack. If no registers are
114114
available, the aggregate is passed on the stack. Bits unused due to
115115
padding, and bits past the end of an aggregate whose size in bits is not
116116
divisible by XLEN, are undefined.

0 commit comments

Comments
 (0)