Skip to content

Commit 716d766

Browse files
authored
cpufeatures: x86 support of sha512, sm3, sm4 (#1181)
https://en.wikipedia.org/wiki/CPUID#EAX=7,_ECX=1:_Extended_Features Add supports of `sha512`, `sm3` and `sm4` in x86. Rust support: rust-lang/rust#126624
1 parent 6f11249 commit 716d766

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

cpufeatures/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ Target features:
8787
- `sse4.1`
8888
- `sse4.2`
8989
- `ssse3`
90+
- `sha512`*
91+
- `sm3`*
92+
- `sm4`*
9093

9194
If you would like detection support for a target feature which is not on
9295
this list, please [open a GitHub issue].

cpufeatures/src/x86.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ macro_rules! __detect_target_features {
4747
}
4848

4949
let cr = unsafe {
50-
[cpuid(1), cpuid_count(7, 0)]
50+
[cpuid(1), cpuid_count(7, 0), cpuid_count(7, 1)]
5151
};
5252

5353
$($crate::check!(cr, $tf) & )+ true
@@ -142,4 +142,8 @@ __expand_check_macro! {
142142
("vpclmulqdq", "zmm", 1, ecx, 10),
143143
("avx512bitalg", "zmm", 1, ecx, 12),
144144
("avx512vpopcntdq", "zmm", 1, ecx, 14),
145+
146+
("sha512", "ymm", 2, eax, 0),
147+
("sm3", "xmm", 2, eax, 1),
148+
("sm4", "ymm", 2, eax, 2),
145149
}

0 commit comments

Comments
 (0)