Skip to content

Commit 05519a8

Browse files
committed
Further clarify treatment of bitfields in the floating-point calling convention
This patch reflects the observed behaviour from GCC, as discussed in issue #99. Fixes #99.
1 parent 78a8a0b commit 05519a8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

riscv-elf.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ register if it is no more than FLEN bits wide and at least one floating-point
197197
argument register is available. Otherwise, it is passed according to the
198198
integer calling convention.
199199

200-
A struct containing just one floating-point real is passed as though it were
201-
a standalone floating-point real.
200+
A struct containing just one floating-point real or (as a special case) one
201+
floating-point real and any number of zero-size bitfields is passed as though
202+
it were a standalone floating-point real.
202203

203204
A struct containing two floating-point reals is passed in two floating-point
204205
registers, if neither is more than FLEN bits wide and at least two floating-point
@@ -215,7 +216,13 @@ without extending the integer to XLEN bits, provided the floating-point real
215216
is no more than FLEN bits wide and the integer is no more than XLEN bits wide,
216217
and at least one floating-point argument register and at least one integer
217218
argument register is available. Otherwise, it is passed according to the
218-
integer calling convention.
219+
integer calling convention. Note that the bitfield may have a type that is
220+
larger than XLEN but can still be considered eligible for passing in this way
221+
provided the bitfield size is no more than XLEN bits wide. e.g. `struct {
222+
float f; int64_t i : 32; }` is eligible for being passed in a floating-point
223+
argument register and an integer argument register even when XLEN is 32.
224+
Zero-size bitfields are not ignored, so `struct { float f; int64_t i : 32; int
225+
0;`} would be passed according to the integer calling convention.
219226

220227
Unions are never flattened and are always passed according to the integer
221228
calling convention.

0 commit comments

Comments
 (0)