Skip to content

Commit 55add8f

Browse files
committed
rustc_target: Add more RISC-V vector-related features
1 parent 4e2b096 commit 55add8f

File tree

3 files changed

+77
-3
lines changed

3 files changed

+77
-3
lines changed

Diff for: compiler/rustc_codegen_llvm/src/llvm_util.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
274274
("arm", "fp16") => Some(LLVMFeature::new("fullfp16")),
275275
// In LLVM 18, `unaligned-scalar-mem` was merged with `unaligned-vector-mem` into a single
276276
// feature called `fast-unaligned-access`. In LLVM 19, it was split back out.
277-
("riscv32" | "riscv64", "unaligned-scalar-mem") if get_version().0 == 18 => {
277+
("riscv32" | "riscv64", "unaligned-scalar-mem" | "unaligned-vector-mem")
278+
if get_version().0 == 18 =>
279+
{
278280
Some(LLVMFeature::new("fast-unaligned-access"))
279281
}
280282
// Filter out features that are not supported by the current LLVM version

Diff for: compiler/rustc_target/src/target_features.rs

+37-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,8 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
497497
("m", Stable, &[]),
498498
("relax", Unstable(sym::riscv_target_feature), &[]),
499499
("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]),
500-
("v", Unstable(sym::riscv_target_feature), &[]),
500+
("unaligned-vector-mem", Unstable(sym::riscv_target_feature), &[]),
501+
("v", Unstable(sym::riscv_target_feature), &["zvl128b", "zve64d"]),
501502
("za128rs", Unstable(sym::riscv_target_feature), &[]),
502503
("za64rs", Unstable(sym::riscv_target_feature), &[]),
503504
("zaamo", Unstable(sym::riscv_target_feature), &[]),
@@ -529,6 +530,41 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
529530
("zksed", Stable, &[]),
530531
("zksh", Stable, &[]),
531532
("zkt", Stable, &[]),
533+
("zvbb", Unstable(sym::riscv_target_feature), &["zvkb"]),
534+
("zvbc", Unstable(sym::riscv_target_feature), &["zve64x"]),
535+
("zve32f", Unstable(sym::riscv_target_feature), &["zve32x", "f"]),
536+
("zve32x", Unstable(sym::riscv_target_feature), &["zvl32b"]),
537+
("zve64d", Unstable(sym::riscv_target_feature), &["zve64f", "d"]),
538+
("zve64f", Unstable(sym::riscv_target_feature), &["zve32f", "zve64x"]),
539+
("zve64x", Unstable(sym::riscv_target_feature), &["zve32x", "zvl64b"]),
540+
("zvfh", Unstable(sym::riscv_target_feature), &["zvfhmin", "zfhmin"]),
541+
("zvfhmin", Unstable(sym::riscv_target_feature), &["zve32f"]),
542+
("zvkb", Unstable(sym::riscv_target_feature), &["zve32x"]),
543+
("zvkg", Unstable(sym::riscv_target_feature), &["zve32x"]),
544+
("zvkn", Unstable(sym::riscv_target_feature), &["zvkned", "zvknhb", "zvkb", "zvkt"]),
545+
("zvknc", Unstable(sym::riscv_target_feature), &["zvkn", "zvbc"]),
546+
("zvkned", Unstable(sym::riscv_target_feature), &["zve32x"]),
547+
("zvkng", Unstable(sym::riscv_target_feature), &["zvkn", "zvkg"]),
548+
("zvknha", Unstable(sym::riscv_target_feature), &["zve32x"]),
549+
("zvknhb", Unstable(sym::riscv_target_feature), &["zve64x"]),
550+
("zvks", Unstable(sym::riscv_target_feature), &["zvksed", "zvksh", "zvkb", "zvkt"]),
551+
("zvksc", Unstable(sym::riscv_target_feature), &["zvks", "zvbc"]),
552+
("zvksed", Unstable(sym::riscv_target_feature), &["zve32x"]),
553+
("zvksg", Unstable(sym::riscv_target_feature), &["zvks", "zvkg"]),
554+
("zvksh", Unstable(sym::riscv_target_feature), &["zve32x"]),
555+
("zvkt", Unstable(sym::riscv_target_feature), &[]),
556+
("zvl1024b", Unstable(sym::riscv_target_feature), &["zvl512b"]),
557+
("zvl128b", Unstable(sym::riscv_target_feature), &["zvl64b"]),
558+
("zvl16384b", Unstable(sym::riscv_target_feature), &["zvl8192b"]),
559+
("zvl2048b", Unstable(sym::riscv_target_feature), &["zvl1024b"]),
560+
("zvl256b", Unstable(sym::riscv_target_feature), &["zvl128b"]),
561+
("zvl32768b", Unstable(sym::riscv_target_feature), &["zvl16384b"]),
562+
("zvl32b", Unstable(sym::riscv_target_feature), &[]),
563+
("zvl4096b", Unstable(sym::riscv_target_feature), &["zvl2048b"]),
564+
("zvl512b", Unstable(sym::riscv_target_feature), &["zvl256b"]),
565+
("zvl64b", Unstable(sym::riscv_target_feature), &["zvl32b"]),
566+
("zvl65536b", Unstable(sym::riscv_target_feature), &["zvl32768b"]),
567+
("zvl8192b", Unstable(sym::riscv_target_feature), &["zvl4096b"]),
532568
// tidy-alphabetical-end
533569
];
534570

Diff for: tests/ui/check-cfg/target_feature.stderr

+37-1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
245245
`trustzone`
246246
`ual`
247247
`unaligned-scalar-mem`
248+
`unaligned-vector-mem`
248249
`v`
249250
`v5te`
250251
`v6`
@@ -325,7 +326,42 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
325326
`zkr`
326327
`zks`
327328
`zksed`
328-
`zksh`, and `zkt`
329+
`zksh`
330+
`zkt`
331+
`zvbb`
332+
`zvbc`
333+
`zve32f`
334+
`zve32x`
335+
`zve64d`
336+
`zve64f`
337+
`zve64x`
338+
`zvfh`
339+
`zvfhmin`
340+
`zvkb`
341+
`zvkg`
342+
`zvkn`
343+
`zvknc`
344+
`zvkned`
345+
`zvkng`
346+
`zvknha`
347+
`zvknhb`
348+
`zvks`
349+
`zvksc`
350+
`zvksed`
351+
`zvksg`
352+
`zvksh`
353+
`zvkt`
354+
`zvl1024b`
355+
`zvl128b`
356+
`zvl16384b`
357+
`zvl2048b`
358+
`zvl256b`
359+
`zvl32768b`
360+
`zvl32b`
361+
`zvl4096b`
362+
`zvl512b`
363+
`zvl64b`
364+
`zvl65536b`, and `zvl8192b`
329365
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
330366
= note: `#[warn(unexpected_cfgs)]` on by default
331367

0 commit comments

Comments
 (0)