]> gitweb.factorcode.org Git - factor.git/blob - extra/compiler/cfg/gvn/avail/avail.factor
compiler.cfg.gvn.redundancy-elimination: horrific tinkering that doesn't even work
[factor.git] / extra / compiler / cfg / gvn / avail / avail.factor
1 ! Copyright (C) 2011 Alex Vondrak.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs compiler.cfg
4 compiler.cfg.dataflow-analysis compiler.cfg.def-use hashtables
5 kernel namespaces sequences ;
6 IN: compiler.cfg.gvn.avail
7
8 ! assoc mapping basic blocks to the set of value numbers that
9 ! are defined in the block
10 SYMBOL: bbs>defns
11
12 ! : defined ( bb -- vns ) bbs>defns get at ;
13
14 : defined ( bb -- vregs )
15     instructions>> [ defs-vregs ] map concat [ dup ] H{ } map>assoc ;
16
17 FORWARD-ANALYSIS: avail
18
19 M: avail-analysis transfer-set drop defined assoc-union ;
20
21 : available? ( vn -- ? )
22     basic-block get avail-ins get at key? ;
23
24 : make-available ( insn -- insn )
25     dup dst>>
26     basic-block get avail-ins get [ dupd ?set-at ] change-at ;