]> gitweb.factorcode.org Git - factor.git/blob - extra/compiler/cfg/gvn/avail/avail.factor
compiler.cfg.gvn: try to clean up availability issues (untested)
[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 hashtables kernel namespaces sequences
4 sets
5 compiler.cfg
6 compiler.cfg.dataflow-analysis
7 compiler.cfg.def-use
8 compiler.cfg.gvn.graph
9 compiler.cfg.predecessors
10 compiler.cfg.rpo ;
11 FROM: namespaces => set ;
12 IN: compiler.cfg.gvn.avail
13
14 : defined ( bb -- vregs )
15     instructions>> [ defs-vregs ] map concat unique ;
16
17 ! This doesn't propagate across "kill blocks".  Not sure if
18 ! that's right, though I may as well assume as much.
19
20 FORWARD-ANALYSIS: avail
21
22 M: avail-analysis transfer-set drop defined assoc-union ;
23
24 ! Strict idea of availability, for now.  Would like to see if
25 ! searching the VN congruence classes for the smallest
26 ! available vn would work at all / better.
27
28 : available? ( vn -- ? )
29     final-iteration? get [
30         basic-block get avail-ins get at key?
31     ] [ drop t ] if ;
32
33 : available-uses? ( insn -- ? )
34     uses-vregs [ available? ] all? ;
35
36 : with-available-uses? ( quot -- ? )
37     [ available-uses? ] bi and ; inline
38
39 : make-available ( insn -- insn )
40     dup dst>>
41     basic-block get avail-ins get [ dupd ?set-at ] change-at ;