compiler.cfg.liveness: update for new ##phi node representation
parent
90daf6d03d
commit
6d46bf623c
|
@ -0,0 +1,15 @@
|
||||||
|
USING: compiler.cfg compiler.cfg.instructions compiler.cfg.registers
|
||||||
|
compiler.cfg.liveness accessors tools.test cpu.architecture ;
|
||||||
|
IN: compiler.cfg.liveness.tests
|
||||||
|
|
||||||
|
[
|
||||||
|
H{
|
||||||
|
{ "A" H{ { V int-regs 1 V int-regs 1 } { V int-regs 4 V int-regs 4 } } }
|
||||||
|
{ "B" H{ { V int-regs 3 V int-regs 3 } { V int-regs 2 V int-regs 2 } } }
|
||||||
|
}
|
||||||
|
] [
|
||||||
|
<basic-block> V{
|
||||||
|
T{ ##phi f V int-regs 0 { { "A" V int-regs 1 } { "B" V int-regs 2 } } }
|
||||||
|
T{ ##phi f V int-regs 1 { { "B" V int-regs 3 } { "A" V int-regs 4 } } }
|
||||||
|
} >>instructions compute-phi-live-in
|
||||||
|
] unit-test
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2009 Slava Pestov.
|
! Copyright (C) 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel namespaces deques accessors sets sequences assocs fry
|
USING: kernel namespaces deques accessors sets sequences assocs fry
|
||||||
dlists compiler.cfg.def-use compiler.cfg.instructions
|
hashtables dlists compiler.cfg.def-use compiler.cfg.instructions
|
||||||
compiler.cfg.rpo ;
|
compiler.cfg.rpo ;
|
||||||
IN: compiler.cfg.liveness
|
IN: compiler.cfg.liveness
|
||||||
|
|
||||||
|
@ -16,9 +16,7 @@ SYMBOL: live-ins
|
||||||
! is in conrrespondence with a predecessor
|
! is in conrrespondence with a predecessor
|
||||||
SYMBOL: phi-live-ins
|
SYMBOL: phi-live-ins
|
||||||
|
|
||||||
: phi-live-in ( predecessor basic-block -- set )
|
: phi-live-in ( predecessor basic-block -- set ) phi-live-ins get at at ;
|
||||||
[ predecessors>> index ] keep phi-live-ins get at
|
|
||||||
dup [ nth ] [ 2drop f ] if ;
|
|
||||||
|
|
||||||
! Assoc mapping basic blocks to sets of vregs
|
! Assoc mapping basic blocks to sets of vregs
|
||||||
SYMBOL: live-outs
|
SYMBOL: live-outs
|
||||||
|
@ -45,9 +43,15 @@ SYMBOL: work-list
|
||||||
[ nip kill-set ]
|
[ nip kill-set ]
|
||||||
2bi assoc-diff ;
|
2bi assoc-diff ;
|
||||||
|
|
||||||
|
: conjoin-at ( value key assoc -- )
|
||||||
|
[ dupd ?set-at ] change-at ;
|
||||||
|
|
||||||
: compute-phi-live-in ( basic-block -- phi-live-in )
|
: compute-phi-live-in ( basic-block -- phi-live-in )
|
||||||
instructions>> [ ##phi? ] filter
|
instructions>> [ ##phi? ] filter [ f ] [
|
||||||
[ f ] [ [ inputs>> ] map flip [ unique ] map ] if-empty ;
|
H{ } clone [
|
||||||
|
'[ inputs>> [ swap _ conjoin-at ] assoc-each ] each
|
||||||
|
] keep
|
||||||
|
] if-empty ;
|
||||||
|
|
||||||
: update-live-in ( basic-block -- changed? )
|
: update-live-in ( basic-block -- changed? )
|
||||||
[ [ compute-live-in ] keep live-ins get maybe-set-at ]
|
[ [ compute-live-in ] keep live-ins get maybe-set-at ]
|
||||||
|
|
|
@ -17,7 +17,7 @@ sequences kernel classes ;
|
||||||
<state> H{ { D 0 V int-regs 0 } } >>locs>vregs
|
<state> H{ { D 0 V int-regs 0 } } >>locs>vregs
|
||||||
<state> H{ { D 0 V int-regs 1 } } >>locs>vregs 2array
|
<state> H{ { D 0 V int-regs 1 } } >>locs>vregs 2array
|
||||||
|
|
||||||
[ merge-locs locs>vregs>> keys ] { } make first inputs>>
|
[ merge-locs locs>vregs>> keys ] { } make first inputs>> values
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue