Copying disjoint arrays on the word RAM #
The seven-register copy routine charges every address calculation, load, store, increment, and loop test. Its source precedes its destination, as in a bump-allocated growing array. It is a fixed program: neither the length nor either address is baked into the code.
Main definitions #
Cslib.WordRAM.ArrayCopy.program: copying between addresses supplied in registers.Cslib.WordRAM.ArrayCopy.copyPrefix: mathematical specification of the writes.
Main results #
Cslib.WordRAM.ArrayCopy.exec: copyingnwords within7 * n + 4instructions, preserving the source and all cells outside the destination.
References #
@[simp]
theorem Cslib.WordRAM.ArrayCopy.copyPrefix_succ (mem : ℕ → ℕ) (src dst k : ℕ) :
copyPrefix mem src dst (k + 1) = Function.update (copyPrefix mem src dst k) (dst + k) (mem (src + k))
@[reducible, inline]
Source base, destination base, length, index, temporary address, value, and one.
Instances For
Five data instructions per copied word.
Instances For
A fixed copying program with all three parameters in registers.
Instances For
theorem Cslib.WordRAM.ArrayCopy.exec {w : ℕ} (x : Data 7) (h1 : Fits w 1) (hs : Fits w (x.regs src + x.regs len)) (hd : Fits w (x.regs dst + x.regs len)) (hdisj : x.regs src + x.regs len ≤ x.regs dst) :
Low-level structured copying charges register setup and all loop instructions, excluding
the final halt. The one-past-end addresses must fit a word. Boundedness of the input memory and
registers is a separate premise when using ExecWithin.bounded to obtain bounded-word execution.