Skip to content

Commit

Permalink
Adjust the V calling convention to aid lazy binding
Browse files Browse the repository at this point in the history
The whole point of this VARIANT_CC bit is that we want to be able to use
V registers in _dl_resolve without saving them.  That requires that the
interface between the caller and the callee does not rely on the values
in the V registers.  That's a bit different than how we've histrorically
defined these temporary register clobbers, which is about the the
caller-side visibility into register changes.

Signed-off-by: Palmer Dabbelt <[email protected]>

---

I'm not entirely sure what the right way to describe this one is.  What
I've got here feels a bit clunky and doesn't call out the lazy binding
issue, but at least it's something.  It also only applies to the V
register calling convention, as it's not clear if the goal here is to
retroactively make this apply to X and F.
  • Loading branch information
palmer-dabbelt committed May 26, 2022
1 parent 68efc8d commit eefd8b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion riscv-cc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ duration in accordance with C11 section 7.6 "Floating-point environment
.Vector register convention
[%autowidth]
|===
| Name | ABI Mnemonic | Meaning | Preserved across calls?
| Name | ABI Mnemonic | Meaning | Preserved into calls?

| v0-v31 | | Temporary registers | No
| vl | | Vector length | No
Expand Down
9 changes: 3 additions & 6 deletions riscv-elf.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,9 @@ Any functions that use registers in a way that is incompatible with
the calling convention of the ABI in use must be annotated with
`STO_RISCV_VARIANT_CC`, as defined in <<Symbol Table>>.

NOTE: Vector registers have a variable size depending on the hardware
implementation and can be quite large. Saving/restoring all these vector
arguments in a run-time linker's lazy resolver would use a large amount of
stack space and hurt performance. This attribute allows vector registers to
not be part of the standard calling convention so run-time linkers are not
required to save/restore them and can instead eagerly bind such functions.
NOTE: The standard caling conventions all clobber the V registers on calls, so
this allows for the direct use (ie, without an expensive save/restore) of those
registers while resolving lazily bound functions.

== C++ Name Mangling

Expand Down

0 comments on commit eefd8b0

Please sign in to comment.