]> git.proxmox.com Git - rustc.git/blob - library/stdarch/crates/core_arch/src/arm/v6.rs
New upstream version 1.49.0+dfsg1
[rustc.git] / library / stdarch / crates / core_arch / src / arm / v6.rs
1 //! ARMv6 intrinsics.
2 //!
3 //! The reference is [ARMv6-M Architecture Reference Manual][armv6m].
4 //!
5 //! [armv6m]:
6 //! http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0419c/index.
7 //! html
8
9 #[cfg(test)]
10 use stdarch_test::assert_instr;
11
12 /// Reverse the order of the bytes.
13 #[inline]
14 #[cfg_attr(test, assert_instr(rev))]
15 pub unsafe fn _rev_u16(x: u16) -> u16 {
16 x.swap_bytes() as u16
17 }
18
19 /// Reverse the order of the bytes.
20 #[inline]
21 #[cfg_attr(test, assert_instr(rev))]
22 pub unsafe fn _rev_u32(x: u32) -> u32 {
23 x.swap_bytes() as u32
24 }
25
26 #[cfg(test)]
27 mod tests {
28 use crate::core_arch::arm::v6;
29
30 #[test]
31 fn _rev_u16() {
32 unsafe {
33 assert_eq!(
34 v6::_rev_u16(0b0000_0000_1111_1111_u16),
35 0b1111_1111_0000_0000_u16
36 );
37 }
38 }
39
40 #[test]
41 fn _rev_u32() {
42 unsafe {
43 assert_eq!(
44 v6::_rev_u32(0b0000_0000_1111_1111_0000_0000_1111_1111_u32),
45 0b1111_1111_0000_0000_1111_1111_0000_0000_u32
46 );
47 }
48 }
49 }