Rollup merge of #130555 - hegza:rv32e, r=workingjubilee

Initial support for riscv32{e|em|emc}_unknown_none_elf

We have a research prototype of an RV32EMC target and have been successfully running the e, em, emc programs on it. I'm hoping upstreaming this configuration would make the target maintenance slightly easier.

Configuration is based on the respective {i, im, imc} variants. As defined in RISC-V Unprivileged Spec. 20191213, the only change in RVE wrt. RVI is to reduce the number of integer registers to 16 (x0-x15), which also implies

- 2 callee saved registers instead of 12
- 32-bit / 4-byte stack alignment instead of 128 bits / 16 bytes

My initial presumption is that this will not impact how the target is defined for the compiler but only becomes relevant at the runtime level. I am willing to investigate, though.

EDIT: LLVM is now told about the presumed 32-bit stack alignment.

`@Disasm` `@romancardenas`
This commit is contained in:
Matthias Krüger 2024-10-05 19:07:53 +02:00 committed by GitHub
commit 8e31e98ff9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 825 additions and 1 deletions

View file

@ -37,6 +37,9 @@ pub struct Finder {
const STAGE0_MISSING_TARGETS: &[&str] = &[
// just a dummy comment so the list doesn't get onelined
"armv7-rtems-eabihf",
"riscv32e-unknown-none-elf",
"riscv32em-unknown-none-elf",
"riscv32emc-unknown-none-elf",
];
/// Minimum version threshold for libstdc++ required when using prebuilt LLVM

View file

@ -413,5 +413,8 @@ target | std | host | notes
[`riscv32imafc-unknown-nuttx-elf`](platform-support/nuttx.md) | * | | RISC-V 32bit with NuttX
[`riscv64imac-unknown-nuttx-elf`](platform-support/nuttx.md) | * | | RISC-V 64bit with NuttX
[`riscv64gc-unknown-nuttx-elf`](platform-support/nuttx.md) | * | | RISC-V 64bit with NuttX
[`riscv32e-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | | Bare RISC-V (RV32E ISA)
[`riscv32em-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | | Bare RISC-V (RV32EM ISA)
[`riscv32emc-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | | Bare RISC-V (RV32EMC ISA)
[runs on NVIDIA GPUs]: https://github.com/japaric-archived/nvptx#targets

View file

@ -35,4 +35,4 @@ Rust test-suite on this target.
## Cross-compilation toolchains and C code
This target supports C code. If interlinking with C or C++, you may need to use
`riscv64-unknown-elf-gcc` as a linker instead of `rust-lld`.
`riscv32-unknown-elf-gcc` as a linker instead of `rust-lld`.

View file

@ -0,0 +1,30 @@
# `riscv32{e,em,emc}-unknown-none-elf`
**Tier: 3**
Bare-metal target for RISC-V CPUs with the RV32E, RV32EM and RV32EMC ISAs.
## Target maintainers
* Henri Lunnikivi, <henri.lunnikivi@gmail.com>, [@hegza](https://github.com/hegza)
## Requirements
The target is cross-compiled, and uses static linking. No external toolchain is
required and the default `rust-lld` linker works, but you must specify a linker
script.
## Building the target
This target is included in Rust and can be installed via `rustup`.
## Testing
This is a cross-compiled `no-std` target, which must be run either in a
simulator or by programming them onto suitable hardware. It is not possible to
run the Rust test-suite on this target.
## Cross-compilation toolchains and C code
This target supports C code. If interlinking with C or C++, you may need to use
`riscv32-unknown-elf-gcc` as a linker instead of `rust-lld`.