Skip to content

Commit cec39a0

Browse files
authored
Stack slots are at least XLEN-bit aligned (#138)
* Stack slots are at least XLEN-bit aligned And, for integral arguments, the unused space is not undefined. Resolves #137 * Clarify extension behavior for FP args
1 parent c5a0588 commit cec39a0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

riscv-elf.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,12 @@ The base integer calling convention provides eight argument registers,
9595
a0-a7, the first two of which are also used to return values.
9696

9797
Scalars that are at most XLEN bits wide are passed in a single argument
98-
register, or on the stack by value if none is available. When passed in
99-
registers, scalars narrower than XLEN bits are widened according to the sign
100-
of their type up to 32 bits, then sign-extended to XLEN bits.
98+
register, or on the stack by value if none is available.
99+
When passed in registers or on the stack, integer scalars narrower than XLEN
100+
bits are widened according to the sign of their type up to 32 bits, then
101+
sign-extended to XLEN bits.
102+
When passed in registers or on the stack, floating-point types narrower than
103+
XLEN bits are widened to XLEN bits, with the upper bits undefined.
101104

102105
Scalars that are 2✕XLEN bits wide are passed in a pair of argument registers,
103106
with the low-order XLEN bits in the lower-numbered register and the high-order
@@ -119,8 +122,8 @@ available, the aggregate is passed on the stack. Bits unused due to
119122
padding, and bits past the end of an aggregate whose size in bits is not
120123
divisible by XLEN, are undefined.
121124

122-
Aggregates or scalars passed on the stack are aligned to the minimum of the
123-
object alignment and the stack alignment.
125+
Aggregates or scalars passed on the stack are aligned to the greater of the
126+
type alignment and XLEN bits, but never more than the stack alignment.
124127

125128
Aggregates larger than 2✕XLEN bits are passed by reference and are replaced in
126129
the argument list with the address, as are C++ aggregates with nontrivial copy
@@ -214,6 +217,8 @@ A real floating-point argument is passed in a floating-point argument
214217
register if it is no more than FLEN bits wide and at least one floating-point
215218
argument register is available. Otherwise, it is passed according to the
216219
integer calling convention.
220+
When a floating-point argument narrower than FLEN bits is passed in a
221+
floating-point register, it is 1-extended (NaN-boxed) to FLEN bits.
217222

218223
A struct containing just one floating-point real is passed as though it were
219224
a standalone floating-point real.

0 commit comments

Comments
 (0)