4 IRPROG of (Tree.program -> Tree.program) |
5 IRFUNC of (Tree.func -> Tree.func) |
6 IRSTM of (Tree.stm -> Tree.stm list) |
7 IREXP of (Tree.exp -> Tree.exp) |
8 PRELIVENESS of (Blarg.insn list -> Blarg.insn list) |
9 FINAL of (Blarg.insn list -> Blarg.insn list)
17 val optimize_ir : optimization list -> Tree.program -> Tree.program
18 val optimize_preliveness : optimization list -> Blarg.insn list -> Blarg.insn list
19 val optimize_final : optimization list -> Blarg.insn list -> Blarg.insn list
22 structure Optimizer :> OPTIMIZER =
27 IRPROG of (Tree.program -> Tree.program) |
28 IRFUNC of (Tree.func -> Tree.func) |
29 IRSTM of (Tree.stm -> Tree.stm list) |
30 IREXP of (Tree.exp -> Tree.exp) |
31 PRELIVENESS of (Blarg.insn list -> Blarg.insn list) |
32 FINAL of (Blarg.insn list -> Blarg.insn list)
40 fun foldfunc f (T.FUNCTION (id, stml)) = T.FUNCTION (id, List.concat (List.map f stml))
41 fun expfunc f (T.MOVE (e1, e2)) = [T.MOVE (f e1, f e2)]
42 | expfunc f (T.RETURN (e, s)) = [T.RETURN (f e, s)]
43 | expfunc f (T.EFFECT e) = [T.EFFECT (f e)]
44 | expfunc f (a as T.LABEL _) = [a]
45 | expfunc f (T.JUMPIFN (e, l)) = [T.JUMPIFN (f e, l)]
46 | expfunc f (a as T.JUMP _) = [a]
48 fun optimize_ir ol prog =
50 fn (IRPROG f, prog) => f prog
51 | (IRFUNC f, prog) => List.map f prog
52 | (IRSTM f, prog) => List.map (foldfunc (f)) prog
53 | (IREXP f, prog) => List.map (foldfunc (expfunc f)) prog
56 (map (fn (x : optimization) => #func x) ol)
58 fun optimize_preliveness ol assem =
60 fn (PRELIVENESS f, assem) => f assem
61 | (_, assem) => assem)
63 (map (fn (x : optimization) => #func x) ol)
65 fun optimize_final ol assem =
67 fn (FINAL f, assem) => f assem
68 | (_, assem) => assem)
70 (map (fn (x : optimization) => #func x) ol)
73 signature OPTIMIZATION =
75 val optimizer : Optimizer.optimization