The first step towards optimization is to take statistics.
We will count: [[instrs]], Mips words, [[NOP]]s in load and branch delays,
and [[bltzal]]s.
In the current implementation the [[bltzal]]s are implicit, so there
is no way to count them or optimize them.
«statistics»=
fun printstats stream
inst : int, code : int, data : int,
load : int, branch : int, compare : int, size : int =
let val print = output stream
val nop = load+branch+compare
val bltzal = size - (code + data)
val code = code + bltzal
«definition of [[sprintf]]»
fun P x = substring(makestring(100.0 * x),0,4) (* percent *)
fun printf f d = print (sprintf f d)
in printf ["Counted "," instrs in "," words (",
" code, "," data)" ^
"Used "," NOPs ("," load, "," branch,"," compare) and "," bltzals" ^
"","