about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-02-04 06:13:58 +0100
committerGitHub <noreply@github.com>2025-02-04 06:13:58 +0100
commite4eedb548824c0c813df4bb879b0b16c38bc39b1 (patch)
tree1ff8b70870b2f3882a947e04517c734b50d2e997
parentf8f31faeb75b739f8aa1e425c3115f4e8906fd7a (diff)
parentdc49fdd2256bde48d90dde356355d6fc31e8f855 (diff)
downloadrust-e4eedb548824c0c813df4bb879b0b16c38bc39b1.tar.gz
rust-e4eedb548824c0c813df4bb879b0b16c38bc39b1.zip
Rollup merge of #134814 - sayantn:keylocker, r=oli-obk
Add `kl` and `widekl` target features, and the feature gate

This is an effort towards #134813. This PR adds the target-features and the feature gate to `rustc`

<!--
```@rustbot``` label O-x86_64 O-x86_32 A-target-feature
r? compiler
-->
-rw-r--r--compiler/rustc_feature/src/unstable.rs2
-rw-r--r--compiler/rustc_span/src/symbol.rs1
-rw-r--r--compiler/rustc_target/src/target_features.rs2
-rw-r--r--tests/ui/check-cfg/target_feature.stderr2
-rw-r--r--tests/ui/feature-gates/feature-gate-keylocker_x86.rs6
-rw-r--r--tests/ui/feature-gates/feature-gate-keylocker_x86.stderr13
6 files changed, 26 insertions, 0 deletions
diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs
index 1a216ebf117..f5761da60f2 100644
--- a/compiler/rustc_feature/src/unstable.rs
+++ b/compiler/rustc_feature/src/unstable.rs
@@ -529,6 +529,8 @@ declare_features! (
     (unstable, inline_const_pat, "1.58.0", Some(76001)),
     /// Allows using `pointer` and `reference` in intra-doc links
     (unstable, intra_doc_pointers, "1.51.0", Some(80896)),
+    // Allows using the `kl` and `widekl` target features and the associated intrinsics
+    (unstable, keylocker_x86, "CURRENT_RUSTC_VERSION", Some(134813)),
     // Allows setting the threshold for the `large_assignments` lint.
     (unstable, large_assignments, "1.52.0", Some(83518)),
     /// Allow to have type alias types for inter-crate use.
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index b23cc909911..382b12638f4 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -1148,6 +1148,7 @@ symbols! {
         iterator,
         iterator_collect_fn,
         kcfi,
+        keylocker_x86,
         keyword,
         kind,
         kreg,
diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs
index 5355a4ad532..eb2417e0a20 100644
--- a/compiler/rustc_target/src/target_features.rs
+++ b/compiler/rustc_target/src/target_features.rs
@@ -409,6 +409,7 @@ const X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
     ("fma", Stable, &["avx"]),
     ("fxsr", Stable, &[]),
     ("gfni", Unstable(sym::avx512_target_feature), &["sse2"]),
+    ("kl", Unstable(sym::keylocker_x86), &["sse2"]),
     ("lahfsahf", Unstable(sym::lahfsahf_target_feature), &[]),
     ("lzcnt", Stable, &[]),
     ("movbe", Stable, &[]),
@@ -435,6 +436,7 @@ const X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
     ("tbm", Unstable(sym::tbm_target_feature), &[]),
     ("vaes", Unstable(sym::avx512_target_feature), &["avx2", "aes"]),
     ("vpclmulqdq", Unstable(sym::avx512_target_feature), &["avx", "pclmulqdq"]),
+    ("widekl", Unstable(sym::keylocker_x86), &["kl"]),
     ("x87", Unstable(sym::x87_target_feature), &[]),
     ("xop", Unstable(sym::xop_target_feature), &[/*"fma4", */ "avx", "sse4a"]),
     ("xsave", Stable, &[]),
diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr
index bf54d17f6ec..70852423bdb 100644
--- a/tests/ui/check-cfg/target_feature.stderr
+++ b/tests/ui/check-cfg/target_feature.stderr
@@ -127,6 +127,7 @@ LL |     cfg!(target_feature = "_UNEXPECTED_VALUE");
 `isa-68881`
 `isa-68882`
 `jsconv`
+`kl`
 `lahfsahf`
 `lasx`
 `lbt`
@@ -271,6 +272,7 @@ LL |     cfg!(target_feature = "_UNEXPECTED_VALUE");
 `vsx`
 `wfxt`
 `wide-arithmetic`
+`widekl`
 `x87`
 `xop`
 `xsave`
diff --git a/tests/ui/feature-gates/feature-gate-keylocker_x86.rs b/tests/ui/feature-gates/feature-gate-keylocker_x86.rs
new file mode 100644
index 00000000000..cef80ad41a8
--- /dev/null
+++ b/tests/ui/feature-gates/feature-gate-keylocker_x86.rs
@@ -0,0 +1,6 @@
+//@ only-x86_64
+#[target_feature(enable = "kl")]
+//~^ ERROR: currently unstable
+unsafe fn foo() {}
+
+fn main() {}
diff --git a/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr b/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr
new file mode 100644
index 00000000000..ed814d3a3ce
--- /dev/null
+++ b/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr
@@ -0,0 +1,13 @@
+error[E0658]: the target feature `kl` is currently unstable
+  --> $DIR/feature-gate-keylocker_x86.rs:2:18
+   |
+LL | #[target_feature(enable = "kl")]
+   |                  ^^^^^^^^^^^^^
+   |
+   = note: see issue #134813 <https://github.com/rust-lang/rust/issues/134813> for more information
+   = help: add `#![feature(keylocker_x86)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0658`.