fix bug where traversal order was lost

db4
Doug Coleman 2009-06-30 16:44:14 -05:00
parent f41f84436c
commit d1f6871081
3 changed files with 34 additions and 20 deletions

View File

@ -248,4 +248,4 @@ INSN: _reload dst class n ;
INSN: _copy dst src class ; INSN: _copy dst src class ;
INSN: _spill-counts counts ; INSN: _spill-counts counts ;
SYMBOL: temp-spill SYMBOL: spill-temp

View File

@ -68,12 +68,12 @@ T{ live-interval
[ [
{ {
T{ _copy { dst 5 } { src 4 } { class int-regs } } T{ _copy { dst 5 } { src 4 } { class int-regs } }
T{ _spill { src 0 } { class int-regs } { n spill-temp } } T{ _spill { src 1 } { class int-regs } { n spill-temp } }
T{ _copy { dst 0 } { src 1 } { class int-regs } } T{ _copy { dst 1 } { src 0 } { class int-regs } }
T{ _reload { dst 1 } { class int-regs } { n spill-temp } } T{ _reload { dst 0 } { class int-regs } { n spill-temp } }
T{ _spill { src 0 } { class float-regs } { n spill-temp } } T{ _spill { src 1 } { class float-regs } { n spill-temp } }
T{ _copy { dst 0 } { src 1 } { class float-regs } } T{ _copy { dst 1 } { src 0 } { class float-regs } }
T{ _reload { dst 1 } { class float-regs } { n spill-temp } } T{ _reload { dst 0 } { class float-regs } { n spill-temp } }
} }
] [ ] [
{ {
@ -87,10 +87,10 @@ T{ live-interval
[ [
{ {
T{ _spill { src 0 } { class int-regs } { n spill-temp } } T{ _spill { src 2 } { class int-regs } { n spill-temp } }
T{ _copy { dst 0 } { src 2 } { class int-regs } }
T{ _copy { dst 2 } { src 1 } { class int-regs } } T{ _copy { dst 2 } { src 1 } { class int-regs } }
T{ _reload { dst 1 } { class int-regs } { n spill-temp } } T{ _copy { dst 1 } { src 0 } { class int-regs } }
T{ _reload { dst 0 } { class int-regs } { n spill-temp } }
} }
] [ ] [
{ {
@ -162,10 +162,10 @@ T{ live-interval
{ {
T{ _copy { dst 1 } { src 0 } { class int-regs } } T{ _copy { dst 1 } { src 0 } { class int-regs } }
T{ _copy { dst 2 } { src 0 } { class int-regs } } T{ _copy { dst 2 } { src 0 } { class int-regs } }
T{ _spill { src 3 } { class int-regs } { n spill-temp } } T{ _spill { src 4 } { class int-regs } { n spill-temp } }
T{ _copy { dst 4 } { src 0 } { class int-regs } } T{ _copy { dst 4 } { src 0 } { class int-regs } }
T{ _copy { dst 3 } { src 4 } { class int-regs } } T{ _copy { dst 0 } { src 3 } { class int-regs } }
T{ _reload { dst 0 } { class int-regs } { n spill-temp } } T{ _reload { dst 3 } { class int-regs } { n spill-temp } }
} }
] [ ] [
{ {
@ -182,10 +182,10 @@ T{ live-interval
T{ _copy { dst 2 } { src 0 } { class int-regs } } T{ _copy { dst 2 } { src 0 } { class int-regs } }
T{ _copy { dst 9 } { src 1 } { class int-regs } } T{ _copy { dst 9 } { src 1 } { class int-regs } }
T{ _copy { dst 1 } { src 0 } { class int-regs } } T{ _copy { dst 1 } { src 0 } { class int-regs } }
T{ _spill { src 3 } { class int-regs } { n spill-temp } } T{ _spill { src 4 } { class int-regs } { n spill-temp } }
T{ _copy { dst 4 } { src 0 } { class int-regs } } T{ _copy { dst 4 } { src 0 } { class int-regs } }
T{ _copy { dst 3 } { src 4 } { class int-regs } } T{ _copy { dst 0 } { src 3 } { class int-regs } }
T{ _reload { dst 0 } { class int-regs } { n spill-temp } } T{ _reload { dst 3 } { class int-regs } { n spill-temp } }
} }
] [ ] [
{ {

View File

@ -126,22 +126,36 @@ M: register->register to-loc drop register ;
:: (trace-chain) ( obj hashtable -- ) :: (trace-chain) ( obj hashtable -- )
obj to-reg froms get at* [ obj to-reg froms get at* [
dup ,
obj over hashtable clone [ maybe-set-at ] keep swap obj over hashtable clone [ maybe-set-at ] keep swap
[ (trace-chain) ] [ , drop ] if [ (trace-chain) ] [ 2drop ] if
] [ ] [
drop hashtable , drop
] if ; ] if ;
: trace-chain ( obj -- seq ) : trace-chain ( obj -- seq )
[ [
dup ,
dup dup associate (trace-chain) dup dup associate (trace-chain)
] { } make [ keys ] map concat reverse ; ] { } make prune reverse ;
: trace-chains ( seq -- seq' ) : trace-chains ( seq -- seq' )
[ trace-chain ] map concat ; [ trace-chain ] map concat ;
: break-cycle-n ( operations -- operations' ) ERROR: resolve-error ;
: split-cycle ( operations -- chain spilled-operation )
unclip [ unclip [
[ set-tos/froms ]
[
[ start? ] find nip
[ resolve-error ] unless* trace-chain
] bi
] dip ;
: break-cycle-n ( operations -- operations' )
split-cycle [
[ from>> spill-temp ] [ from>> spill-temp ]
[ reg-class>> ] bi \ register->memory boa [ reg-class>> ] bi \ register->memory boa
] [ ] [