1 ! Copyright (C) 2008, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel math namespaces assocs ;
4 IN: compiler.cfg.gvn.graph
6 SYMBOL: input-expr-counter
8 ! assoc mapping vregs to value numbers
9 ! this is the identity on canonical representatives
12 ! assoc mapping expressions to value numbers
15 ! assoc mapping value numbers to instructions
18 ! assoc mapping basic blocks to the set of value numbers that
19 ! are defined in the block
22 ! boolean to track whether vregs>vns changes
25 : vn>insn ( vn -- insn ) vns>insns get at ;
27 : vreg>vn ( vreg -- vn ) vregs>vns get at ;
29 : set-vn ( vn vreg -- )
30 vregs>vns get maybe-set-at [ changed? on ] when ;
32 : vreg>insn ( vreg -- insn ) vreg>vn vn>insn ;
34 : defined ( bb -- vns ) bbs>defns get at ;
37 exprs>vns get clear-assoc
38 vns>insns get clear-assoc
39 bbs>defns get clear-assoc ;
41 : init-value-graph ( -- )
42 0 input-expr-counter set
43 H{ } clone vregs>vns set
44 H{ } clone exprs>vns set
45 H{ } clone vns>insns set
46 H{ } clone bbs>defns set ;