def copy.shift

bend-kit-bytes@0.3.3.0 · bytes.bend:80

import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
import Base

80# m bytes to a word-aligned d from an unaligned s: each out word joins two source words.
81# lo = 8*(s%4) and hi = 32 - lo; r holds source word k, prev the word before it.
82def copy.shift(n: Nat, +lo: Nat, +hi: Nat, +prev: U32, r: Array<U32> & U32, dst: Array<U32>, +k: U32, +d: U32) -> Array<U32> & Array<U32>:
83  match n:
84    case 0n:
85      (a, w) = r
86      (a, dst)
87    case 1n+p:
88      (a, +w) = r
89      copy.shift(p, lo, hi, w, Array.get(U32, a, (k + 1 : U32)), Array.set(U32, dst, d, (U32.shrn(prev, lo) .|. U32.shln(w, hi) : U32)), (k + 1 : U32), (d + 1 : U32))

Uses (11)

Used by (1)