]>
git.proxmox.com Git - rustc.git/blob - src/stdarch/crates/core_arch/src/x86_64/bt.rs
2 use stdarch_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 _bittest64(p
: *const i64, b
: i64) -> u8 {
10 asm
!("btq $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 _bittestandset64(p
: *mut i64, b
: i64) -> u8 {
23 asm
!("btsq $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 _bittestandreset64(p
: *mut i64, b
: i64) -> u8 {
36 asm
!("btrq $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 _bittestandcomplement64(p
: *mut i64, b
: i64) -> u8 {
49 asm
!("btcq $2, $1\n\tsetc ${0:b}"
58 use crate::core_arch
::x86_64
::*;
63 let a
= 0b0101_0000i64;
64 assert_eq
!(_bittest64(&a
as _
, 4), 1);
65 assert_eq
!(_bittest64(&a
as _
, 5), 0);
70 fn test_bittestandset64() {
72 let mut a
= 0b0101_0000i64;
73 assert_eq
!(_bittestandset64(&mut a
as _
, 4), 1);
74 assert_eq
!(_bittestandset64(&mut a
as _
, 4), 1);
75 assert_eq
!(_bittestandset64(&mut a
as _
, 5), 0);
76 assert_eq
!(_bittestandset64(&mut a
as _
, 5), 1);
81 fn test_bittestandreset64() {
83 let mut a
= 0b0101_0000i64;
84 assert_eq
!(_bittestandreset64(&mut a
as _
, 4), 1);
85 assert_eq
!(_bittestandreset64(&mut a
as _
, 4), 0);
86 assert_eq
!(_bittestandreset64(&mut a
as _
, 5), 0);
87 assert_eq
!(_bittestandreset64(&mut a
as _
, 5), 0);
92 fn test_bittestandcomplement64() {
94 let mut a
= 0b0101_0000i64;
95 assert_eq
!(_bittestandcomplement64(&mut a
as _
, 4), 1);
96 assert_eq
!(_bittestandcomplement64(&mut a
as _
, 4), 0);
97 assert_eq
!(_bittestandcomplement64(&mut a
as _
, 4), 1);
98 assert_eq
!(_bittestandcomplement64(&mut a
as _
, 5), 0);
99 assert_eq
!(_bittestandcomplement64(&mut a
as _
, 5), 1);