Skip to content

Commit a4cf5e9

Browse files
committed
Add new Tier-3 target: riscv64a23-unknown-linux-gnu
1 parent 5771665 commit a4cf5e9

File tree

7 files changed

+166
-1
lines changed

7 files changed

+166
-1
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,11 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
278278
None
279279
}
280280
// Filter out features that are not supported by the current LLVM version
281-
("riscv32" | "riscv64", "zacas") if get_version().0 < 20 => None,
281+
("riscv32" | "riscv64", "zacas" | "rva23s64" | "rva23u64" | "sha" | "ssnpm" | "supm")
282+
if get_version().0 < 20 =>
283+
{
284+
None
285+
}
282286
(
283287
"s390x",
284288
"message-security-assist-extension12"

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,6 +2137,7 @@ supported_targets! {
21372137
("riscv64gc-unknown-none-elf", riscv64gc_unknown_none_elf),
21382138
("riscv64gc-unknown-linux-gnu", riscv64gc_unknown_linux_gnu),
21392139
("riscv64gc-unknown-linux-musl", riscv64gc_unknown_linux_musl),
2140+
("riscv64a23-unknown-linux-gnu", riscv64a23_unknown_linux_gnu),
21402141

21412142
("sparc-unknown-none-elf", sparc_unknown_none_elf),
21422143

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use std::borrow::Cow;
2+
3+
use crate::spec::{CodeModel, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base};
4+
5+
pub(crate) fn target() -> Target {
6+
Target {
7+
llvm_target: "riscv64-unknown-linux-gnu".into(),
8+
metadata: TargetMetadata {
9+
description: Some("RISC-V Linux (kernel 4.20, glibc 2.29)".into()),
10+
tier: Some(3),
11+
host_tools: Some(true),
12+
std: Some(true),
13+
},
14+
pointer_width: 64,
15+
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
16+
arch: "riscv64".into(),
17+
options: TargetOptions {
18+
code_model: Some(CodeModel::Medium),
19+
cpu: "generic-rv64".into(),
20+
features: "+rva23u64,+rva23s64".into(),
21+
llvm_abiname: "lp64d".into(),
22+
max_atomic_width: Some(64),
23+
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
24+
..base::linux_gnu::opts()
25+
},
26+
}
27+
}

compiler/rustc_target/src/target_features.rs

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,119 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
597597
),
598598
("m", Stable, &[]),
599599
("relax", Unstable(sym::riscv_target_feature), &[]),
600+
(
601+
"rva23s64",
602+
Unstable(sym::riscv_target_feature),
603+
&[
604+
"m",
605+
"a",
606+
"f",
607+
"d",
608+
"c",
609+
"b",
610+
"v",
611+
"zicsr",
612+
"zicntr",
613+
"zihpm",
614+
"ziccif",
615+
"ziccrse",
616+
"ziccamoa",
617+
"zicclsm",
618+
"zic64b",
619+
"za64rs",
620+
"zihintpause",
621+
"zba",
622+
"zbb",
623+
"zbs",
624+
"zicbom",
625+
"zicbop",
626+
"zicboz",
627+
"zfhmin",
628+
"zkt",
629+
"zvfhmin",
630+
"zvbb",
631+
"zvkt",
632+
"zihintntl",
633+
"zicond",
634+
"zimop",
635+
"zcmop",
636+
"zcb",
637+
"zfa",
638+
"zawrs",
639+
"svbare",
640+
"svade",
641+
"ssccptr",
642+
"sstvecd",
643+
"sstvala",
644+
"sscounterenw",
645+
"svpbmt",
646+
"svinval",
647+
"svnapot",
648+
"sstc",
649+
"sscofpmf",
650+
"ssnpm",
651+
"ssu64xl",
652+
"sha",
653+
"supm",
654+
],
655+
),
656+
(
657+
"rva23u64",
658+
Unstable(sym::riscv_target_feature),
659+
&[
660+
"m",
661+
"a",
662+
"f",
663+
"d",
664+
"c",
665+
"b",
666+
"v",
667+
"zicsr",
668+
"zicntr",
669+
"zihpm",
670+
"ziccif",
671+
"ziccrse",
672+
"ziccamoa",
673+
"zicclsm",
674+
"zic64b",
675+
"za64rs",
676+
"zihintpause",
677+
"zba",
678+
"zbb",
679+
"zbs",
680+
"zicbom",
681+
"zicbop",
682+
"zicboz",
683+
"zfhmin",
684+
"zkt",
685+
"zvfhmin",
686+
"zvbb",
687+
"zvkt",
688+
"zihintntl",
689+
"zicond",
690+
"zimop",
691+
"zcmop",
692+
"zcb",
693+
"zfa",
694+
"zawrs",
695+
"supm",
696+
],
697+
),
698+
("sha", Unstable(sym::riscv_target_feature), &[]),
699+
("ssccptr", Unstable(sym::riscv_target_feature), &[]),
700+
("sscofpmf", Unstable(sym::riscv_target_feature), &[]),
701+
("sscounterenw", Unstable(sym::riscv_target_feature), &[]),
702+
("ssnpm", Unstable(sym::riscv_target_feature), &[]),
703+
("sstc", Unstable(sym::riscv_target_feature), &[]),
704+
("sstvala", Unstable(sym::riscv_target_feature), &[]),
705+
("sstvecd", Unstable(sym::riscv_target_feature), &[]),
706+
("ssu64xl", Unstable(sym::riscv_target_feature), &[]),
707+
("supm", Unstable(sym::riscv_target_feature), &[]),
708+
("svade", Unstable(sym::riscv_target_feature), &[]),
709+
("svbare", Unstable(sym::riscv_target_feature), &[]),
710+
("svinval", Unstable(sym::riscv_target_feature), &[]),
711+
("svnapot", Unstable(sym::riscv_target_feature), &[]),
712+
("svpbmt", Unstable(sym::riscv_target_feature), &[]),
600713
("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]),
601714
("unaligned-vector-mem", Unstable(sym::riscv_target_feature), &[]),
602715
("v", Unstable(sym::riscv_target_feature), &["zvl128b", "zve64d"]),

src/bootstrap/src/core/sanity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub struct Finder {
3434
// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap).
3535
const STAGE0_MISSING_TARGETS: &[&str] = &[
3636
"armv7a-vex-v5",
37+
"riscv64a23-unknown-linux-gnu",
3738
// just a dummy comment so the list doesn't get onelined
3839
];
3940

tests/assembly-llvm/targets/targets-elf.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@
475475
//@ revisions: riscv64gc_unknown_linux_gnu
476476
//@ [riscv64gc_unknown_linux_gnu] compile-flags: --target riscv64gc-unknown-linux-gnu
477477
//@ [riscv64gc_unknown_linux_gnu] needs-llvm-components: riscv
478+
//@ revisions: riscv64a23_unknown_linux_gnu
479+
//@ [riscv64a23_unknown_linux_gnu] compile-flags: --target riscv64a23-unknown-linux-gnu
480+
//@ [riscv64a23_unknown_linux_gnu] needs-llvm-components: riscv
478481
//@ revisions: riscv64gc_unknown_linux_musl
479482
//@ [riscv64gc_unknown_linux_musl] compile-flags: --target riscv64gc-unknown-linux-musl
480483
//@ [riscv64gc_unknown_linux_musl] needs-llvm-components: riscv

tests/ui/check-cfg/target_feature.stderr

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
241241
`relax`
242242
`relaxed-simd`
243243
`rtm`
244+
`rva23s64`
245+
`rva23u64`
244246
`sb`
245247
`scq`
246248
`sha`
@@ -292,16 +294,27 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
292294
`soft-float`
293295
`spe`
294296
`ssbs`
297+
`ssccptr`
298+
`sscofpmf`
299+
`sscounterenw`
295300
`sse`
296301
`sse2`
297302
`sse3`
298303
`sse4.1`
299304
`sse4.2`
300305
`sse4a`
306+
`ssnpm`
301307
`ssse3`
308+
`sstc`
309+
`sstvala`
310+
`sstvecd`
311+
`ssu64xl`
302312
`ssve-fp8dot2`
303313
`ssve-fp8dot4`
304314
`ssve-fp8fma`
315+
`supm`
316+
`svade`
317+
`svbare`
305318
`sve`
306319
`sve-b16b16`
307320
`sve2`
@@ -310,6 +323,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
310323
`sve2-sha3`
311324
`sve2-sm4`
312325
`sve2p1`
326+
`svinval`
327+
`svnapot`
328+
`svpbmt`
313329
`tail-call`
314330
`tbm`
315331
`thumb-mode`

0 commit comments

Comments
 (0)