 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel namespaces deques accessors sets sequences assocs fry
-dlists compiler.cfg.def-use ;
+dlists compiler.cfg.def-use compiler.cfg.instructions ;
 IN: compiler.cfg.liveness
 
 ! This is a backward dataflow analysis. See http://en.wikipedia.org/wiki/Liveness_analysis

: compute-liveness ( rpo -- )
    <hashed-dlist> work-list set
    H{ } clone live-ins set
    H{ } clone live-outs set
    <reversed> add-to-work-list
    work-list get [ liveness-step ] slurp-deque ;
SYMBOL: live-ins

: live-in ( basic-block -- set ) live-ins get at ;

! Assoc mapping basic blocks to sequences of sets of vregs; each sequence
! is in conrrespondence with a predecessor
SYMBOL: phi-live-ins

: phi-live-in ( predecessor basic-block -- set )
    [ predecessors>> index ] keep phi-live-ins get at
    dup [ nth ] [ 2drop f ] if ;

! Assoc mapping basic blocks to sets of vregs
SYMBOL: live-outs
