Skip to content

Stabilize sha512, sm3 and sm4 intrinsics and runtime detection #1796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions crates/core_arch/src/x86/sha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub fn _mm_sha256rnds2_epu32(a: __m128i, b: __m128i, k: __m128i) -> __m128i {
#[inline]
#[target_feature(enable = "sha512,avx")]
#[cfg_attr(test, assert_instr(vsha512msg1))]
#[unstable(feature = "sha512_sm_x86", issue = "126624")]
#[stable(feature = "sha512_sm_x86", since = "CURRENT_RUSTC_VERSION")]
pub fn _mm256_sha512msg1_epi64(a: __m256i, b: __m128i) -> __m256i {
unsafe { transmute(vsha512msg1(a.as_i64x4(), b.as_i64x2())) }
}
Expand All @@ -159,7 +159,7 @@ pub fn _mm256_sha512msg1_epi64(a: __m256i, b: __m128i) -> __m256i {
#[inline]
#[target_feature(enable = "sha512,avx")]
#[cfg_attr(test, assert_instr(vsha512msg2))]
#[unstable(feature = "sha512_sm_x86", issue = "126624")]
#[stable(feature = "sha512_sm_x86", since = "CURRENT_RUSTC_VERSION")]
pub fn _mm256_sha512msg2_epi64(a: __m256i, b: __m256i) -> __m256i {
unsafe { transmute(vsha512msg2(a.as_i64x4(), b.as_i64x4())) }
}
Expand All @@ -175,7 +175,7 @@ pub fn _mm256_sha512msg2_epi64(a: __m256i, b: __m256i) -> __m256i {
#[inline]
#[target_feature(enable = "sha512,avx")]
#[cfg_attr(test, assert_instr(vsha512rnds2))]
#[unstable(feature = "sha512_sm_x86", issue = "126624")]
#[stable(feature = "sha512_sm_x86", since = "CURRENT_RUSTC_VERSION")]
pub fn _mm256_sha512rnds2_epi64(a: __m256i, b: __m256i, k: __m128i) -> __m256i {
unsafe { transmute(vsha512rnds2(a.as_i64x4(), b.as_i64x4(), k.as_i64x2())) }
}
Expand All @@ -188,7 +188,7 @@ pub fn _mm256_sha512rnds2_epi64(a: __m256i, b: __m256i, k: __m128i) -> __m256i {
#[inline]
#[target_feature(enable = "sm3,avx")]
#[cfg_attr(test, assert_instr(vsm3msg1))]
#[unstable(feature = "sha512_sm_x86", issue = "126624")]
#[stable(feature = "sha512_sm_x86", since = "CURRENT_RUSTC_VERSION")]
pub fn _mm_sm3msg1_epi32(a: __m128i, b: __m128i, c: __m128i) -> __m128i {
unsafe { transmute(vsm3msg1(a.as_i32x4(), b.as_i32x4(), c.as_i32x4())) }
}
Expand All @@ -201,7 +201,7 @@ pub fn _mm_sm3msg1_epi32(a: __m128i, b: __m128i, c: __m128i) -> __m128i {
#[inline]
#[target_feature(enable = "sm3,avx")]
#[cfg_attr(test, assert_instr(vsm3msg2))]
#[unstable(feature = "sha512_sm_x86", issue = "126624")]
#[stable(feature = "sha512_sm_x86", since = "CURRENT_RUSTC_VERSION")]
pub fn _mm_sm3msg2_epi32(a: __m128i, b: __m128i, c: __m128i) -> __m128i {
unsafe { transmute(vsm3msg2(a.as_i32x4(), b.as_i32x4(), c.as_i32x4())) }
}
Expand All @@ -219,7 +219,7 @@ pub fn _mm_sm3msg2_epi32(a: __m128i, b: __m128i, c: __m128i) -> __m128i {
#[target_feature(enable = "sm3,avx")]
#[cfg_attr(test, assert_instr(vsm3rnds2, IMM8 = 0))]
#[rustc_legacy_const_generics(3)]
#[unstable(feature = "sha512_sm_x86", issue = "126624")]
#[stable(feature = "sha512_sm_x86", since = "CURRENT_RUSTC_VERSION")]
pub fn _mm_sm3rnds2_epi32<const IMM8: i32>(a: __m128i, b: __m128i, c: __m128i) -> __m128i {
static_assert!(
IMM8 == (IMM8 & 0x3e),
Expand All @@ -235,7 +235,7 @@ pub fn _mm_sm3rnds2_epi32<const IMM8: i32>(a: __m128i, b: __m128i, c: __m128i) -
#[inline]
#[target_feature(enable = "sm4,avx")]
#[cfg_attr(test, assert_instr(vsm4key4))]
#[unstable(feature = "sha512_sm_x86", issue = "126624")]
#[stable(feature = "sha512_sm_x86", since = "CURRENT_RUSTC_VERSION")]
pub fn _mm_sm4key4_epi32(a: __m128i, b: __m128i) -> __m128i {
unsafe { transmute(vsm4key4128(a.as_i32x4(), b.as_i32x4())) }
}
Expand All @@ -247,7 +247,7 @@ pub fn _mm_sm4key4_epi32(a: __m128i, b: __m128i) -> __m128i {
#[inline]
#[target_feature(enable = "sm4,avx")]
#[cfg_attr(test, assert_instr(vsm4key4))]
#[unstable(feature = "sha512_sm_x86", issue = "126624")]
#[stable(feature = "sha512_sm_x86", since = "CURRENT_RUSTC_VERSION")]
pub fn _mm256_sm4key4_epi32(a: __m256i, b: __m256i) -> __m256i {
unsafe { transmute(vsm4key4256(a.as_i32x8(), b.as_i32x8())) }
}
Expand All @@ -259,7 +259,7 @@ pub fn _mm256_sm4key4_epi32(a: __m256i, b: __m256i) -> __m256i {
#[inline]
#[target_feature(enable = "sm4,avx")]
#[cfg_attr(test, assert_instr(vsm4rnds4))]
#[unstable(feature = "sha512_sm_x86", issue = "126624")]
#[stable(feature = "sha512_sm_x86", since = "CURRENT_RUSTC_VERSION")]
pub fn _mm_sm4rnds4_epi32(a: __m128i, b: __m128i) -> __m128i {
unsafe { transmute(vsm4rnds4128(a.as_i32x4(), b.as_i32x4())) }
}
Expand All @@ -271,7 +271,7 @@ pub fn _mm_sm4rnds4_epi32(a: __m128i, b: __m128i) -> __m128i {
#[inline]
#[target_feature(enable = "sm4,avx")]
#[cfg_attr(test, assert_instr(vsm4rnds4))]
#[unstable(feature = "sha512_sm_x86", issue = "126624")]
#[stable(feature = "sha512_sm_x86", since = "CURRENT_RUSTC_VERSION")]
pub fn _mm256_sm4rnds4_epi32(a: __m256i, b: __m256i) -> __m256i {
unsafe { transmute(vsm4rnds4256(a.as_i32x8(), b.as_i32x8())) }
}
Expand Down
6 changes: 3 additions & 3 deletions crates/std_detect/src/detect/arch/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ features! {
/// AVX (Advanced Vector Extensions)
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx2: "avx2";
/// AVX2 (Advanced Vector Extensions 2)
@FEATURE: #[unstable(feature = "sha512_sm_x86", issue = "126624")] sha512: "sha512";
@FEATURE: #[stable(feature = "sha512_sm_x86", since = "CURRENT_RUSTC_VERSION")] sha512: "sha512";
/// SHA512
@FEATURE: #[unstable(feature = "sha512_sm_x86", issue = "126624")] sm3: "sm3";
@FEATURE: #[stable(feature = "sha512_sm_x86", since = "CURRENT_RUSTC_VERSION")] sm3: "sm3";
/// SM3
@FEATURE: #[unstable(feature = "sha512_sm_x86", issue = "126624")] sm4: "sm4";
@FEATURE: #[stable(feature = "sha512_sm_x86", since = "CURRENT_RUSTC_VERSION")] sm4: "sm4";
/// SM4
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512f: "avx512f" ;
/// AVX-512 F (Foundation)
Expand Down