forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable verification of more intrinsics (rust-lang#309)
Looks like intrinsics that weren't listing a target feature were accidentally omitted from the verification logic, so this commit fixes that! Along the way I've ended up filing rust-lang#307 and rust-lang#308 for detected inconsistencies.
- Loading branch information
1 parent
e38d5ac
commit b68f729
Showing
6 changed files
with
97 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//! Byte swap intrinsics. | ||
#![cfg_attr(feature = "cargo-clippy", allow(stutter))] | ||
|
||
#[cfg(test)] | ||
use stdsimd_test::assert_instr; | ||
|
||
/// Return an integer with the reversed byte order of x | ||
#[inline] | ||
#[cfg_attr(test, assert_instr(bswap))] | ||
pub unsafe fn _bswap64(x: i64) -> i64 { | ||
bswap_i64(x) | ||
} | ||
|
||
#[allow(improper_ctypes)] | ||
extern "C" { | ||
#[link_name = "llvm.bswap.i64"] | ||
fn bswap_i64(x: i64) -> i64; | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_bswap64() { | ||
unsafe { | ||
assert_eq!(_bswap64(0x0EADBEEFFADECA0E), 0x0ECADEFAEFBEAD0E); | ||
assert_eq!(_bswap64(0x0000000000000000), 0x0000000000000000); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,6 @@ pub use self::bmi2::*; | |
|
||
mod avx2; | ||
pub use self::avx2::*; | ||
|
||
mod bswap; | ||
pub use self::bswap::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters