A swift package providing bitwise rotation operators for FixedWidthInteger
and SIMD
vectors with a FixedWidthInteger
scalar.
This package is written in a sepcific way to compile to ror
and rol
on x86. On ARM only UInt32
, UInt64
, Int32
and Int64
compile to ror
. Rotations on SIMD
vectors don't yet compile to the most efficient instructions possible.
In your Package.swift add:
.package(url: "https://github.com/tgymnich/BitwiseRotate.git", from: "1.1.1")
let someBits: UInt8 = 0b01010100 <<< 3 // returns 0b10100010
let someBits: UInt8 = 0b01010100 >>> 3 // returns 0b10001010
let someBitVector = SIMD3<UInt8>(arrayLiteral: 0b01010100,0b11011100,0b00011000) <<< 1 // (0b10101000, 0b10111001, 0b00110000)