compiler.cfg.utilities: add each-phi combinator to iterate over all ##phi instructions in a basic block
parent
21489ce85e
commit
01f51a96cd
|
@ -53,9 +53,9 @@ M: ds-loc pprint* \ D pprint-loc ;
|
||||||
M: rs-loc pprint* \ R pprint-loc ;
|
M: rs-loc pprint* \ R pprint-loc ;
|
||||||
|
|
||||||
: resolve-phis ( bb -- )
|
: resolve-phis ( bb -- )
|
||||||
instructions>> [ ##phi? ] filter [
|
[
|
||||||
[ [ [ get ] dip ] assoc-map ] change-inputs drop
|
[ [ [ get ] dip ] assoc-map ] change-inputs drop
|
||||||
] each ;
|
] each-phi ;
|
||||||
|
|
||||||
: test-bb ( insns n -- )
|
: test-bb ( insns n -- )
|
||||||
[ <basic-block> swap >>number swap >>instructions dup ] keep set
|
[ <basic-block> swap >>number swap >>instructions dup ] keep set
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
! 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
|
||||||
hashtables dlists compiler.cfg.def-use compiler.cfg.instructions
|
hashtables dlists compiler.cfg.def-use compiler.cfg.instructions
|
||||||
compiler.cfg.rpo compiler.cfg.liveness ;
|
compiler.cfg.rpo compiler.cfg.liveness compiler.cfg.utilities ;
|
||||||
IN: compiler.cfg.liveness.ssa
|
IN: compiler.cfg.liveness.ssa
|
||||||
|
|
||||||
! TODO: merge with compiler.cfg.liveness
|
! TODO: merge with compiler.cfg.liveness
|
||||||
|
@ -22,11 +22,9 @@ SYMBOL: work-list
|
||||||
[ live-out ] keep instructions>> transfer-liveness ;
|
[ live-out ] keep instructions>> transfer-liveness ;
|
||||||
|
|
||||||
: compute-phi-live-in ( basic-block -- phi-live-in )
|
: compute-phi-live-in ( basic-block -- phi-live-in )
|
||||||
instructions>> [ ##phi? ] filter [ f ] [
|
H{ } clone [
|
||||||
H{ } clone [
|
'[ inputs>> [ swap _ conjoin-at ] assoc-each ] each-phi
|
||||||
'[ inputs>> [ swap _ conjoin-at ] assoc-each ] each
|
] keep ;
|
||||||
] 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 ]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2008, 2009 Slava Pestov.
|
! Copyright (C) 2008, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel accessors combinators fry sequences assocs compiler.cfg.rpo
|
USING: kernel accessors combinators fry sequences assocs compiler.cfg.rpo
|
||||||
compiler.cfg.instructions ;
|
compiler.cfg.instructions compiler.cfg.utilities ;
|
||||||
IN: compiler.cfg.predecessors
|
IN: compiler.cfg.predecessors
|
||||||
|
|
||||||
: update-predecessors ( bb -- )
|
: update-predecessors ( bb -- )
|
||||||
|
@ -14,9 +14,7 @@ IN: compiler.cfg.predecessors
|
||||||
] change-inputs drop ;
|
] change-inputs drop ;
|
||||||
|
|
||||||
: update-phis ( bb -- )
|
: update-phis ( bb -- )
|
||||||
dup instructions>> [
|
dup [ update-phi ] with each-phi ;
|
||||||
dup ##phi? [ update-phi ] [ 2drop ] if
|
|
||||||
] with each ;
|
|
||||||
|
|
||||||
: compute-predecessors ( cfg -- cfg' )
|
: compute-predecessors ( cfg -- cfg' )
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,7 +34,7 @@ SYMBOL: seen
|
||||||
] [ src seen get conjoin ] if ;
|
] [ src seen get conjoin ] if ;
|
||||||
|
|
||||||
:: break-interferences ( -- )
|
:: break-interferences ( -- )
|
||||||
V{ } clone seen set
|
H{ } clone seen set
|
||||||
renaming-sets get [| dst assoc |
|
renaming-sets get [| dst assoc |
|
||||||
assoc [| src bb |
|
assoc [| src bb |
|
||||||
dst assoc src bb visit-renaming
|
dst assoc src bb visit-renaming
|
||||||
|
@ -49,9 +49,9 @@ SYMBOL: seen
|
||||||
|
|
||||||
: destruct-ssa ( cfg -- cfg' )
|
: destruct-ssa ( cfg -- cfg' )
|
||||||
dup cfg-has-phis? [
|
dup cfg-has-phis? [
|
||||||
init-coalescing
|
|
||||||
compute-ssa-live-sets
|
|
||||||
dup split-critical-edges
|
dup split-critical-edges
|
||||||
|
compute-ssa-live-sets
|
||||||
|
init-coalescing
|
||||||
dup compute-def-use
|
dup compute-def-use
|
||||||
dup compute-dominance
|
dup compute-dominance
|
||||||
dup compute-live-ranges
|
dup compute-live-ranges
|
||||||
|
|
|
@ -58,6 +58,10 @@ SYMBOL: visited
|
||||||
: if-has-phis ( bb quot: ( bb -- ) -- )
|
: if-has-phis ( bb quot: ( bb -- ) -- )
|
||||||
[ dup has-phis? ] dip [ drop ] if ; inline
|
[ dup has-phis? ] dip [ drop ] if ; inline
|
||||||
|
|
||||||
|
: each-phi ( bb quot: ( ##phi -- ) -- )
|
||||||
|
[ instructions>> ] dip
|
||||||
|
'[ dup ##phi? [ @ t ] [ drop f ] if ] all? drop ; inline
|
||||||
|
|
||||||
: predecessor ( bb -- pred )
|
: predecessor ( bb -- pred )
|
||||||
predecessors>> first ; inline
|
predecessors>> first ; inline
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue