v7.rs.html -- source
Description: Source to the Rust file `src/libcore/../stdsimd/coresimd/arm/v7.rs`.
Keywords: rust, rustlang, rust-lang

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89

    //! ARMv7 intrinsics.
    //!
    //! The reference is [ARMv7-M Architecture Reference Manual (Issue
    //! E.b)][armv7m].
    //!
    //! [armv7m]:
    //! http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0403e.
    //! b/index.html

    pub use super::v6::*;

    #[cfg(test)]
    use stdsimd_test::assert_instr;

    /// Count Leading Zeros.
    #[inline]
    #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
    #[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(clz))]
    // FIXME: https://github.com/rust-lang-nursery/stdsimd/issues/382
    // #[cfg_attr(all(test, target_arch = "arm"), assert_instr(clz))]
    pub unsafe fn _clz_u8(x: u8) -> u8 {
        x.leading_zeros() as u8
    }

    /// Count Leading Zeros.
    #[inline]
    #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
    #[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(clz))]
    // FIXME: https://github.com/rust-lang-nursery/stdsimd/issues/382
    // #[cfg_attr(all(test, target_arch = "arm"), assert_instr(clz))]
    pub unsafe fn _clz_u16(x: u16) -> u16 {
        x.leading_zeros() as u16
    }

    /// Count Leading Zeros.
    #[inline]
    #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
    #[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(clz))]
    // FIXME: https://github.com/rust-lang-nursery/stdsimd/issues/382
    // #[cfg_attr(all(test, target_arch = "arm"), assert_instr(clz))]
    pub unsafe fn _clz_u32(x: u32) -> u32 {
        x.leading_zeros() as u32
    }

    /// Reverse the bit order.
    #[inline]
    #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
    #[cfg_attr(test, assert_instr(rbit))]
    pub unsafe fn _rbit_u32(x: u32) -> u32 {
        use intrinsics::bitreverse;
        bitreverse(x)
    }

    #[cfg(test)]
    mod tests {
        use coresimd::arm::v7;

        #[test]
        fn _clz_u8() {
            unsafe {
                assert_eq!(v7::_clz_u8(0b0000_1010u8), 4u8);
            }
        }

        #[test]
        fn _clz_u16() {
            unsafe {
                assert_eq!(v7::_clz_u16(0b0000_1010u16), 12u16);
            }
        }

        #[test]
        fn _clz_u32() {
            unsafe {
                assert_eq!(v7::_clz_u32(0b0000_1010u32), 28u32);
            }
        }

        #[test]
        #[cfg(dont_compile_me)] // FIXME need to add `v7` upstream in rustc
        fn _rbit_u32() {
            unsafe {
                assert_eq!(
                    v7::_rbit_u32(0b0000_1010u32),
                    0b0101_0000_0000_0000_0000_0000_0000_0000u32
                );
            }
        }
    }

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)