Charged in-place normalization of an array #
ArrayNormalize.program replaces each word of a supplied interval by its remainder modulo a
supplied positive modulus. It executes actual loads, remainders and stores; the untouched
memory need not already be normalized. This small topic module avoids adding an application
specific transformation to the allocation API.
@[reducible, inline]
First address to normalize.
@[reducible, inline]
Positive normalization modulus.
@[reducible, inline]
Temporary absolute address.
@[reducible, inline]
Loaded and normalized word.
Normalize one cell with five actual native instructions.
Fixed code for in-place normalization of an interval supplied in registers.
theorem Cslib.WordRAM.ArrayNormalize.exec {W b M n : ℕ} (x : Data 7) (hb : x.regs base = b) (hn : x.regs length = n) (hm : x.regs modulus = M) (hM : 0 < M) (hfit : Fits W (b + n + M + 2)) :
In-place normalization costs at most 7n+4 native instructions, including every indexed
load/store and loop decision. The input arguments and all outside memory are preserved.