Skip to content

Commit 3a79e93

Browse files
authored
Merge pull request #381 from Liaoshihua/master
Support ILP32 on RV64 in psABI
2 parents eb2b296 + 71782e9 commit 3a79e93

File tree

3 files changed

+54
-11
lines changed

3 files changed

+54
-11
lines changed

introduction.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ This specification uses the following terms and abbreviations:
5050
| LP64F | Ratified
5151
| LP64D | Ratified
5252
| LP64Q | Ratified
53+
| RV64ILP32 | Draft
54+
| RV64ILP32F | Draft
55+
| RV64ILP32D | Draft
56+
| RV64ILP32Q | Draft
5357
|===
5458

5559
NOTE: ABI for big-endian is *NOT* included in this specification, we intend to

riscv-cc.adoc

+35-6
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,15 @@ The ILP32E calling convention is not compatible with ISAs that have registers
449449
that require load and store alignments of more than 32 bits. In particular, this
450450
calling convention must not be used with the D ISA extension.
451451

452+
=== RV64ILP32* Calling Convention
453+
454+
IMPORTANT: RV64ILP32* ABIs are experimental.
455+
456+
The RV64ILP32* calling convention is designed to be usable with the RV64* ISA.
457+
These calling conventions are composed of the integer & floating-point & vector
458+
calling conventions. When passed in registers or on the stack, pointer scalars
459+
(32-bit), narrower than XLEN bits (64-bit), are sign-extended to XLEN bits.
460+
452461
=== Named ABIs
453462

454463
This specification defines the following named ABIs:
@@ -493,10 +502,30 @@ LP64Q:: LP64 with hardware floating-point calling
493502
convention for ABI_FLEN=128 (i.e. <<ELFCLASS64,ELFCLASS64>> and
494503
<<EF_RISCV_FLOAT_ABI_QUAD,EF_RISCV_FLOAT_ABI_QUAD>>).
495504

496-
The ILP32* ABIs are only compatible with RV32* ISAs, and the LP64* ABIs are
497-
only compatible with RV64* ISAs. A future version of this specification may
498-
define an ILP32 ABI for the RV64 ISA, but currently this is not a supported
499-
operating mode.
505+
[[abi-rv64ilp32]]
506+
RV64ILP32:: Integer calling-convention only, hardware
507+
floating-point calling convention is not used (i.e. <<ELFCLASS32,ELFCLASS32>> and
508+
<<EF_RISCV_FLOAT_ABI_SINGLE,EF_RISCV_FLOAT_ABI_SINGLE>>).
509+
510+
[[abi-rv64ilp32f]]
511+
RV64ILP32F:: RV64ILP32 with hardware floating-point calling
512+
convention for ABI_FLEN=32 (i.e. <<ELFCLASS32,ELFCLASS32>> and
513+
<<EF_RISCV_FLOAT_ABI_SINGLE,EF_RISCV_FLOAT_ABI_SINGLE>>).
514+
515+
[[abi-rv64ilp32d]]
516+
RV64ILP32D:: RV64ILP32 with hardware floating-point calling
517+
convention for ABI_FLEN=64 (i.e. <<ELFCLASS32,ELFCLASS32>> and
518+
<<EF_RISCV_FLOAT_ABI_DOUBLE,EF_RISCV_FLOAT_ABI_DOUBLE>>).
519+
520+
[[abi-rv64ilp32q]]
521+
RV64ILP32Q:: RV64ILP32 with hardware floating-point calling
522+
convention for ABI_FLEN=128 (i.e. <<ELFCLASS32,ELFCLASS32>> and
523+
<<EF_RISCV_FLOAT_ABI_QUAD,EF_RISCV_FLOAT_ABI_QUAD>>).
524+
525+
The LP64* ABIs are only compatible with RV64* ISAs. The ILP32* are compatible
526+
with RV32* and RV64* ISAs.
527+
528+
NOTE: RV64ILP32* ABIs are experimental.
500529

