1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: namespaces assocs biassocs classes kernel math accessors
4 sorting sets sequences compiler.vops
6 compiler.cfg.vn.expressions
7 compiler.cfg.vn.simplify
8 compiler.cfg.vn.liveness
9 compiler.cfg.vn.constant-fold
10 compiler.cfg.vn.propagate ;
13 : insn>vn ( insn -- vn ) >expr simplify ; inline
15 GENERIC: make-value-node ( insn -- )
16 M: flushable-op make-value-node [ insn>vn ] [ out>> ] bi set-vn ;
17 M: effect-op make-value-node in>> live-vreg ;
18 M: %store make-value-node [ in>> live-vreg ] [ addr>> live-vreg ] bi ;
19 M: %%set-slot make-value-node [ in>> live-vreg ] [ obj>> live-vreg ] bi ;
20 M: nullary-op make-value-node drop ;
22 : init-value-numbering ( -- )
27 : value-numbering ( instructions -- instructions )
29 [ [ make-value-node ] each ]
30 [ [ eliminate constant-fold propogate ] map ]