-
Notifications
You must be signed in to change notification settings - Fork 288
[arm] bitwise manipulation instructions #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
602915a
[arm] bitwise manipulation instructions
gnzlbg 799b92c
[bmi] add some more code-gen tests
gnzlbg 52fb0e4
[assert-instr] compare only the instruction prefix
gnzlbg f765407
[appveyor] enable panic backtraces
gnzlbg 2285f74
[assert-instr] simplify
gnzlbg d116aea
Help debug missing assembly
alexcrichton 4fe06c1
Fix Windows MSVC CI
alexcrichton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -15,7 +15,7 @@ debug = true | |
opt-level = 3 | ||
|
||
[profile.bench] | ||
debug = 1 | ||
debug = true | ||
opt-level = 3 | ||
|
||
[dev-dependencies] | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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,10 @@ | ||
//! ARM intrinsics. | ||
pub use self::v6::*; | ||
pub use self::v7::*; | ||
#[cfg(target_arch = "aarch64")] | ||
pub use self::v8::*; | ||
|
||
mod v6; | ||
mod v7; | ||
#[cfg(target_arch = "aarch64")] | ||
mod v8; |
This file contains hidden or 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,25 @@ | ||
//! ARMv6 intrinsics. | ||
//! | ||
//! The reference is [ARMv6-M Architecture Reference | ||
//! Manual](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0419c/index.html). | ||
|
||
/// Reverse the order of the bytes. | ||
#[inline(always)] | ||
#[cfg_attr(test, assert_instr(rev))] | ||
pub fn _rev_u8(x: u8) -> u8 { | ||
x.swap_bytes() as u8 | ||
} | ||
|
||
/// Reverse the order of the bytes. | ||
#[inline(always)] | ||
#[cfg_attr(test, assert_instr(rev))] | ||
pub fn _rev_u16(x: u16) -> u16 { | ||
x.swap_bytes() as u16 | ||
} | ||
|
||
/// Reverse the order of the bytes. | ||
#[inline(always)] | ||
#[cfg_attr(test, assert_instr(rev))] | ||
pub fn _rev_u32(x: u32) -> u32 { | ||
x.swap_bytes() as u32 | ||
} |
This file contains hidden or 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,40 @@ | ||
//! ARMv7 intrinsics. | ||
//! | ||
//! The reference is [ARMv7-M Architecture Reference Manual (Issue | ||
//! E.b)](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0403e.b/index.html). | ||
|
||
pub use super::v6::*; | ||
|
||
/// Count Leading Zeros. | ||
#[inline(always)] | ||
#[cfg_attr(test, assert_instr(clz))] | ||
pub fn _clz_u8(x: u8) -> u8 { | ||
x.leading_zeros() as u8 | ||
} | ||
|
||
/// Count Leading Zeros. | ||
#[inline(always)] | ||
#[cfg_attr(test, assert_instr(clz))] | ||
pub fn _clz_u16(x: u16) -> u16 { | ||
x.leading_zeros() as u16 | ||
} | ||
|
||
/// Count Leading Zeros. | ||
#[inline(always)] | ||
#[cfg_attr(test, assert_instr(clz))] | ||
pub fn _clz_u32(x: u32) -> u32 { | ||
x.leading_zeros() as u32 | ||
} | ||
|
||
#[allow(dead_code)] | ||
extern "C" { | ||
#[link_name="llvm.bitreverse.i32"] | ||
fn rbit_u32(i: i32) -> i32; | ||
} | ||
|
||
/// Reverse the bit order. | ||
#[inline(always)] | ||
#[cfg_attr(test, assert_instr(rbit))] | ||
pub fn _rbit_u32(x: u32) -> u32 { | ||
unsafe { rbit_u32(x as i32) as u32 } | ||
} |
This file contains hidden or 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,54 @@ | ||
//! ARMv8 intrinsics. | ||
//! | ||
//! The reference is [ARMv8-A Reference Manual](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0487a.k_10775/index.html). | ||
|
||
pub use super::v7::*; | ||
|
||
/// Reverse the order of the bytes. | ||
#[inline(always)] | ||
#[cfg_attr(test, assert_instr(rev))] | ||
pub fn _rev_u64(x: u64) -> u64 { | ||
x.swap_bytes() as u64 | ||
} | ||
|
||
/// Count Leading Zeros. | ||
#[inline(always)] | ||
#[cfg_attr(test, assert_instr(clz))] | ||
pub fn _clz_u64(x: u64) -> u64 { | ||
x.leading_zeros() as u64 | ||
} | ||
|
||
#[allow(dead_code)] | ||
extern "C" { | ||
#[link_name="llvm.bitreverse.i64"] | ||
fn rbit_u64(i: i64) -> i64; | ||
} | ||
|
||
/// Reverse the bit order. | ||
#[inline(always)] | ||
#[cfg_attr(test, assert_instr(rbit))] | ||
pub fn _rbit_u64(x: u64) -> u64 { | ||
unsafe { rbit_u64(x as i64) as u64 } | ||
} | ||
|
||
/// Counts the leading most significant bits set. | ||
/// | ||
/// When all bits of the operand are set it returns the size of the operand in | ||
/// bits. | ||
#[inline(always)] | ||
// LLVM Bug (should be cls): https://bugs.llvm.org/show_bug.cgi?id=31802 | ||
#[cfg_attr(test, assert_instr(clz))] | ||
pub fn _cls_u32(x: u32) -> u32 { | ||
u32::leading_zeros(!x) as u32 | ||
} | ||
|
||
/// Counts the leading most significant bits set. | ||
/// | ||
/// When all bits of the operand are set it returns the size of the operand in | ||
/// bits. | ||
#[inline(always)] | ||
// LLVM Bug (should be cls): https://bugs.llvm.org/show_bug.cgi?id=31802 | ||
#[cfg_attr(test, assert_instr(clz))] | ||
pub fn _cls_u64(x: u64) -> u64 { | ||
u64::leading_zeros(!x) as u64 | ||
} |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have never thought of this.