Skip to content

Commit b593748

Browse files
committed
add nvptx_target_feature
1 parent 9f274ba commit b593748

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

compiler/rustc_feature/src/unstable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ declare_features! (
324324
(unstable, loongarch_target_feature, "1.73.0", Some(44839)),
325325
(unstable, m68k_target_feature, "1.85.0", Some(134328)),
326326
(unstable, mips_target_feature, "1.27.0", Some(44839)),
327+
(unstable, nvptx_target_feature, "CURRENT_RUSTC_VERSION", Some(44839)),
327328
(unstable, powerpc_target_feature, "1.27.0", Some(44839)),
328329
(unstable, prfchw_target_feature, "1.78.0", Some(44839)),
329330
(unstable, riscv_target_feature, "1.45.0", Some(44839)),

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,7 @@ symbols! {
14471447
not,
14481448
notable_trait,
14491449
note,
1450+
nvptx_target_feature,
14501451
object_safe_for_dispatch,
14511452
of,
14521453
off,

compiler/rustc_target/src/target_features.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,39 @@ const MIPS_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
482482
// tidy-alphabetical-end
483483
];
484484

485+
const NVPTX_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
486+
// tidy-alphabetical-start
487+
("sm_20", Unstable(sym::nvptx_target_feature), &[]),
488+
("sm_21", Unstable(sym::nvptx_target_feature), &["sm_20"]),
489+
("sm_30", Unstable(sym::nvptx_target_feature), &["sm_21"]),
490+
("sm_32", Unstable(sym::nvptx_target_feature), &["sm_30"]),
491+
("sm_35", Unstable(sym::nvptx_target_feature), &["sm_32"]),
492+
("sm_37", Unstable(sym::nvptx_target_feature), &["sm_35"]),
493+
("sm_50", Unstable(sym::nvptx_target_feature), &["sm_37"]),
494+
("sm_52", Unstable(sym::nvptx_target_feature), &["sm_50"]),
495+
("sm_53", Unstable(sym::nvptx_target_feature), &["sm_52"]),
496+
("sm_60", Unstable(sym::nvptx_target_feature), &["sm_53"]),
497+
("sm_61", Unstable(sym::nvptx_target_feature), &["sm_60"]),
498+
("sm_62", Unstable(sym::nvptx_target_feature), &["sm_61"]),
499+
("sm_70", Unstable(sym::nvptx_target_feature), &["sm_62"]),
500+
("sm_72", Unstable(sym::nvptx_target_feature), &["sm_70"]),
501+
("sm_75", Unstable(sym::nvptx_target_feature), &["sm_72"]),
502+
("sm_80", Unstable(sym::nvptx_target_feature), &["sm_75"]),
503+
("sm_86", Unstable(sym::nvptx_target_feature), &["sm_80"]),
504+
("sm_87", Unstable(sym::nvptx_target_feature), &["sm_86"]),
505+
("sm_90", Unstable(sym::nvptx_target_feature), &["sm_87"]),
506+
("sm_90a", Unstable(sym::nvptx_target_feature), &["sm_90"]),
507+
// tidy-alphabetical-end
508+
// tidy-alphabetical-start
509+
("sm_100", Unstable(sym::nvptx_target_feature), &["sm_90a"]),
510+
("sm_100a", Unstable(sym::nvptx_target_feature), &["sm_100"]),
511+
("sm_101", Unstable(sym::nvptx_target_feature), &["sm_100a"]),
512+
("sm_101a", Unstable(sym::nvptx_target_feature), &["sm_101"]),
513+
("sm_120", Unstable(sym::nvptx_target_feature), &["sm_101a"]),
514+
("sm_120a", Unstable(sym::nvptx_target_feature), &["sm_120"]),
515+
// tidy-alphabetical-end
516+
];
517+
485518
static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
486519
// tidy-alphabetical-start
487520
("a", Stable, &["zaamo", "zalrsc"]),
@@ -679,6 +712,7 @@ pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> {
679712
.chain(HEXAGON_FEATURES.iter())
680713
.chain(POWERPC_FEATURES.iter())
681714
.chain(MIPS_FEATURES.iter())
715+
.chain(NVPTX_FEATURES.iter())
682716
.chain(RISCV_FEATURES.iter())
683717
.chain(WASM_FEATURES.iter())
684718
.chain(BPF_FEATURES.iter())
@@ -732,6 +766,7 @@ impl Target {
732766
"x86" | "x86_64" => X86_FEATURES,
733767
"hexagon" => HEXAGON_FEATURES,
734768
"mips" | "mips32r6" | "mips64" | "mips64r6" => MIPS_FEATURES,
769+
"nvptx32" | "nvptx64" => NVPTX_FEATURES,
735770
"powerpc" | "powerpc64" => POWERPC_FEATURES,
736771
"riscv32" | "riscv64" => RISCV_FEATURES,
737772
"wasm32" | "wasm64" => WASM_FEATURES,
@@ -758,6 +793,7 @@ impl Target {
758793
"sparc" | "sparc64" => SPARC_FEATURES_FOR_CORRECT_VECTOR_ABI,
759794
"hexagon" => HEXAGON_FEATURES_FOR_CORRECT_VECTOR_ABI,
760795
"mips" | "mips32r6" | "mips64" | "mips64r6" => MIPS_FEATURES_FOR_CORRECT_VECTOR_ABI,
796+
"nvptx" => &[], // no vector ABI
761797
"bpf" | "m68k" => &[], // no vector ABI
762798
"csky" => CSKY_FEATURES_FOR_CORRECT_VECTOR_ABI,
763799
// FIXME: for some tier3 targets, we are overly cautious and always give warnings

library/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
//
203203
// Target features:
204204
// tidy-alphabetical-start
205+
#![cfg_attr(not(bootstrap), feature(nvptx_target_feature))]
205206
#![feature(aarch64_unstable_target_feature)]
206207
#![feature(arm_target_feature)]
207208
#![feature(avx512_target_feature)]

tests/ui/target-feature/gate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// gate-test-arm_target_feature
88
// gate-test-hexagon_target_feature
99
// gate-test-mips_target_feature
10+
// gate-test-nvptx_target_feature
1011
// gate-test-wasm_target_feature
1112
// gate-test-adx_target_feature
1213
// gate-test-cmpxchg16b_target_feature

0 commit comments

Comments
 (0)