From e2c9aa0b1e93f93589b6e5b6a25be2a885bcd2a0 Mon Sep 17 00:00:00 2001 From: Liao Shihua Date: Fri, 19 May 2023 11:58:06 +0800 Subject: [PATCH 1/3] RV64ILP32: Add RV64ILP32* ABIs on RV64* ISAs support riscv-cc.adoc: - Add ABIs and ISAs mapping description about RV64ILP32* ABIs on RV64* ISAs. - Correct C/{Cpp} type sizes and alignments descriptions. riscv-elf.adoc: - Add EF_RISCV_RV64ILP32 in e_flags field. Signed-off-by: Liao Shihua Signed-off-by: Guo Ren --- riscv-cc.adoc | 12 ++++++------ riscv-elf.adoc | 18 +++++++++++++----- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/riscv-cc.adoc b/riscv-cc.adoc index f6ab1882..23a3d789 100644 --- a/riscv-cc.adoc +++ b/riscv-cc.adoc @@ -493,10 +493,10 @@ LP64Q:: LP64 with hardware floating-point calling convention for ABI_FLEN=128 (i.e. <> and <>). -The ILP32* ABIs are only compatible with RV32* ISAs, and the LP64* ABIs are -only compatible with RV64* ISAs. A future version of this specification may -define an ILP32 ABI for the RV64 ISA, but currently this is not a supported -operating mode. +The LP64* ABIs are only compatible with RV64* ISAs. The ILP32* are compatible +with RV32* and RV64* ISAs. + +NOTE: RV64ILP32* ABIs are experimental. The *F ABIs require the *F ISA extension, the *D ABIs require the *D ISA extension, and the LP64Q ABI requires the Q ISA extension. @@ -535,7 +535,7 @@ There are two conventions for C/{Cpp} type sizes and alignments. ILP32, ILP32F, ILP32D, and ILP32E:: Use the following type sizes and alignments (based on the ILP32 convention): + -.C/{Cpp} type sizes and alignments for RV32 +.C/{Cpp} type sizes and alignments for ILP32 [cols="4,>2,>3,4"] [width=60%] |=== @@ -561,7 +561,7 @@ alignments (based on the ILP32 convention): LP64, LP64F, LP64D, and LP64Q:: Use the following type sizes and alignments (based on the LP64 convention): + -.C/{Cpp} type sizes and alignments for RV64 +.C/{Cpp} type sizes and alignments for LP64 [cols="4,>2,>3,4"] [width=60%] |=== diff --git a/riscv-elf.adoc b/riscv-elf.adoc index 9d4ea27f..f08ecba4 100644 --- a/riscv-elf.adoc +++ b/riscv-elf.adoc @@ -247,8 +247,8 @@ header fields; any fields not listed in this section have no RISC-V-specific values. e_ident:: - EI_CLASS::: Specifies the base ISA, either RV32 or RV64. - Linking RV32 and RV64 code together is not supported. + EI_CLASS::: Specifies the ABIs, either ILP32*, LP64* or RV64ILP32*. + Linking different ABIs' code together is not supported. + -- [horizontal] @@ -277,12 +277,12 @@ below. + [[e-flags-layout]] .Layout of e_flags -[cols="1,2,1,1,3,5"] +[cols="1,2,1,1,1,3,5"] [width=80%] |=== -| Bit 0 | Bits 1 - 2 | Bit 3 | Bit 4 | Bits 5 - 23 | Bits 24 - 31 +| Bit 0 | Bits 1 - 2 | Bit 3 | Bit 4 | Bit 5 | Bits 6 - 23 | Bits 24 - 31 -| RVC | Float ABI | RVE | TSO | *Reserved* | *Non-standard extensions* +| RVC | Float ABI | RVE | TSO | RV64ILP32 | *Reserved* | *Non-standard extensions* |=== + @@ -320,6 +320,11 @@ below. EF_RISCV_TSO (0x0010)::: This bit is set when the binary requires the RVTSO memory consistency model. + EF_RISCV_RV64ILP32 (0x0020)::: This bit is set when the binary requires the + RV64ILP32* ABIs on RV64* ISAs. + +NOTE: RV64ILP32* ABIs are experimental. + Until such a time that the *Reserved* bits (0x00ffffe0) are allocated by future versions of this specification, they shall not be set by standard software. Non-standard extensions are free to use bits 24-31 for any purpose. This may @@ -355,6 +360,9 @@ raise an error. TSO::: Input files can have different values for the TSO field; the linker should set this field if any of the input objects have the TSO field set. + RV64ILP32::: Linker should report errors if object files of different value + for RV64ILP32 field. + NOTE: The static linker may ignore the compatibility checks if all fields in the `e_flags` are zero and all sections in the input file are non-executable sections. From 9803707baeef9a5ca634df0cde749a8f8b4d2946 Mon Sep 17 00:00:00 2001 From: Guo Ren Date: Tue, 3 Dec 2024 16:05:39 +0800 Subject: [PATCH 2/3] RV64ILP32: Add calling convention description Add abi-rv64ilp32(f)(d)(q) calling convention sections. Signed-off-by: Guo Ren Signed-off-by: Liao Shihua Signed-off-by: Jia-Wei Chen --- introduction.adoc | 4 ++++ riscv-cc.adoc | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/introduction.adoc b/introduction.adoc index d5f27667..3b7a435a 100644 --- a/introduction.adoc +++ b/introduction.adoc @@ -50,6 +50,10 @@ This specification uses the following terms and abbreviations: | LP64F | Ratified | LP64D | Ratified | LP64Q | Ratified +| RV64ILP32 | Draft +| RV64ILP32F | Draft +| RV64ILP32D | Draft +| RV64ILP32Q | Draft |=== NOTE: ABI for big-endian is *NOT* included in this specification, we intend to diff --git a/riscv-cc.adoc b/riscv-cc.adoc index 23a3d789..d0a88cf0 100644 --- a/riscv-cc.adoc +++ b/riscv-cc.adoc @@ -449,6 +449,15 @@ The ILP32E calling convention is not compatible with ISAs that have registers that require load and store alignments of more than 32 bits. In particular, this calling convention must not be used with the D ISA extension. +=== RV64ILP32* Calling Convention + +IMPORTANT: RV64ILP32* ABIs are experimental. + +The RV64ILP32* calling convention is designed to be usable with the RV64* ISA. +These calling conventions are composed of the integer & floating-point & vector +calling conventions. When passed in registers or on the stack, pointer scalars +(32-bit), narrower than XLEN bits (64-bit), are sign-extended to XLEN bits. + === Named ABIs This specification defines the following named ABIs: @@ -493,6 +502,26 @@ LP64Q:: LP64 with hardware floating-point calling convention for ABI_FLEN=128 (i.e. <> and <>). +[[abi-rv64ilp32]] +RV64ILP32:: Integer calling-convention only, hardware +floating-point calling convention is not used (i.e. <> and +<>). + +[[abi-rv64ilp32f]] +RV64ILP32F:: RV64ILP32 with hardware floating-point calling +convention for ABI_FLEN=32 (i.e. <> and +<>). + +[[abi-rv64ilp32d]] +RV64ILP32D:: RV64ILP32 with hardware floating-point calling +convention for ABI_FLEN=64 (i.e. <> and +<>). + +[[abi-rv64ilp32q]] +RV64ILP32Q:: RV64ILP32 with hardware floating-point calling +convention for ABI_FLEN=128 (i.e. <> and +<>). + The LP64* ABIs are only compatible with RV64* ISAs. The ILP32* are compatible with RV32* and RV64* ISAs. From 71782e920773f2ec683cacc6c127f96dce7b8644 Mon Sep 17 00:00:00 2001 From: Guo Ren Date: Fri, 6 Dec 2024 15:16:25 +0800 Subject: [PATCH 3/3] RV64ILP32: Add note for medium any code model address space The address space of RV64ILP32* ABIs is not continuous in the middle for medium any code model. Signed-off-by: Guo Ren Signed-off-by: Liao Shihua Signed-off-by: Jia-Wei Chen --- riscv-elf.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/riscv-elf.adoc b/riscv-elf.adoc index f08ecba4..7202a7d5 100644 --- a/riscv-elf.adoc +++ b/riscv-elf.adoc @@ -101,6 +101,8 @@ NOTE: Although the generated code is technically position independent, it's not suitable for ELF shared libraries due to differing symbol interposition rules; for that, please use the medium position independent code model below. +NOTE: The address space of RV64ILP32* ABIs is not continuous in the middle. + === Medium position independent code model This model is similar to the medium any code model, but uses the