compiler.cfg.linear-scan.*: refactoring to simplify init-allocator and get rid of init-unhandled

db4
Björn Lindqvist 2014-12-14 18:59:14 +01:00
parent fab478482e
commit c810677b47
3 changed files with 11 additions and 14 deletions

View File

@ -76,7 +76,6 @@ M: sync-point handle ( sync-point -- )
: allocate-registers ( live-intervals sync-point machine-registers -- live-intervals ) : allocate-registers ( live-intervals sync-point machine-registers -- live-intervals )
init-allocator init-allocator
init-unhandled
unhandled-intervals get unhandled-sync-points get (allocate-registers) unhandled-intervals get unhandled-sync-points get (allocate-registers)
finish-allocation finish-allocation
handled-intervals get ; handled-intervals get ;

View File

@ -22,6 +22,12 @@ SYMBOL: progress
: check-handled ( live-interval -- ) : check-handled ( live-interval -- )
end>> progress get > [ "check-handled" throw ] when ; inline end>> progress get > [ "check-handled" throw ] when ; inline
: live-intervals>min-heap ( live-intervals -- min-heap )
[ [ start>> ] map ] keep zip >min-heap ;
: sync-points>min-heap ( sync-points -- min-heap )
[ [ n>> ] map ] keep zip >min-heap ;
! Mapping from register classes to sequences of machine registers ! Mapping from register classes to sequences of machine registers
SYMBOL: registers SYMBOL: registers
@ -108,7 +114,6 @@ ERROR: register-already-used live-interval ;
[ don't-change ] [ don't-change ]
} process-intervals ; } process-intervals ;
! Minheap of live intervals which still need a register allocation
SYMBOL: unhandled-intervals SYMBOL: unhandled-intervals
: add-unhandled ( live-interval -- ) : add-unhandled ( live-interval -- )
@ -127,7 +132,6 @@ SYMBOL: unhandled-intervals
: align-spill-area ( align -- ) : align-spill-area ( align -- )
cfg get [ max ] change-spill-area-align drop ; cfg get [ max ] change-spill-area-align drop ;
! Minheap of sync points which still need to be processed
SYMBOL: unhandled-sync-points SYMBOL: unhandled-sync-points
SYMBOL: spill-slots SYMBOL: spill-slots
@ -141,10 +145,11 @@ SYMBOL: spill-slots
: lookup-spill-slot ( coalesced-vreg rep -- spill-slot ) : lookup-spill-slot ( coalesced-vreg rep -- spill-slot )
rep-size 2array spill-slots get ?at [ ] [ bad-vreg ] if ; rep-size 2array spill-slots get ?at [ ] [ bad-vreg ] if ;
: init-allocator ( registers -- ) : init-allocator ( live-intervals sync-points registers -- )
registers set registers set
<min-heap> unhandled-intervals set [ live-intervals>min-heap unhandled-intervals set ]
<min-heap> unhandled-sync-points set [ sync-points>min-heap unhandled-sync-points set ] bi*
[ V{ } clone ] reg-class-assoc active-intervals set [ V{ } clone ] reg-class-assoc active-intervals set
[ V{ } clone ] reg-class-assoc inactive-intervals set [ V{ } clone ] reg-class-assoc inactive-intervals set
V{ } clone handled-intervals set V{ } clone handled-intervals set
@ -152,10 +157,6 @@ SYMBOL: spill-slots
H{ } clone spill-slots set H{ } clone spill-slots set
-1 progress set ; -1 progress set ;
: init-unhandled ( live-intervals sync-points -- )
[ unhandled-intervals get '[ dup start>> _ heap-push ] each ]
[ unhandled-sync-points get '[ dup n>> _ heap-push ] each ]
bi* ;
! A utility used by register-status and spill-status words ! A utility used by register-status and spill-status words
: free-positions ( new -- assoc ) : free-positions ( new -- assoc )

View File

@ -38,9 +38,6 @@ ERROR: not-spilled-error vreg ;
SYMBOL: unhandled-intervals SYMBOL: unhandled-intervals
: init-unhandled ( live-intervals -- unhandled-intervals )
[ dup start>> swap 2array ] map >min-heap ;
! Liveness info is used by resolve pass ! Liveness info is used by resolve pass
SYMBOL: machine-live-ins SYMBOL: machine-live-ins
@ -70,7 +67,7 @@ SYMBOL: machine-live-outs
[ live-out keys vregs>regs ] keep machine-live-outs get set-at ; [ live-out keys vregs>regs ] keep machine-live-outs get set-at ;
: init-assignment ( live-intervals -- ) : init-assignment ( live-intervals -- )
init-unhandled unhandled-intervals set live-intervals>min-heap unhandled-intervals set
<min-heap> pending-interval-heap set <min-heap> pending-interval-heap set
H{ } clone pending-interval-assoc set H{ } clone pending-interval-assoc set
H{ } clone machine-live-ins set H{ } clone machine-live-ins set