1 ! Copyright (C) 2008, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel sequences sets arrays math strings fry
4 namespaces prettyprint compiler.cfg.linear-scan.live-intervals
5 compiler.cfg.linear-scan.allocation compiler.cfg assocs ;
6 IN: compiler.cfg.linear-scan.debugger
8 : check-assigned ( live-intervals -- )
11 [ "Not all intervals have registers" throw ] unless
14 : split-children ( live-interval -- seq )
16 [ split-before>> ] [ split-after>> ] bi
17 [ split-children ] bi@
21 : check-linear-scan ( live-intervals machine-registers -- )
23 [ clone ] map dup [ [ vreg>> ] keep ] H{ } map>assoc
25 ] dip allocate-registers
26 [ split-children ] map concat check-assigned ;
28 : picture ( uses -- str )
29 dup last 1 + CHAR: space <string>
30 [ '[ CHAR: * swap _ set-nth ] each ] keep ;
32 : interval-picture ( interval -- str )
34 [ copy-from>> unparse ]
38 : live-intervals. ( seq -- )
39 [ interval-picture ] map simple-table. ;