diff options
| author | Jed Brown <jed@jedbrown.org> | 2025-05-21 22:08:51 -0600 |
|---|---|---|
| committer | Jed Brown <jed@jedbrown.org> | 2025-06-21 19:32:47 -0600 |
| commit | 35a485ddd86229101c4c17d9167f23cf75cae644 (patch) | |
| tree | 1bb5c2b878a2e97360910d03c6d191bc73cc350b /tests/ui/target-feature | |
| parent | 6dbac3f09e67c853f343df9d75a7eb213f16c959 (diff) | |
| download | rust-35a485ddd86229101c4c17d9167f23cf75cae644.tar.gz rust-35a485ddd86229101c4c17d9167f23cf75cae644.zip | |
target-feature: enable rust target features implied by target-cpu
Normally LLVM and rustc agree about what features are implied by
target-cpu, but for NVPTX, LLVM considers sm_* and ptx* features to be
exclusive, which makes sense for codegen purposes. But in Rust, we want
to think of them as:
sm_{sver} means that the target supports the hardware features of sver
ptx{pver} means the driver supports PTX ISA pver
Intrinsics usually require a minimum sm_{sver} and ptx{pver}.
Prior to this commit, -Ctarget-cpu=sm_70 would activate only sm_70 and
ptx60 (the minimum PTX version that supports sm_70, which maximizes
driver compatibility). With this commit, it also activates all the
implied target features (sm_20, ..., sm_62; ptx32, ..., ptx50).
Diffstat (limited to 'tests/ui/target-feature')
| -rw-r--r-- | tests/ui/target-feature/implied-features-nvptx.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/ui/target-feature/implied-features-nvptx.rs b/tests/ui/target-feature/implied-features-nvptx.rs new file mode 100644 index 00000000000..1550c99f67a --- /dev/null +++ b/tests/ui/target-feature/implied-features-nvptx.rs @@ -0,0 +1,28 @@ +//@ assembly-output: ptx-linker +//@ compile-flags: --crate-type cdylib -C target-cpu=sm_80 -Z unstable-options -Clinker-flavor=llbc +//@ only-nvptx64 +//@ build-pass +#![no_std] +#![allow(dead_code)] + +#[panic_handler] +pub fn panic(_info: &core::panic::PanicInfo) -> ! { + loop {} +} + +// -Ctarget-cpu=sm_80 directly enables sm_80 and ptx70 +#[cfg(not(all(target_feature = "sm_80", target_feature = "ptx70")))] +compile_error!("direct target features not enabled"); + +// -Ctarget-cpu=sm_80 implies all earlier sm_* and ptx* features. +#[cfg(not(all( + target_feature = "sm_60", + target_feature = "sm_70", + target_feature = "ptx50", + target_feature = "ptx60", +)))] +compile_error!("implied target features not enabled"); + +// -Ctarget-cpu=sm_80 implies all earlier sm_* and ptx* features. +#[cfg(target_feature = "ptx71")] +compile_error!("sm_80 requires only ptx70, but ptx71 enabled"); |
