factor/basis/compiler/cfg/linear-scan/allocation/allocation.factor

42 lines
1.3 KiB
Factor
Raw Normal View History

! Copyright (C) 2008, 2009 Slava Pestov.
2008-09-10 23:11:03 -04:00
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs heaps kernel namespaces sequences
compiler.cfg.linear-scan.allocation.coalescing
compiler.cfg.linear-scan.allocation.spilling
compiler.cfg.linear-scan.allocation.splitting
compiler.cfg.linear-scan.allocation.state ;
2008-09-11 03:05:22 -04:00
IN: compiler.cfg.linear-scan.allocation
2008-09-10 23:11:03 -04:00
: assign-register ( new -- )
dup coalesce? [ coalesce ] [
dup vreg>> free-registers-for [
dup intersecting-inactive
[ assign-blocked-register ]
[ assign-inactive-register ]
if-empty
] [ assign-free-register ]
2008-11-02 02:49:57 -05:00
if-empty
] if ;
2008-09-10 23:11:03 -04:00
2008-09-15 02:54:48 -04:00
: handle-interval ( live-interval -- )
[
start>>
[ progress set ]
[ deactivate-intervals ]
[ activate-intervals ] tri
] [ assign-register ] bi ;
2008-09-15 02:54:48 -04:00
: (allocate-registers) ( -- )
unhandled-intervals get [ handle-interval ] slurp-heap ;
: finish-allocation ( -- )
active-intervals inactive-intervals
[ get values [ handled-intervals get push-all ] each ] bi@ ;
2008-09-15 05:22:12 -04:00
: allocate-registers ( live-intervals machine-registers -- live-intervals )
init-allocator
init-unhandled
(allocate-registers)
finish-allocation
handled-intervals get ;