[ new ] Implement bit-rotation operators (#2903)

* [ new ] Implement bit-rotation operators

Whereas `shiftR` and `shiftL` throw bits off the edge, the `rotR` and
`rotL` operations wrap the bits around to the start of the bit-stream.

* [ test ] visualise bit patterns instead

* [ fix ] print bit patterns the right way around

---------

Co-authored-by: Guillaume Allais <guillaume.allais@ens-lyon.org>
This commit is contained in:
CodingCellist 2023-03-04 15:41:54 +01:00 committed by GitHub
parent 24a69089bc
commit 7972c6acbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 624 additions and 5 deletions

View File

@ -110,6 +110,8 @@
`setInt32` (now takes an `Int32` instead of an `Int`),
`getInt32` (now returns an `Int32` instead of an `Int`)
* Adds left- and right-rotation for `FiniteBits`.
* Adds `Vect.permute` for applying permutations to `Vect`s.
* Adds `Vect.kSplits` and `Vect.nSplits` for splitting a `Vect` whose length is
a known multiple of two `Nat`s (k * n) into k vectors of length n (and

View File

@ -1,6 +1,7 @@
module Data.Bits
import public Data.Fin
import Data.Vect
%default total
@ -208,6 +209,24 @@ interface Bits a => FiniteBits a where
||| known as the population count or the Hamming weight.
popCount : a -> Nat
||| Rotate the argument right by the specified number of bits.
rotR : a -> Fin bitSize -> a
rotR x i =
(x `shiftR` (bitsToIndex i)) .|. (x `shiftL` (bitsToIndex $ finS (complement i)))
||| Rotate the argument left by the specified number of bits.
rotL : a -> Fin bitSize -> a
rotL x i =
(x `shiftL` (bitsToIndex i)) .|. (x `shiftR` (bitsToIndex $ finS (complement i)))
public export
asBitVector : FiniteBits a => a -> Vect (bitSize {a}) Bool
asBitVector v = testBit v . bitsToIndex <$> allFins _
public export
asString : FiniteBits a => a -> String
asString = pack . toList . map (\ b => ifThenElse b '1' '0') . reverse . asBitVector
public export %inline
FiniteBits Bits8 where
bitSize = 8
@ -282,6 +301,19 @@ FiniteBits Int where
x5 = if x < 0 then x4 + 1 else x4
in cast x5
-- Rotating signed integers is tricky because right-shifting a signed integer
-- inserts the signed bit rather than a 0-bit. We can work around this by
-- casting to (unsigned) Bits64, rotating, and casting back.
rotR x i =
let ux : Bits64
ux = cast x
in cast $ ux `rotR` i
rotL x i =
let ux : Bits64
ux = cast x
in cast $ ux `rotL` i
public export %inline
FiniteBits Int8 where
bitSize = 8
@ -300,6 +332,19 @@ FiniteBits Int8 where
x4 = if x < 0 then x3 + 1 else x3
in cast x4
-- Rotating signed integers is tricky because right-shifting a signed integer
-- inserts the signed bit rather than a 0-bit. We can work around this by
-- casting to (unsigned) Bits, rotating, and casting back.
rotR x i =
let ux : Bits8
ux = cast x
in cast $ ux `rotR` i
rotL x i =
let ux : Bits8
ux = cast x
in cast $ ux `rotL` i
public export %inline
FiniteBits Int16 where
bitSize = 16
@ -319,6 +364,19 @@ FiniteBits Int16 where
x5 = if x < 0 then x4 + 1 else x4
in cast x5
-- Rotating signed integers is tricky because right-shifting a signed integer
-- inserts the signed bit rather than a 0-bit. We can work around this by
-- casting to (unsigned) Bits, rotating, and casting back.
rotR x i =
let ux : Bits16
ux = cast x
in cast $ ux `rotR` i
rotL x i =
let ux : Bits16
ux = cast x
in cast $ ux `rotL` i
public export %inline
FiniteBits Int32 where
bitSize = 32
@ -338,6 +396,19 @@ FiniteBits Int32 where
x5 = if x < 0 then x4 + 1 else x4
in cast x5
-- Rotating signed integers is tricky because right-shifting a signed integer
-- inserts the signed bit rather than a 0-bit. We can work around this by
-- casting to (unsigned) Bits, rotating, and casting back.
rotR x i =
let ux : Bits32
ux = cast x
in cast $ ux `rotR` i
rotL x i =
let ux : Bits32
ux = cast x
in cast $ ux `rotL` i
public export %inline
FiniteBits Int64 where
bitSize = 64
@ -358,3 +429,16 @@ FiniteBits Int64 where
x4 = (x3 * 0x0101010101010101) `shiftR` 56
x5 = if x < 0 then x4 + 1 else x4
in cast x5
-- Rotating signed integers is tricky because right-shifting a signed integer
-- inserts the signed bit rather than a 0-bit. We can work around this by
-- casting to (unsigned) Bits, rotating, and casting back.
rotR x i =
let ux : Bits64
ux = cast x
in cast $ ux `rotR` i
rotL x i =
let ux : Bits64
ux = cast x
in cast $ ux `rotL` i

View File

@ -153,11 +153,22 @@ complement : {n : Nat} -> Fin n -> Fin n
complement {n = S _} FZ = last
complement {n = S _} (FS x) = weaken $ complement x
||| All of the Fin elements
public export
allFins : (n : Nat) -> List1 (Fin (S n))
allFins Z = FZ ::: []
allFins (S n) = FZ ::: map FS (forget (allFins n))
namespace List
||| All of the Fin elements
public export
allFins : (n : Nat) -> List (Fin n)
allFins Z = []
allFins (S n) = FZ :: map FS (allFins n)
namespace List1
||| All of the Fin elements
public export
allFins : (n : Nat) -> List1 (Fin (S n))
allFins Z = FZ ::: []
allFins (S n) = FZ ::: map FS (forget (allFins n))
export
Ord (Fin n) where

View File

@ -0,0 +1,100 @@
import Data.Bits
import Data.List
import Data.Stream
import Data.String
import Decidable.Equality
import Data.Fin
--------------------------------------------------------------------------------
-- Utilities
--------------------------------------------------------------------------------
shl1 : Int -> Int
shl1 = prim__shl_Int 1
b8max : Bits8
b8max = 0xff
b16max : Bits16
b16max = 0xffff
b32max : Bits32
b32max = 0xffffffff
b64max : Bits64
b64max = 18446744073709551615
-- the only way to create -2^63
intmin : Int
intmin = shl1 63
intmax : Int
intmax = 0x7fffffffffffffff
powsOf2 : Num a => Nat -> List a
powsOf2 n = take n (iterate (*2) 1)
experiment : FiniteBits a => String -> (a -> a) -> List a -> String
experiment name f vals
= unlines
$ replicate 72 '-'
:: "-- \{name}"
:: map (\ l => "\{asString l} \{asString (f l)}") vals
--------------------------------------------------------------------------------
-- rotR
--------------------------------------------------------------------------------
rotRBits8 : String
rotRBits8 = experiment "RotR Bits8" (`rotR` 1) (0 :: powsOf2 8 ++ [b8max])
rotRBits16 : String
rotRBits16 = experiment "RotR Bits16" (`rotR` 1) (0 :: powsOf2 16 ++ [b16max])
rotRBits32 : String
rotRBits32 = experiment "RotR Bits32" (`rotR` 1) (0 :: powsOf2 32 ++ [b32max])
rotRInt : String
rotRInt = experiment "RotR Int" (`rotR` 1) (0 :: powsOf2 63 ++ [intmax])
rotRNegativeInt : String
rotRNegativeInt = experiment "RotR negative Int" (`rotR` 1) (0 :: map negate (powsOf2 63) ++ [intmin])
--------------------------------------------------------------------------------
-- rotL
--------------------------------------------------------------------------------
rotLBits8 : String
rotLBits8 = experiment "RotL Bits8" (`rotL` 1) (0 :: powsOf2 8 ++ [b8max])
rotLBits16 : String
rotLBits16 = experiment "RotL Bits16" (`rotL` 1) (0 :: powsOf2 16 ++ [b16max])
rotLBits32 : String
rotLBits32 = experiment "RotL Bits32" (`rotL` 1) (0 :: powsOf2 32 ++ [b32max])
rotLInt : String
rotLInt = experiment "RotL Int" (`rotL` 1) (0 :: powsOf2 63 ++ [intmax])
rotLNegativeInt : String
rotLNegativeInt = experiment "RotL negative Int" (`rotL` 1) (0 :: map negate (powsOf2 62) ++ [intmin])
--------------------------------------------------------------------------------
-- Running Tests
--------------------------------------------------------------------------------
main : IO ()
main = do putStrLn rotRBits8
putStrLn rotRBits16
putStrLn rotRBits32
putStrLn rotRInt
putStrLn rotRNegativeInt
putStrLn ""
putStrLn rotLBits8
putStrLn rotLBits16
putStrLn rotLBits32
putStrLn rotLInt
putStrLn rotLNegativeInt

View File

@ -0,0 +1,416 @@
1/1: Building BitRotate (BitRotate.idr)
Main> ------------------------------------------------------------------------
-- RotR Bits8
00000000 00000000
00000001 10000000
00000010 00000001
00000100 00000010
00001000 00000100
00010000 00001000
00100000 00010000
01000000 00100000
10000000 01000000
11111111 11111111
------------------------------------------------------------------------
-- RotR Bits16
0000000000000000 0000000000000000
0000000000000001 1000000000000000
0000000000000010 0000000000000001
0000000000000100 0000000000000010
0000000000001000 0000000000000100
0000000000010000 0000000000001000
0000000000100000 0000000000010000
0000000001000000 0000000000100000
0000000010000000 0000000001000000
0000000100000000 0000000010000000
0000001000000000 0000000100000000
0000010000000000 0000001000000000
0000100000000000 0000010000000000
0001000000000000 0000100000000000
0010000000000000 0001000000000000
0100000000000000 0010000000000000
1000000000000000 0100000000000000
1111111111111111 1111111111111111
------------------------------------------------------------------------
-- RotR Bits32
00000000000000000000000000000000 00000000000000000000000000000000
00000000000000000000000000000001 10000000000000000000000000000000
00000000000000000000000000000010 00000000000000000000000000000001
00000000000000000000000000000100 00000000000000000000000000000010
00000000000000000000000000001000 00000000000000000000000000000100
00000000000000000000000000010000 00000000000000000000000000001000
00000000000000000000000000100000 00000000000000000000000000010000
00000000000000000000000001000000 00000000000000000000000000100000
00000000000000000000000010000000 00000000000000000000000001000000
00000000000000000000000100000000 00000000000000000000000010000000
00000000000000000000001000000000 00000000000000000000000100000000
00000000000000000000010000000000 00000000000000000000001000000000
00000000000000000000100000000000 00000000000000000000010000000000
00000000000000000001000000000000 00000000000000000000100000000000
00000000000000000010000000000000 00000000000000000001000000000000
00000000000000000100000000000000 00000000000000000010000000000000
00000000000000001000000000000000 00000000000000000100000000000000
00000000000000010000000000000000 00000000000000001000000000000000
00000000000000100000000000000000 00000000000000010000000000000000
00000000000001000000000000000000 00000000000000100000000000000000
00000000000010000000000000000000 00000000000001000000000000000000
00000000000100000000000000000000 00000000000010000000000000000000
00000000001000000000000000000000 00000000000100000000000000000000
00000000010000000000000000000000 00000000001000000000000000000000
00000000100000000000000000000000 00000000010000000000000000000000
00000001000000000000000000000000 00000000100000000000000000000000
00000010000000000000000000000000 00000001000000000000000000000000
00000100000000000000000000000000 00000010000000000000000000000000
00001000000000000000000000000000 00000100000000000000000000000000
00010000000000000000000000000000 00001000000000000000000000000000
00100000000000000000000000000000 00010000000000000000000000000000
01000000000000000000000000000000 00100000000000000000000000000000
10000000000000000000000000000000 01000000000000000000000000000000
11111111111111111111111111111111 11111111111111111111111111111111
------------------------------------------------------------------------
-- RotR Int
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000001 1000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000010 0000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000100 0000000000000000000000000000000000000000000000000000000000000010
0000000000000000000000000000000000000000000000000000000000001000 0000000000000000000000000000000000000000000000000000000000000100
0000000000000000000000000000000000000000000000000000000000010000 0000000000000000000000000000000000000000000000000000000000001000
0000000000000000000000000000000000000000000000000000000000100000 0000000000000000000000000000000000000000000000000000000000010000
0000000000000000000000000000000000000000000000000000000001000000 0000000000000000000000000000000000000000000000000000000000100000
0000000000000000000000000000000000000000000000000000000010000000 0000000000000000000000000000000000000000000000000000000001000000
0000000000000000000000000000000000000000000000000000000100000000 0000000000000000000000000000000000000000000000000000000010000000
0000000000000000000000000000000000000000000000000000001000000000 0000000000000000000000000000000000000000000000000000000100000000
0000000000000000000000000000000000000000000000000000010000000000 0000000000000000000000000000000000000000000000000000001000000000
0000000000000000000000000000000000000000000000000000100000000000 0000000000000000000000000000000000000000000000000000010000000000
0000000000000000000000000000000000000000000000000001000000000000 0000000000000000000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000010000000000000 0000000000000000000000000000000000000000000000000001000000000000
0000000000000000000000000000000000000000000000000100000000000000 0000000000000000000000000000000000000000000000000010000000000000
0000000000000000000000000000000000000000000000001000000000000000 0000000000000000000000000000000000000000000000000100000000000000
0000000000000000000000000000000000000000000000010000000000000000 0000000000000000000000000000000000000000000000001000000000000000
0000000000000000000000000000000000000000000000100000000000000000 0000000000000000000000000000000000000000000000010000000000000000
0000000000000000000000000000000000000000000001000000000000000000 0000000000000000000000000000000000000000000000100000000000000000
0000000000000000000000000000000000000000000010000000000000000000 0000000000000000000000000000000000000000000001000000000000000000
0000000000000000000000000000000000000000000100000000000000000000 0000000000000000000000000000000000000000000010000000000000000000
0000000000000000000000000000000000000000001000000000000000000000 0000000000000000000000000000000000000000000100000000000000000000
0000000000000000000000000000000000000000010000000000000000000000 0000000000000000000000000000000000000000001000000000000000000000
0000000000000000000000000000000000000000100000000000000000000000 0000000000000000000000000000000000000000010000000000000000000000
0000000000000000000000000000000000000001000000000000000000000000 0000000000000000000000000000000000000000100000000000000000000000
0000000000000000000000000000000000000010000000000000000000000000 0000000000000000000000000000000000000001000000000000000000000000
0000000000000000000000000000000000000100000000000000000000000000 0000000000000000000000000000000000000010000000000000000000000000
0000000000000000000000000000000000001000000000000000000000000000 0000000000000000000000000000000000000100000000000000000000000000
0000000000000000000000000000000000010000000000000000000000000000 0000000000000000000000000000000000001000000000000000000000000000
0000000000000000000000000000000000100000000000000000000000000000 0000000000000000000000000000000000010000000000000000000000000000
0000000000000000000000000000000001000000000000000000000000000000 0000000000000000000000000000000000100000000000000000000000000000
0000000000000000000000000000000010000000000000000000000000000000 0000000000000000000000000000000001000000000000000000000000000000
0000000000000000000000000000000100000000000000000000000000000000 0000000000000000000000000000000010000000000000000000000000000000
0000000000000000000000000000001000000000000000000000000000000000 0000000000000000000000000000000100000000000000000000000000000000
0000000000000000000000000000010000000000000000000000000000000000 0000000000000000000000000000001000000000000000000000000000000000
0000000000000000000000000000100000000000000000000000000000000000 0000000000000000000000000000010000000000000000000000000000000000
0000000000000000000000000001000000000000000000000000000000000000 0000000000000000000000000000100000000000000000000000000000000000
0000000000000000000000000010000000000000000000000000000000000000 0000000000000000000000000001000000000000000000000000000000000000
0000000000000000000000000100000000000000000000000000000000000000 0000000000000000000000000010000000000000000000000000000000000000
0000000000000000000000001000000000000000000000000000000000000000 0000000000000000000000000100000000000000000000000000000000000000
0000000000000000000000010000000000000000000000000000000000000000 0000000000000000000000001000000000000000000000000000000000000000
0000000000000000000000100000000000000000000000000000000000000000 0000000000000000000000010000000000000000000000000000000000000000
0000000000000000000001000000000000000000000000000000000000000000 0000000000000000000000100000000000000000000000000000000000000000
0000000000000000000010000000000000000000000000000000000000000000 0000000000000000000001000000000000000000000000000000000000000000
0000000000000000000100000000000000000000000000000000000000000000 0000000000000000000010000000000000000000000000000000000000000000
0000000000000000001000000000000000000000000000000000000000000000 0000000000000000000100000000000000000000000000000000000000000000
0000000000000000010000000000000000000000000000000000000000000000 0000000000000000001000000000000000000000000000000000000000000000
0000000000000000100000000000000000000000000000000000000000000000 0000000000000000010000000000000000000000000000000000000000000000
0000000000000001000000000000000000000000000000000000000000000000 0000000000000000100000000000000000000000000000000000000000000000
0000000000000010000000000000000000000000000000000000000000000000 0000000000000001000000000000000000000000000000000000000000000000
0000000000000100000000000000000000000000000000000000000000000000 0000000000000010000000000000000000000000000000000000000000000000
0000000000001000000000000000000000000000000000000000000000000000 0000000000000100000000000000000000000000000000000000000000000000
0000000000010000000000000000000000000000000000000000000000000000 0000000000001000000000000000000000000000000000000000000000000000
0000000000100000000000000000000000000000000000000000000000000000 0000000000010000000000000000000000000000000000000000000000000000
0000000001000000000000000000000000000000000000000000000000000000 0000000000100000000000000000000000000000000000000000000000000000
0000000010000000000000000000000000000000000000000000000000000000 0000000001000000000000000000000000000000000000000000000000000000
0000000100000000000000000000000000000000000000000000000000000000 0000000010000000000000000000000000000000000000000000000000000000
0000001000000000000000000000000000000000000000000000000000000000 0000000100000000000000000000000000000000000000000000000000000000
0000010000000000000000000000000000000000000000000000000000000000 0000001000000000000000000000000000000000000000000000000000000000
0000100000000000000000000000000000000000000000000000000000000000 0000010000000000000000000000000000000000000000000000000000000000
0001000000000000000000000000000000000000000000000000000000000000 0000100000000000000000000000000000000000000000000000000000000000
0010000000000000000000000000000000000000000000000000000000000000 0001000000000000000000000000000000000000000000000000000000000000
0100000000000000000000000000000000000000000000000000000000000000 0010000000000000000000000000000000000000000000000000000000000000
0111111111111111111111111111111111111111111111111111111111111111 1011111111111111111111111111111111111111111111111111111111111111
------------------------------------------------------------------------
-- RotR negative Int
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000
1111111111111111111111111111111111111111111111111111111111111111 1111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111110 0111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111100 0111111111111111111111111111111111111111111111111111111111111110
1111111111111111111111111111111111111111111111111111111111111000 0111111111111111111111111111111111111111111111111111111111111100
1111111111111111111111111111111111111111111111111111111111110000 0111111111111111111111111111111111111111111111111111111111111000
1111111111111111111111111111111111111111111111111111111111100000 0111111111111111111111111111111111111111111111111111111111110000
1111111111111111111111111111111111111111111111111111111111000000 0111111111111111111111111111111111111111111111111111111111100000
1111111111111111111111111111111111111111111111111111111110000000 0111111111111111111111111111111111111111111111111111111111000000
1111111111111111111111111111111111111111111111111111111100000000 0111111111111111111111111111111111111111111111111111111110000000
1111111111111111111111111111111111111111111111111111111000000000 0111111111111111111111111111111111111111111111111111111100000000
1111111111111111111111111111111111111111111111111111110000000000 0111111111111111111111111111111111111111111111111111111000000000
1111111111111111111111111111111111111111111111111111100000000000 0111111111111111111111111111111111111111111111111111110000000000
1111111111111111111111111111111111111111111111111111000000000000 0111111111111111111111111111111111111111111111111111100000000000
1111111111111111111111111111111111111111111111111110000000000000 0111111111111111111111111111111111111111111111111111000000000000
1111111111111111111111111111111111111111111111111100000000000000 0111111111111111111111111111111111111111111111111110000000000000
1111111111111111111111111111111111111111111111111000000000000000 0111111111111111111111111111111111111111111111111100000000000000
1111111111111111111111111111111111111111111111110000000000000000 0111111111111111111111111111111111111111111111111000000000000000
1111111111111111111111111111111111111111111111100000000000000000 0111111111111111111111111111111111111111111111110000000000000000
1111111111111111111111111111111111111111111111000000000000000000 0111111111111111111111111111111111111111111111100000000000000000
1111111111111111111111111111111111111111111110000000000000000000 0111111111111111111111111111111111111111111111000000000000000000
1111111111111111111111111111111111111111111100000000000000000000 0111111111111111111111111111111111111111111110000000000000000000
1111111111111111111111111111111111111111111000000000000000000000 0111111111111111111111111111111111111111111100000000000000000000
1111111111111111111111111111111111111111110000000000000000000000 0111111111111111111111111111111111111111111000000000000000000000
1111111111111111111111111111111111111111100000000000000000000000 0111111111111111111111111111111111111111110000000000000000000000
1111111111111111111111111111111111111111000000000000000000000000 0111111111111111111111111111111111111111100000000000000000000000
1111111111111111111111111111111111111110000000000000000000000000 0111111111111111111111111111111111111111000000000000000000000000
1111111111111111111111111111111111111100000000000000000000000000 0111111111111111111111111111111111111110000000000000000000000000
1111111111111111111111111111111111111000000000000000000000000000 0111111111111111111111111111111111111100000000000000000000000000
1111111111111111111111111111111111110000000000000000000000000000 0111111111111111111111111111111111111000000000000000000000000000
1111111111111111111111111111111111100000000000000000000000000000 0111111111111111111111111111111111110000000000000000000000000000
1111111111111111111111111111111111000000000000000000000000000000 0111111111111111111111111111111111100000000000000000000000000000
1111111111111111111111111111111110000000000000000000000000000000 0111111111111111111111111111111111000000000000000000000000000000
1111111111111111111111111111111100000000000000000000000000000000 0111111111111111111111111111111110000000000000000000000000000000
1111111111111111111111111111111000000000000000000000000000000000 0111111111111111111111111111111100000000000000000000000000000000
1111111111111111111111111111110000000000000000000000000000000000 0111111111111111111111111111111000000000000000000000000000000000
1111111111111111111111111111100000000000000000000000000000000000 0111111111111111111111111111110000000000000000000000000000000000
1111111111111111111111111111000000000000000000000000000000000000 0111111111111111111111111111100000000000000000000000000000000000
1111111111111111111111111110000000000000000000000000000000000000 0111111111111111111111111111000000000000000000000000000000000000
1111111111111111111111111100000000000000000000000000000000000000 0111111111111111111111111110000000000000000000000000000000000000
1111111111111111111111111000000000000000000000000000000000000000 0111111111111111111111111100000000000000000000000000000000000000
1111111111111111111111110000000000000000000000000000000000000000 0111111111111111111111111000000000000000000000000000000000000000
1111111111111111111111100000000000000000000000000000000000000000 0111111111111111111111110000000000000000000000000000000000000000
1111111111111111111111000000000000000000000000000000000000000000 0111111111111111111111100000000000000000000000000000000000000000
1111111111111111111110000000000000000000000000000000000000000000 0111111111111111111111000000000000000000000000000000000000000000
1111111111111111111100000000000000000000000000000000000000000000 0111111111111111111110000000000000000000000000000000000000000000
1111111111111111111000000000000000000000000000000000000000000000 0111111111111111111100000000000000000000000000000000000000000000
1111111111111111110000000000000000000000000000000000000000000000 0111111111111111111000000000000000000000000000000000000000000000
1111111111111111100000000000000000000000000000000000000000000000 0111111111111111110000000000000000000000000000000000000000000000
1111111111111111000000000000000000000000000000000000000000000000 0111111111111111100000000000000000000000000000000000000000000000
1111111111111110000000000000000000000000000000000000000000000000 0111111111111111000000000000000000000000000000000000000000000000
1111111111111100000000000000000000000000000000000000000000000000 0111111111111110000000000000000000000000000000000000000000000000
1111111111111000000000000000000000000000000000000000000000000000 0111111111111100000000000000000000000000000000000000000000000000
1111111111110000000000000000000000000000000000000000000000000000 0111111111111000000000000000000000000000000000000000000000000000
1111111111100000000000000000000000000000000000000000000000000000 0111111111110000000000000000000000000000000000000000000000000000
1111111111000000000000000000000000000000000000000000000000000000 0111111111100000000000000000000000000000000000000000000000000000
1111111110000000000000000000000000000000000000000000000000000000 0111111111000000000000000000000000000000000000000000000000000000
1111111100000000000000000000000000000000000000000000000000000000 0111111110000000000000000000000000000000000000000000000000000000
1111111000000000000000000000000000000000000000000000000000000000 0111111100000000000000000000000000000000000000000000000000000000
1111110000000000000000000000000000000000000000000000000000000000 0111111000000000000000000000000000000000000000000000000000000000
1111100000000000000000000000000000000000000000000000000000000000 0111110000000000000000000000000000000000000000000000000000000000
1111000000000000000000000000000000000000000000000000000000000000 0111100000000000000000000000000000000000000000000000000000000000
1110000000000000000000000000000000000000000000000000000000000000 0111000000000000000000000000000000000000000000000000000000000000
1100000000000000000000000000000000000000000000000000000000000000 0110000000000000000000000000000000000000000000000000000000000000
1000000000000000000000000000000000000000000000000000000000000000 0100000000000000000000000000000000000000000000000000000000000000
------------------------------------------------------------------------
-- RotL Bits8
00000000 00000000
00000001 00000010
00000010 00000100
00000100 00001000
00001000 00010000
00010000 00100000
00100000 01000000
01000000 10000000
10000000 00000001
11111111 11111111
------------------------------------------------------------------------
-- RotL Bits16
0000000000000000 0000000000000000
0000000000000001 0000000000000010
0000000000000010 0000000000000100
0000000000000100 0000000000001000
0000000000001000 0000000000010000
0000000000010000 0000000000100000
0000000000100000 0000000001000000
0000000001000000 0000000010000000
0000000010000000 0000000100000000
0000000100000000 0000001000000000
0000001000000000 0000010000000000
0000010000000000 0000100000000000
0000100000000000 0001000000000000
0001000000000000 0010000000000000
0010000000000000 0100000000000000
0100000000000000 1000000000000000
1000000000000000 0000000000000001
1111111111111111 1111111111111111
------------------------------------------------------------------------
-- RotL Bits32
00000000000000000000000000000000 00000000000000000000000000000000
00000000000000000000000000000001 00000000000000000000000000000010
00000000000000000000000000000010 00000000000000000000000000000100
00000000000000000000000000000100 00000000000000000000000000001000
00000000000000000000000000001000 00000000000000000000000000010000
00000000000000000000000000010000 00000000000000000000000000100000
00000000000000000000000000100000 00000000000000000000000001000000
00000000000000000000000001000000 00000000000000000000000010000000
00000000000000000000000010000000 00000000000000000000000100000000
00000000000000000000000100000000 00000000000000000000001000000000
00000000000000000000001000000000 00000000000000000000010000000000
00000000000000000000010000000000 00000000000000000000100000000000
00000000000000000000100000000000 00000000000000000001000000000000
00000000000000000001000000000000 00000000000000000010000000000000
00000000000000000010000000000000 00000000000000000100000000000000
00000000000000000100000000000000 00000000000000001000000000000000
00000000000000001000000000000000 00000000000000010000000000000000
00000000000000010000000000000000 00000000000000100000000000000000
00000000000000100000000000000000 00000000000001000000000000000000
00000000000001000000000000000000 00000000000010000000000000000000
00000000000010000000000000000000 00000000000100000000000000000000
00000000000100000000000000000000 00000000001000000000000000000000
00000000001000000000000000000000 00000000010000000000000000000000
00000000010000000000000000000000 00000000100000000000000000000000
00000000100000000000000000000000 00000001000000000000000000000000
00000001000000000000000000000000 00000010000000000000000000000000
00000010000000000000000000000000 00000100000000000000000000000000
00000100000000000000000000000000 00001000000000000000000000000000
00001000000000000000000000000000 00010000000000000000000000000000
00010000000000000000000000000000 00100000000000000000000000000000
00100000000000000000000000000000 01000000000000000000000000000000
01000000000000000000000000000000 10000000000000000000000000000000
10000000000000000000000000000000 00000000000000000000000000000001
11111111111111111111111111111111 11111111111111111111111111111111
------------------------------------------------------------------------
-- RotL Int
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000001 0000000000000000000000000000000000000000000000000000000000000010
0000000000000000000000000000000000000000000000000000000000000010 0000000000000000000000000000000000000000000000000000000000000100
0000000000000000000000000000000000000000000000000000000000000100 0000000000000000000000000000000000000000000000000000000000001000
0000000000000000000000000000000000000000000000000000000000001000 0000000000000000000000000000000000000000000000000000000000010000
0000000000000000000000000000000000000000000000000000000000010000 0000000000000000000000000000000000000000000000000000000000100000
0000000000000000000000000000000000000000000000000000000000100000 0000000000000000000000000000000000000000000000000000000001000000
0000000000000000000000000000000000000000000000000000000001000000 0000000000000000000000000000000000000000000000000000000010000000
0000000000000000000000000000000000000000000000000000000010000000 0000000000000000000000000000000000000000000000000000000100000000
0000000000000000000000000000000000000000000000000000000100000000 0000000000000000000000000000000000000000000000000000001000000000
0000000000000000000000000000000000000000000000000000001000000000 0000000000000000000000000000000000000000000000000000010000000000
0000000000000000000000000000000000000000000000000000010000000000 0000000000000000000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000000100000000000 0000000000000000000000000000000000000000000000000001000000000000
0000000000000000000000000000000000000000000000000001000000000000 0000000000000000000000000000000000000000000000000010000000000000
0000000000000000000000000000000000000000000000000010000000000000 0000000000000000000000000000000000000000000000000100000000000000
0000000000000000000000000000000000000000000000000100000000000000 0000000000000000000000000000000000000000000000001000000000000000
0000000000000000000000000000000000000000000000001000000000000000 0000000000000000000000000000000000000000000000010000000000000000
0000000000000000000000000000000000000000000000010000000000000000 0000000000000000000000000000000000000000000000100000000000000000
0000000000000000000000000000000000000000000000100000000000000000 0000000000000000000000000000000000000000000001000000000000000000
0000000000000000000000000000000000000000000001000000000000000000 0000000000000000000000000000000000000000000010000000000000000000
0000000000000000000000000000000000000000000010000000000000000000 0000000000000000000000000000000000000000000100000000000000000000
0000000000000000000000000000000000000000000100000000000000000000 0000000000000000000000000000000000000000001000000000000000000000
0000000000000000000000000000000000000000001000000000000000000000 0000000000000000000000000000000000000000010000000000000000000000
0000000000000000000000000000000000000000010000000000000000000000 0000000000000000000000000000000000000000100000000000000000000000
0000000000000000000000000000000000000000100000000000000000000000 0000000000000000000000000000000000000001000000000000000000000000
0000000000000000000000000000000000000001000000000000000000000000 0000000000000000000000000000000000000010000000000000000000000000
0000000000000000000000000000000000000010000000000000000000000000 0000000000000000000000000000000000000100000000000000000000000000
0000000000000000000000000000000000000100000000000000000000000000 0000000000000000000000000000000000001000000000000000000000000000
0000000000000000000000000000000000001000000000000000000000000000 0000000000000000000000000000000000010000000000000000000000000000
0000000000000000000000000000000000010000000000000000000000000000 0000000000000000000000000000000000100000000000000000000000000000
0000000000000000000000000000000000100000000000000000000000000000 0000000000000000000000000000000001000000000000000000000000000000
0000000000000000000000000000000001000000000000000000000000000000 0000000000000000000000000000000010000000000000000000000000000000
0000000000000000000000000000000010000000000000000000000000000000 0000000000000000000000000000000100000000000000000000000000000000
0000000000000000000000000000000100000000000000000000000000000000 0000000000000000000000000000001000000000000000000000000000000000
0000000000000000000000000000001000000000000000000000000000000000 0000000000000000000000000000010000000000000000000000000000000000
0000000000000000000000000000010000000000000000000000000000000000 0000000000000000000000000000100000000000000000000000000000000000
0000000000000000000000000000100000000000000000000000000000000000 0000000000000000000000000001000000000000000000000000000000000000
0000000000000000000000000001000000000000000000000000000000000000 0000000000000000000000000010000000000000000000000000000000000000
0000000000000000000000000010000000000000000000000000000000000000 0000000000000000000000000100000000000000000000000000000000000000
0000000000000000000000000100000000000000000000000000000000000000 0000000000000000000000001000000000000000000000000000000000000000
0000000000000000000000001000000000000000000000000000000000000000 0000000000000000000000010000000000000000000000000000000000000000
0000000000000000000000010000000000000000000000000000000000000000 0000000000000000000000100000000000000000000000000000000000000000
0000000000000000000000100000000000000000000000000000000000000000 0000000000000000000001000000000000000000000000000000000000000000
0000000000000000000001000000000000000000000000000000000000000000 0000000000000000000010000000000000000000000000000000000000000000
0000000000000000000010000000000000000000000000000000000000000000 0000000000000000000100000000000000000000000000000000000000000000
0000000000000000000100000000000000000000000000000000000000000000 0000000000000000001000000000000000000000000000000000000000000000
0000000000000000001000000000000000000000000000000000000000000000 0000000000000000010000000000000000000000000000000000000000000000
0000000000000000010000000000000000000000000000000000000000000000 0000000000000000100000000000000000000000000000000000000000000000
0000000000000000100000000000000000000000000000000000000000000000 0000000000000001000000000000000000000000000000000000000000000000
0000000000000001000000000000000000000000000000000000000000000000 0000000000000010000000000000000000000000000000000000000000000000
0000000000000010000000000000000000000000000000000000000000000000 0000000000000100000000000000000000000000000000000000000000000000
0000000000000100000000000000000000000000000000000000000000000000 0000000000001000000000000000000000000000000000000000000000000000
0000000000001000000000000000000000000000000000000000000000000000 0000000000010000000000000000000000000000000000000000000000000000
0000000000010000000000000000000000000000000000000000000000000000 0000000000100000000000000000000000000000000000000000000000000000
0000000000100000000000000000000000000000000000000000000000000000 0000000001000000000000000000000000000000000000000000000000000000
0000000001000000000000000000000000000000000000000000000000000000 0000000010000000000000000000000000000000000000000000000000000000
0000000010000000000000000000000000000000000000000000000000000000 0000000100000000000000000000000000000000000000000000000000000000
0000000100000000000000000000000000000000000000000000000000000000 0000001000000000000000000000000000000000000000000000000000000000
0000001000000000000000000000000000000000000000000000000000000000 0000010000000000000000000000000000000000000000000000000000000000
0000010000000000000000000000000000000000000000000000000000000000 0000100000000000000000000000000000000000000000000000000000000000
0000100000000000000000000000000000000000000000000000000000000000 0001000000000000000000000000000000000000000000000000000000000000
0001000000000000000000000000000000000000000000000000000000000000 0010000000000000000000000000000000000000000000000000000000000000
0010000000000000000000000000000000000000000000000000000000000000 0100000000000000000000000000000000000000000000000000000000000000
0100000000000000000000000000000000000000000000000000000000000000 1000000000000000000000000000000000000000000000000000000000000000
0111111111111111111111111111111111111111111111111111111111111111 1111111111111111111111111111111111111111111111111111111111111110
------------------------------------------------------------------------
-- RotL negative Int
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000
1111111111111111111111111111111111111111111111111111111111111111 1111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111110 1111111111111111111111111111111111111111111111111111111111111101
1111111111111111111111111111111111111111111111111111111111111100 1111111111111111111111111111111111111111111111111111111111111001
1111111111111111111111111111111111111111111111111111111111111000 1111111111111111111111111111111111111111111111111111111111110001
1111111111111111111111111111111111111111111111111111111111110000 1111111111111111111111111111111111111111111111111111111111100001
1111111111111111111111111111111111111111111111111111111111100000 1111111111111111111111111111111111111111111111111111111111000001
1111111111111111111111111111111111111111111111111111111111000000 1111111111111111111111111111111111111111111111111111111110000001
1111111111111111111111111111111111111111111111111111111110000000 1111111111111111111111111111111111111111111111111111111100000001
1111111111111111111111111111111111111111111111111111111100000000 1111111111111111111111111111111111111111111111111111111000000001
1111111111111111111111111111111111111111111111111111111000000000 1111111111111111111111111111111111111111111111111111110000000001
1111111111111111111111111111111111111111111111111111110000000000 1111111111111111111111111111111111111111111111111111100000000001
1111111111111111111111111111111111111111111111111111100000000000 1111111111111111111111111111111111111111111111111111000000000001
1111111111111111111111111111111111111111111111111111000000000000 1111111111111111111111111111111111111111111111111110000000000001
1111111111111111111111111111111111111111111111111110000000000000 1111111111111111111111111111111111111111111111111100000000000001
1111111111111111111111111111111111111111111111111100000000000000 1111111111111111111111111111111111111111111111111000000000000001
1111111111111111111111111111111111111111111111111000000000000000 1111111111111111111111111111111111111111111111110000000000000001
1111111111111111111111111111111111111111111111110000000000000000 1111111111111111111111111111111111111111111111100000000000000001
1111111111111111111111111111111111111111111111100000000000000000 1111111111111111111111111111111111111111111111000000000000000001
1111111111111111111111111111111111111111111111000000000000000000 1111111111111111111111111111111111111111111110000000000000000001
1111111111111111111111111111111111111111111110000000000000000000 1111111111111111111111111111111111111111111100000000000000000001
1111111111111111111111111111111111111111111100000000000000000000 1111111111111111111111111111111111111111111000000000000000000001
1111111111111111111111111111111111111111111000000000000000000000 1111111111111111111111111111111111111111110000000000000000000001
1111111111111111111111111111111111111111110000000000000000000000 1111111111111111111111111111111111111111100000000000000000000001
1111111111111111111111111111111111111111100000000000000000000000 1111111111111111111111111111111111111111000000000000000000000001
1111111111111111111111111111111111111111000000000000000000000000 1111111111111111111111111111111111111110000000000000000000000001
1111111111111111111111111111111111111110000000000000000000000000 1111111111111111111111111111111111111100000000000000000000000001
1111111111111111111111111111111111111100000000000000000000000000 1111111111111111111111111111111111111000000000000000000000000001
1111111111111111111111111111111111111000000000000000000000000000 1111111111111111111111111111111111110000000000000000000000000001
1111111111111111111111111111111111110000000000000000000000000000 1111111111111111111111111111111111100000000000000000000000000001
1111111111111111111111111111111111100000000000000000000000000000 1111111111111111111111111111111111000000000000000000000000000001
1111111111111111111111111111111111000000000000000000000000000000 1111111111111111111111111111111110000000000000000000000000000001
1111111111111111111111111111111110000000000000000000000000000000 1111111111111111111111111111111100000000000000000000000000000001
1111111111111111111111111111111100000000000000000000000000000000 1111111111111111111111111111111000000000000000000000000000000001
1111111111111111111111111111111000000000000000000000000000000000 1111111111111111111111111111110000000000000000000000000000000001
1111111111111111111111111111110000000000000000000000000000000000 1111111111111111111111111111100000000000000000000000000000000001
1111111111111111111111111111100000000000000000000000000000000000 1111111111111111111111111111000000000000000000000000000000000001
1111111111111111111111111111000000000000000000000000000000000000 1111111111111111111111111110000000000000000000000000000000000001
1111111111111111111111111110000000000000000000000000000000000000 1111111111111111111111111100000000000000000000000000000000000001
1111111111111111111111111100000000000000000000000000000000000000 1111111111111111111111111000000000000000000000000000000000000001
1111111111111111111111111000000000000000000000000000000000000000 1111111111111111111111110000000000000000000000000000000000000001
1111111111111111111111110000000000000000000000000000000000000000 1111111111111111111111100000000000000000000000000000000000000001
1111111111111111111111100000000000000000000000000000000000000000 1111111111111111111111000000000000000000000000000000000000000001
1111111111111111111111000000000000000000000000000000000000000000 1111111111111111111110000000000000000000000000000000000000000001
1111111111111111111110000000000000000000000000000000000000000000 1111111111111111111100000000000000000000000000000000000000000001
1111111111111111111100000000000000000000000000000000000000000000 1111111111111111111000000000000000000000000000000000000000000001
1111111111111111111000000000000000000000000000000000000000000000 1111111111111111110000000000000000000000000000000000000000000001
1111111111111111110000000000000000000000000000000000000000000000 1111111111111111100000000000000000000000000000000000000000000001
1111111111111111100000000000000000000000000000000000000000000000 1111111111111111000000000000000000000000000000000000000000000001
1111111111111111000000000000000000000000000000000000000000000000 1111111111111110000000000000000000000000000000000000000000000001
1111111111111110000000000000000000000000000000000000000000000000 1111111111111100000000000000000000000000000000000000000000000001
1111111111111100000000000000000000000000000000000000000000000000 1111111111111000000000000000000000000000000000000000000000000001
1111111111111000000000000000000000000000000000000000000000000000 1111111111110000000000000000000000000000000000000000000000000001
1111111111110000000000000000000000000000000000000000000000000000 1111111111100000000000000000000000000000000000000000000000000001
1111111111100000000000000000000000000000000000000000000000000000 1111111111000000000000000000000000000000000000000000000000000001
1111111111000000000000000000000000000000000000000000000000000000 1111111110000000000000000000000000000000000000000000000000000001
1111111110000000000000000000000000000000000000000000000000000000 1111111100000000000000000000000000000000000000000000000000000001
1111111100000000000000000000000000000000000000000000000000000000 1111111000000000000000000000000000000000000000000000000000000001
1111111000000000000000000000000000000000000000000000000000000000 1111110000000000000000000000000000000000000000000000000000000001
1111110000000000000000000000000000000000000000000000000000000000 1111100000000000000000000000000000000000000000000000000000000001
1111100000000000000000000000000000000000000000000000000000000000 1111000000000000000000000000000000000000000000000000000000000001
1111000000000000000000000000000000000000000000000000000000000000 1110000000000000000000000000000000000000000000000000000000000001
1110000000000000000000000000000000000000000000000000000000000000 1100000000000000000000000000000000000000000000000000000000000001
1000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000001
Main> Bye for now!

View File

@ -0,0 +1,2 @@
:exec main
:q

4
tests/base/data_bits002/run Executable file
View File

@ -0,0 +1,4 @@
rm -rf build
$1 --no-banner --no-color --console-width 0 BitRotate.idr < input