Skip to content

Commit

Permalink
Add kl and widekl target features, and the feature gate
Browse files Browse the repository at this point in the history
  • Loading branch information
sayantn committed Dec 27, 2024
1 parent 207ed1b commit dd70524
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,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.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,7 @@ symbols! {
iterator,
iterator_collect_fn,
kcfi,
keylocker_x86,
keyword,
kind,
kreg,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ const X86_FEATURES: &[(&str, StabilityUncomputed, 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, &[]),
Expand All @@ -532,6 +533,7 @@ const X86_FEATURES: &[(&str, StabilityUncomputed, 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",
Stability::Unstable {
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/check-cfg/target_feature.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`isa-68881`
`isa-68882`
`jsconv`
`kl`
`lahfsahf`
`lasx`
`lbt`
Expand Down Expand Up @@ -270,6 +271,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`vsx`
`wfxt`
`wide-arithmetic`
`widekl`
`x87`
`xop`
`xsave`
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/feature-gates/feature-gate-keylocker_x86.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@ only-x86_64
#[target_feature(enable = "kl")]
//~^ ERROR: currently unstable
unsafe fn foo() {}

fn main() {}
13 changes: 13 additions & 0 deletions tests/ui/feature-gates/feature-gate-keylocker_x86.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit dd70524

Please sign in to comment.