Debian Codegraph @

lib/mlrisc-lib/MLRISC/flowgraph/cfgPeephole.sml

raw
1 (*
2 * Run peephole optimization on a cluster
3 *)
4 functor CFGPeephole
5 (structure CFG : CONTROL_FLOW_GRAPH
6 structure PeepHole : PEEPHOLE (* sharing CFG.I = PeepHole.I *)
7 where type I.addressing_mode = CFG.I.addressing_mode
8 and type I.ea = CFG.I.ea
9 and type I.instr = CFG.I.instr
10 and type I.instruction = CFG.I.instruction
11 and type I.operand = CFG.I.operand
12 ) : CFG_OPTIMIZATION =
13 struct
14 structure CFG = CFG
15
16 val name = "Peephole optimization"
17
18 fun run (cfg as Graph.GRAPH graph) = let
19 fun opt (_, CFG.BLOCK{insns, ...}) = insns := PeepHole.peephole(rev(!insns))
20 in
21 #forall_nodes graph opt;
22 cfg
23 end
24
25 end