501530
The *F ABIs require the *F ISA extension, the *D ABIs require the *D ISA
502531
extension, and the LP64Q ABI requires the Q ISA extension.
@@ -535,7 +564,7 @@ There are two conventions for C/{Cpp} type sizes and alignments.
535564
ILP32, ILP32F, ILP32D, and ILP32E:: Use the following type sizes and
536565
alignments (based on the ILP32 convention):
537566
+
538-
.C/{Cpp} type sizes and alignments for RV32
567+
.C/{Cpp} type sizes and alignments for ILP32
539568
[cols="4,>2,>3,4"]
540569
[width=60%]
541570
|===
@@ -561,7 +590,7 @@ alignments (based on the ILP32 convention):
561590
LP64, LP64F, LP64D, and LP64Q:: Use the following type sizes and
562591
alignments (based on the LP64 convention):
563592
+
564-
.C/{Cpp} type sizes and alignments for RV64
593+
.C/{Cpp} type sizes and alignments for LP64
565594
[cols="4,>2,>3,4"]
566595
[width=60%]
567596
|===

riscv-elf.adoc

+15-5
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ NOTE: Although the generated code is technically position independent, it's not
101101
suitable for ELF shared libraries due to differing symbol interposition rules;
102102
for that, please use the medium position independent code model below.
103103

104+
NOTE: The address space of RV64ILP32* ABIs is not continuous in the middle.
105+
104106
=== Medium position independent code model
105107

106108
This model is similar to the medium any code model, but uses the
@@ -247,8 +249,8 @@ header fields; any fields not listed in this section have no RISC-V-specific
247249
values.
248250

249251
e_ident::
250-
EI_CLASS::: Specifies the base ISA, either RV32 or RV64.
251-
Linking RV32 and RV64 code together is not supported.
252+
EI_CLASS::: Specifies the ABIs, either ILP32*, LP64* or RV64ILP32*.
253+
Linking different ABIs' code together is not supported.
252254
+
253255
--
254256
[horizontal]
@@ -277,12 +279,12 @@ below.
277279
+
278280
[[e-flags-layout]]
279281
.Layout of e_flags
280-
[cols="1,2,1,1,3,5"]
282+
[cols="1,2,1,1,1,3,5"]
281283
[width=80%]
282284
|===
283-
| Bit 0 | Bits 1 - 2 | Bit 3 | Bit 4 | Bits 5 - 23 | Bits 24 - 31
285+
| Bit 0 | Bits 1 - 2 | Bit 3 | Bit 4 | Bit 5 | Bits 6 - 23 | Bits 24 - 31
284286

285-
| RVC | Float ABI | RVE | TSO | *Reserved* | *Non-standard extensions*
287+
| RVC | Float ABI | RVE | TSO | RV64ILP32 | *Reserved* | *Non-standard extensions*
286288
|===
287289

288290
+
@@ -320,6 +322,11 @@ below.
320322
EF_RISCV_TSO (0x0010)::: This bit is set when the binary requires the RVTSO
321323
memory consistency model.
322324

325+
EF_RISCV_RV64ILP32 (0x0020)::: This bit is set when the binary requires the
326+
RV64ILP32* ABIs on RV64* ISAs.
327+
328+
NOTE: RV64ILP32* ABIs are experimental.
329+
323330
Until such a time that the *Reserved* bits (0x00ffffe0) are allocated by future
324331
versions of this specification, they shall not be set by standard software.
325332
Non-standard extensions are free to use bits 24-31 for any purpose. This may
@@ -355,6 +362,9 @@ raise an error.
355362
TSO::: Input files can have different values for the TSO field; the linker
356363
should set this field if any of the input objects have the TSO field set.
357364

365+
RV64ILP32::: Linker should report errors if object files of different value
366+
for RV64ILP32 field.
367+
358368
NOTE: The static linker may ignore the compatibility checks if all fields in the
359369
`e_flags` are zero and all sections in the input file are non-executable
360370
sections.

0 commit comments

Comments
 (0)