factor/basis/compiler/cfg/value-numbering/graph/graph.factor

31 lines
776 B
Factor
Raw Normal View History

2010-04-21 03:08:52 -04:00
! Copyright (C) 2008, 2010 Slava Pestov.
2008-10-19 02:10:21 -04:00
! See http://factorcode.org/license.txt for BSD license.
2014-12-13 19:10:21 -05:00
USING: assocs kernel namespaces ;
2008-10-19 02:10:21 -04:00
IN: compiler.cfg.value-numbering.graph
SYMBOL: input-expr-counter
! assoc mapping vregs to value numbers
! this is the identity on canonical representatives
SYMBOL: vregs>vns
2008-10-19 02:10:21 -04:00
! assoc mapping expressions to value numbers
2008-10-19 02:10:21 -04:00
SYMBOL: exprs>vns
! assoc mapping value numbers to instructions
SYMBOL: vns>insns
: vn>insn ( vn -- insn ) vns>insns get at ;
: vreg>vn ( vreg -- vn ) vregs>vns get [ ] cache ;
2008-10-19 02:10:21 -04:00
: set-vn ( vn vreg -- ) vregs>vns get set-at ;
: vreg>insn ( vreg -- insn ) vreg>vn vn>insn ;
2008-10-22 22:59:07 -04:00
2008-10-19 02:10:21 -04:00
: init-value-graph ( -- )
0 input-expr-counter set
H{ } clone vregs>vns set
H{ } clone exprs>vns set
H{ } clone vns>insns set ;