RISC-V big-endian register pairs follow significance ordering.
RISC-V big-endian targets now correctly order 2*XLEN register pairs by significance, not memory layout, for arguments and return values.
The RISC-V psABI mandates that 2XLEN scalar arguments and return values be ordered by significance, irrespective of endianness. On big-endian targets, this significance-based ordering differs from the typical memory layout ordering. This commit implements the correct significance-based ordering for named 2XLEN scalar register pairs. Anonymous variadic arguments, aggregates, and floating-point reals maintain their existing memory-layout ordering to ensure compatibility with existing conventions.
In Details
This change corrects the calling convention for 2*XLEN scalar values (arguments and return values) on RISC-V big-endian targets. The RISC-V ELF psABI (specifically the recent change to riscv-elf-psabi-doc/pull/470) requires that such values be passed in register pairs ordered by significance: the lower XLEN bits go in the lower-numbered register, and the higher XLEN bits go in the higher-numbered register. This ordering is independent of the target's endianness. The implementation introduces riscv_2xlen_significance_scalar_p and riscv_pass_2xlen_scalar_gpr_pair to handle this. Crucially…
- RISC-V
- An open-standard instruction set architecture (ISA) based on Reduced Instruction Set Computing principles.
- psABI
- Processor-Specific Application Binary Interface. Defines the low-level conventions for how software should be written for a particular processor architecture, including register usage, calling conventions, and data layout.
- XLEN
- The word size of the RISC-V architecture, typically 32 bits (RV32) or 64 bits (RV64).
- big-endian
- A computer architecture where the most significant byte of a multi-byte word is stored at the lowest memory address.
- register pair
- Two consecutive registers used together to hold a value larger than a single register's capacity, such as a 64-bit value on a 32-bit architecture.
- significance-based ordering
- An ordering where data is arranged according to its numerical significance, typically with the most significant part in the lower-addressed or lower-numbered register.
- memory-layout ordering
- An ordering where data is arranged according to how it would be laid out in memory, which can differ from significance-based ordering on big-endian systems.
- va_arg
- A macro used in C to access arguments passed to a variadic function (a function that can accept a variable number of arguments).