1 ! Copyright (C) 2011 Alex Vondrak.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs hashtables kernel namespaces sequences
6 compiler.cfg.dataflow-analysis
9 compiler.cfg.predecessors
11 FROM: assocs => change-at ;
12 FROM: namespaces => set ;
13 IN: compiler.cfg.gvn.avail
15 : defined ( bb -- vregs )
16 instructions>> [ defs-vregs ] map concat unique ;
18 ! This doesn't propagate across "kill blocks". Not sure if
19 ! that's right, though I may as well assume as much.
21 FORWARD-ANALYSIS: avail
23 M: avail-analysis transfer-set drop defined assoc-union ;
25 ! Strict idea of availability, for now. Would like to see if
26 ! searching the VN congruence classes for the smallest
27 ! available vn would work at all / better.
29 : available? ( vn -- ? )
30 final-iteration? get [
31 basic-block get avail-in key?
34 : available-uses? ( insn -- ? )
35 uses-vregs [ available? ] all? ;
37 : with-available-uses? ( quot -- ? )
38 keep swap [ available-uses? ] [ drop f ] if ; inline
40 : make-available ( vreg -- )
41 basic-block get avail-ins get [ dupd clone ?set-at ] change-at ;