compiler.cfg.linear-scan: tweak it so that register allocation does not depend on hashing order

db4
Slava Pestov 2009-09-27 23:29:48 -05:00
parent aa3b9097c8
commit 1d872db58d
3 changed files with 8 additions and 7 deletions

View File

@ -1,7 +1,7 @@
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs combinators fry hints kernel locals
math sequences sets sorting splitting namespaces
math sequences sets sorting splitting namespaces linked-assocs
combinators.short-circuit compiler.utilities
compiler.cfg.linear-scan.allocation.state
compiler.cfg.linear-scan.allocation.splitting
@ -83,7 +83,7 @@ ERROR: bad-live-ranges interval ;
find-use-positions ;
: spill-status ( new -- use-pos )
H{ } clone
H{ } <linked-assoc>
[ inactive-positions ] [ active-positions ] [ nip ] 2tri
>alist alist-max ;

View File

@ -2,8 +2,8 @@
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs combinators cpu.architecture fry heaps
kernel math math.order namespaces sequences vectors
compiler.cfg compiler.cfg.registers compiler.cfg.instructions
compiler.cfg.linear-scan.live-intervals ;
linked-assocs compiler.cfg compiler.cfg.registers
compiler.cfg.instructions compiler.cfg.linear-scan.live-intervals ;
IN: compiler.cfg.linear-scan.allocation.state
! Start index of current live interval. We ensure that all
@ -148,7 +148,8 @@ SYMBOL: spill-slots
! A utility used by register-status and spill-status words
: free-positions ( new -- assoc )
vreg>> rep-of reg-class-of registers get at [ 1/0. ] H{ } map>assoc ;
vreg>> rep-of reg-class-of registers get at
[ 1/0. ] H{ } <linked-assoc> map>assoc ;
: add-use-position ( n reg assoc -- ) [ [ min ] when* ] change-at ;

View File

@ -29,9 +29,9 @@ yield-hook [ [ ] ] initialize
: alist-most ( alist quot -- pair )
[ [ ] ] dip '[ [ [ second ] bi@ @ ] most ] map-reduce ; inline
: alist-min ( alist -- pair ) [ before? ] alist-most ;
: alist-min ( alist -- pair ) [ before=? ] alist-most ;
: alist-max ( alist -- pair ) [ after? ] alist-most ;
: alist-max ( alist -- pair ) [ after=? ] alist-most ;
: penultimate ( seq -- elt ) [ length 2 - ] keep nth ;