-(* peephole optimizer
- * Gathers tiberium, fires rockets
+(* L2 compiler
+ * peephole optimizer
* optimizes away redundant insns such as:
mov a, b
mov a, b
neg a
neg a
- * Author: Chris Lu <czl@andrew>
+ * Author: Chris Lu <czl@andrew.cmu.edu>
*)
signature PEEPHOLE =
sig
- type tiberium = x86.insn list
- type rockets = x86.insn list
- val peephole : tiberium -> rockets
+ val peephole : x86.insn list -> x86.insn list
end
structure Peephole :> PEEPHOLE =
struct
- type tiberium = x86.insn list
- type rockets = x86.insn list
structure X = x86
- (* val peephole : tiberium -> rockets *)
+ (* val peephole : x86.insn list -> x86.insn list *)
fun peephole ((insn1 as X.MOVL(a1,b1))::(insn2 as X.MOVL(a2,b2))::l) =
if(x86.opereq(a1, b1) orelse (x86.opereq(a1, a2) andalso x86.opereq(b1, b2))) then