Skip to content

Commit 613d43b

Browse files
committed
mark BMI2 intrinsics as safe
Mark all BMI2 intrinsics as safe. `_mulx_u32` and `_mulx_u64` accepts a reference instead of a pointer.
1 parent dea9ce2 commit 613d43b

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Diff for: crates/core_arch/src/x86/bmi2.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use stdarch_test::assert_instr;
2525
#[cfg_attr(all(test, target_arch = "x86"), assert_instr(mul))]
2626
#[target_feature(enable = "bmi2")]
2727
#[stable(feature = "simd_x86", since = "1.27.0")]
28-
pub unsafe fn _mulx_u32(a: u32, b: u32, hi: &mut u32) -> u32 {
28+
pub fn _mulx_u32(a: u32, b: u32, hi: &mut u32) -> u32 {
2929
let result: u64 = (a as u64) * (b as u64);
3030
*hi = (result >> 32) as u32;
3131
result as u32
@@ -38,8 +38,8 @@ pub unsafe fn _mulx_u32(a: u32, b: u32, hi: &mut u32) -> u32 {
3838
#[target_feature(enable = "bmi2")]
3939
#[cfg_attr(test, assert_instr(bzhi))]
4040
#[stable(feature = "simd_x86", since = "1.27.0")]
41-
pub unsafe fn _bzhi_u32(a: u32, index: u32) -> u32 {
42-
x86_bmi2_bzhi_32(a, index)
41+
pub fn _bzhi_u32(a: u32, index: u32) -> u32 {
42+
unsafe { x86_bmi2_bzhi_32(a, index) }
4343
}
4444

4545
/// Scatter contiguous low order bits of `a` to the result at the positions
@@ -50,8 +50,8 @@ pub unsafe fn _bzhi_u32(a: u32, index: u32) -> u32 {
5050
#[target_feature(enable = "bmi2")]
5151
#[cfg_attr(test, assert_instr(pdep))]
5252
#[stable(feature = "simd_x86", since = "1.27.0")]
53-
pub unsafe fn _pdep_u32(a: u32, mask: u32) -> u32 {
54-
x86_bmi2_pdep_32(a, mask)
53+
pub fn _pdep_u32(a: u32, mask: u32) -> u32 {
54+
unsafe { x86_bmi2_pdep_32(a, mask) }
5555
}
5656

5757
/// Gathers the bits of `x` specified by the `mask` into the contiguous low
@@ -62,8 +62,8 @@ pub unsafe fn _pdep_u32(a: u32, mask: u32) -> u32 {
6262
#[target_feature(enable = "bmi2")]
6363
#[cfg_attr(test, assert_instr(pext))]
6464
#[stable(feature = "simd_x86", since = "1.27.0")]
65-
pub unsafe fn _pext_u32(a: u32, mask: u32) -> u32 {
66-
x86_bmi2_pext_32(a, mask)
65+
pub fn _pext_u32(a: u32, mask: u32) -> u32 {
66+
unsafe { x86_bmi2_pext_32(a, mask) }
6767
}
6868

6969
unsafe extern "C" {

Diff for: crates/core_arch/src/x86_64/bmi2.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use stdarch_test::assert_instr;
2424
#[target_feature(enable = "bmi2")]
2525
#[cfg(not(target_arch = "x86"))] // calls an intrinsic
2626
#[stable(feature = "simd_x86", since = "1.27.0")]
27-
pub unsafe fn _mulx_u64(a: u64, b: u64, hi: &mut u64) -> u64 {
27+
pub fn _mulx_u64(a: u64, b: u64, hi: &mut u64) -> u64 {
2828
let result: u128 = (a as u128) * (b as u128);
2929
*hi = (result >> 64) as u64;
3030
result as u64
@@ -38,8 +38,8 @@ pub unsafe fn _mulx_u64(a: u64, b: u64, hi: &mut u64) -> u64 {
3838
#[cfg_attr(test, assert_instr(bzhi))]
3939
#[cfg(not(target_arch = "x86"))]
4040
#[stable(feature = "simd_x86", since = "1.27.0")]
41-
pub unsafe fn _bzhi_u64(a: u64, index: u32) -> u64 {
42-
x86_bmi2_bzhi_64(a, index as u64)
41+
pub fn _bzhi_u64(a: u64, index: u32) -> u64 {
42+
unsafe { x86_bmi2_bzhi_64(a, index as u64) }
4343
}
4444

4545
/// Scatter contiguous low order bits of `a` to the result at the positions
@@ -51,8 +51,8 @@ pub unsafe fn _bzhi_u64(a: u64, index: u32) -> u64 {
5151
#[cfg_attr(test, assert_instr(pdep))]
5252
#[cfg(not(target_arch = "x86"))]
5353
#[stable(feature = "simd_x86", since = "1.27.0")]
54-
pub unsafe fn _pdep_u64(a: u64, mask: u64) -> u64 {
55-
x86_bmi2_pdep_64(a, mask)
54+
pub fn _pdep_u64(a: u64, mask: u64) -> u64 {
55+
unsafe { x86_bmi2_pdep_64(a, mask) }
5656
}
5757

5858
/// Gathers the bits of `x` specified by the `mask` into the contiguous low
@@ -64,8 +64,8 @@ pub unsafe fn _pdep_u64(a: u64, mask: u64) -> u64 {
6464
#[cfg_attr(test, assert_instr(pext))]
6565
#[cfg(not(target_arch = "x86"))]
6666
#[stable(feature = "simd_x86", since = "1.27.0")]
67-
pub unsafe fn _pext_u64(a: u64, mask: u64) -> u64 {
68-
x86_bmi2_pext_64(a, mask)
67+
pub fn _pext_u64(a: u64, mask: u64) -> u64 {
68+
unsafe { x86_bmi2_pext_64(a, mask) }
6969
}
7070

7171
unsafe extern "C" {

0 commit comments

Comments
 (0)