]>
git.proxmox.com Git - rustc.git/blob - src/stdsimd/crates/core_arch/src/x86/bt.rs
2 use stdsimd_test
::assert_instr
;
4 /// Returns the bit in position `b` of the memory addressed by `p`.
6 #[cfg_attr(test, assert_instr(bt))]
7 #[unstable(feature = "simd_x86_bittest", issue = "59414")]
8 pub unsafe fn _bittest(p
: *const i32, b
: i32) -> u8 {
10 asm
!("btl $2, $1\n\tsetc ${0:b}"
17 /// Returns the bit in position `b` of the memory addressed by `p`, then sets the bit to `1`.
19 #[cfg_attr(test, assert_instr(bts))]
20 #[unstable(feature = "simd_x86_bittest", issue = "59414")]
21 pub unsafe fn _bittestandset(p
: *mut i32, b
: i32) -> u8 {
23 asm
!("btsl $2, $1\n\tsetc ${0:b}"
30 /// Returns the bit in position `b` of the memory addressed by `p`, then resets that bit to `0`.
32 #[cfg_attr(test, assert_instr(btr))]
33 #[unstable(feature = "simd_x86_bittest", issue = "59414")]
34 pub unsafe fn _bittestandreset(p
: *mut i32, b
: i32) -> u8 {
36 asm
!("btrl $2, $1\n\tsetc ${0:b}"
43 /// Returns the bit in position `b` of the memory addressed by `p`, then inverts that bit.
45 #[cfg_attr(test, assert_instr(btc))]
46 #[unstable(feature = "simd_x86_bittest", issue = "59414")]
47 pub unsafe fn _bittestandcomplement(p
: *mut i32, b
: i32) -> u8 {
49 asm
!("btcl $2, $1\n\tsetc ${0:b}"
58 use crate::core_arch
::x86
::*;
63 let a
= 0b0101_0000i32;
64 assert_eq
!(_bittest(&a
as _
, 4), 1);
65 assert_eq
!(_bittest(&a
as _
, 5), 0);
70 fn test_bittestandset() {
72 let mut a
= 0b0101_0000i32;
73 assert_eq
!(_bittestandset(&mut a
as _
, 4), 1);
74 assert_eq
!(_bittestandset(&mut a
as _
, 4), 1);
75 assert_eq
!(_bittestandset(&mut a
as _
, 5), 0);
76 assert_eq
!(_bittestandset(&mut a
as _
, 5), 1);
81 fn test_bittestandreset() {
83 let mut a
= 0b0101_0000i32;
84 assert_eq
!(_bittestandreset(&mut a
as _
, 4), 1);
85 assert_eq
!(_bittestandreset(&mut a
as _
, 4), 0);
86 assert_eq
!(_bittestandreset(&mut a
as _
, 5), 0);
87 assert_eq
!(_bittestandreset(&mut a
as _
, 5), 0);
92 fn test_bittestandcomplement() {
94 let mut a
= 0b0101_0000i32;
95 assert_eq
!(_bittestandcomplement(&mut a
as _
, 4), 1);
96 assert_eq
!(_bittestandcomplement(&mut a
as _
, 4), 0);
97 assert_eq
!(_bittestandcomplement(&mut a
as _
, 4), 1);
98 assert_eq
!(_bittestandcomplement(&mut a
as _
, 5), 0);
99 assert_eq
!(_bittestandcomplement(&mut a
as _
, 5), 1);