2011-06-25 19:50:05 -04:00
|
|
|
! Copyright (C) 2011 Alex Vondrak.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2011-06-28 20:58:55 -04:00
|
|
|
USING: accessors assocs hashtables kernel namespaces sequences
|
|
|
|
sets
|
|
|
|
compiler.cfg
|
2011-06-27 18:12:07 -04:00
|
|
|
compiler.cfg.dataflow-analysis
|
|
|
|
compiler.cfg.def-use
|
2011-06-28 20:58:55 -04:00
|
|
|
compiler.cfg.gvn.graph
|
|
|
|
compiler.cfg.predecessors
|
|
|
|
compiler.cfg.rpo ;
|
2011-06-27 18:12:07 -04:00
|
|
|
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 ;
|
|
|
|
|
2011-06-28 20:58:55 -04:00
|
|
|
! Strict idea of availability, for now. Would like to see if
|
|
|
|
! searching the VN congruence classes for the smallest
|
|
|
|
! available vn would work at all / better.
|
|
|
|
|
2011-06-25 19:50:05 -04:00
|
|
|
: available? ( vn -- ? )
|
2011-06-28 20:58:55 -04:00
|
|
|
final-iteration? get [
|
|
|
|
basic-block get avail-ins get at key?
|
|
|
|
] [ drop t ] if ;
|
|
|
|
|
|
|
|
: available-uses? ( insn -- ? )
|
|
|
|
uses-vregs [ available? ] all? ;
|
|
|
|
|
|
|
|
: with-available-uses? ( quot -- ? )
|
|
|
|
[ available-uses? ] bi and ; inline
|
2011-06-25 19:50:05 -04:00
|
|
|
|
|
|
|
: make-available ( insn -- insn )
|
|
|
|
dup dst>>
|
|
|
|
basic-block get avail-ins get [ dupd ?set-at ] change-at ;
|