2011-06-25 19:50:05 -04:00
|
|
|
! Copyright (C) 2011 Alex Vondrak.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
USING: accessors assocs compiler.cfg
|
2011-06-27 18:12:07 -04:00
|
|
|
compiler.cfg.dataflow-analysis
|
|
|
|
compiler.cfg.def-use
|
|
|
|
compiler.cfg.predecessors compiler.cfg.rpo deques dlists
|
|
|
|
hashtables kernel locals namespaces sequences sets ;
|
|
|
|
FROM: namespaces => set ;
|
2011-06-25 19:50:05 -04:00
|
|
|
IN: compiler.cfg.gvn.avail
|
|
|
|
|
|
|
|
: defined ( bb -- vregs )
|
2011-06-27 18:12:07 -04:00
|
|
|
instructions>> [ defs-vregs ] map concat unique ;
|
|
|
|
|
|
|
|
! This doesn't propagate across "kill blocks". Not sure if
|
|
|
|
! that's right, though I may as well assume as much.
|
2011-06-25 19:50:05 -04:00
|
|
|
|
|
|
|
FORWARD-ANALYSIS: avail
|
|
|
|
|
|
|
|
M: avail-analysis transfer-set drop defined assoc-union ;
|
|
|
|
|
|
|
|
: available? ( vn -- ? )
|
|
|
|
basic-block get avail-ins get at key? ;
|
|
|
|
|
|
|
|
: make-available ( insn -- insn )
|
|
|
|
dup dst>>
|
|
|
|
basic-block get avail-ins get [ dupd ?set-at ] change-at ;
|