1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel math namespaces assocs biassocs accessors
4 math.order prettyprint.backend parser ;
5 IN: compiler.cfg.vn.graph
11 : next-vn ( -- vn ) vn-counter [ dup 1 + ] change vn boa ;
13 : VN: scan-word vn boa parsed ; parsing
15 M: vn <=> [ n>> ] compare ;
17 M: vn pprint* \ VN: pprint-word n>> pprint* ;
19 ! biassoc mapping expressions to value numbers
22 : expr>vn ( expr -- vn ) exprs>vns get [ drop next-vn ] cache ;
24 : vn>expr ( vn -- expr ) exprs>vns get value-at ;
28 : vreg>vn ( vreg -- vn ) vregs>vns get at ;
30 : vn>vreg ( vn -- vreg ) vregs>vns get value-at ;
32 : set-vn ( vn vreg -- ) vregs>vns get set-at ;
34 : init-value-graph ( -- )
36 <bihash> exprs>vns set
37 <bihash> vregs>vns set ;