~/bend-docscommunity

table.bend checks

raw source on the hub · import bend-osdev-crc@0.1.0.0/table.bend as Table

bend-osdev-crc, the table-driven fast path: one table lookup per byte instead of eight bit steps (about 3x faster for CRC32C on native builds).

The bitwise engines in crc.bend are the reference; these must give the same results, which the vectors in LAWS.bend and ref/run.sh check (a law for every input is out of reach: it would need lemmas about Array's internals). The table is an Array, so it is built once per call and threaded through.

4 imports
import Base
import bend-osdev-word64@0.1.0.0/word64.bend as W
import bend-osdev-bytes@0.1.0.0/bytes.bend as B
import ./crc.bend as C

Definitions

def t32.fill.r source · line 16 · raw

@n:Nat -> @a:Array<U32> -> @+poly:U32 -> @+i:U32 -> Array<U32>

def t32.fill.n source · line 23 · raw

@n:Nat -> @a:Array<U32> -> @+poly:U32 -> @+shift:Nat -> @+topbit:U32 -> @+mask:U32 -> @+i:U32 -> Array<U32>

def t32.r.fin source · line 30 · raw

@r:Pair(Array<U32>, U32) -> @+c:U32 -> Pair(Array<U32>, U32)

def t32.r.raw source · line 35 · raw

@xs:List<&2, U32> -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, U32)

reflected: c = (c >> 8) ^ T[(c ^ b) & 255]

def t32.n.fin source · line 43 · raw

@r:Pair(Array<U32>, U32) -> @+c:U32 -> @+mask:U32 -> Pair(Array<U32>, U32)

def t32.n.raw source · line 48 · raw

@xs:List<&2, U32> -> @+shift:Nat -> @+mask:U32 -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, U32)

most significant bit first: c = ((c << 8) ^ T[((c >> (w - 8)) ^ b) & 255]) & mask

def t32.snd source · line 56 · raw

@r:Pair(Array<U32>, U32) -> U32

def t32.update.msb source · line 62 · raw

@small:Bool -> @+width:Nat -> @+poly:U32 -> @c:U32 -> @xs:List<&2, U32> -> U32

most significant bit first: a table for widths of 8 and up; below 8 the input goes in a bit at a time, so the bitwise engine serves

def t32.update.go source · line 72 · raw

@reflected:Bool -> @+width:Nat -> @+poly:U32 -> @c:U32 -> @xs:List<&2, U32> -> U32

def Crc32Spec.update_fast source · line 81 · raw

@spec:0x7a77d751f1a239b5a366af461ab7f041/crc.Crc32Spec -> @c:U32 -> @o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> U32

the same as Crc32Spec.update, table-driven

def Crc32Spec.compute_fast source · line 86 · raw

@+spec:0x7a77d751f1a239b5a366af461ab7f041/crc.Crc32Spec -> @o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> U32

def t64.fill.r source · line 91 · raw

@n:Nat -> @a:Array<0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64> -> @+poly:0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64 -> @+i:U32 -> Array<0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64>

def t64.fill.n source · line 98 · raw

@n:Nat -> @a:Array<0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64> -> @+poly:0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64 -> @+i:U32 -> Array<0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64>

def t64.r.fin source · line 105 · raw

@r:Pair(Array<0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64>, 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64) -> @+c:0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64 -> Pair(Array<0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64>, 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64)

def t64.r.raw source · line 109 · raw

@xs:List<&2, U32> -> @r:Pair(Array<0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64>, 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64) -> Pair(Array<0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64>, 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64)

def t64.n.fin source · line 117 · raw

@r:Pair(Array<0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64>, 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64) -> @+c:0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64 -> Pair(Array<0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64>, 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64)

def t64.n.raw source · line 121 · raw

@xs:List<&2, U32> -> @r:Pair(Array<0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64>, 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64) -> Pair(Array<0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64>, 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64)

def t64.snd source · line 129 · raw

@r:Pair(Array<0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64>, 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64) -> 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64

def t64.update.go source · line 133 · raw

@reflected:Bool -> @poly:0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64 -> @c:0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64 -> @xs:List<&2, U32> -> 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64

def Crc64Spec.update_fast source · line 140 · raw

@spec:0x7a77d751f1a239b5a366af461ab7f041/crc.Crc64Spec -> @c:0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64 -> @o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64

def Crc64Spec.compute_fast source · line 145 · raw

@+spec:0x7a77d751f1a239b5a366af461ab7f041/crc.Crc64Spec -> @o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64