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
6 compiler.cfg.predecessors compiler.cfg.rpo deques dlists
7 hashtables kernel locals namespaces sequences sets ;
8 FROM: namespaces => set ;
9 IN: compiler.cfg.gvn.avail
11 : defined ( bb -- vregs )
12 instructions>> [ defs-vregs ] map concat unique ;
14 ! This doesn't propagate across "kill blocks". Not sure if
15 ! that's right, though I may as well assume as much.
17 FORWARD-ANALYSIS: avail
19 M: avail-analysis transfer-set drop defined assoc-union ;
21 : available? ( vn -- ? )
22 basic-block get avail-ins get at key? ;
24 : make-available ( insn -- insn )
26 basic-block get avail-ins get [ dupd ?set-at ] change-at ;