compiler.cfg.utilities: adding connect-bbs and make-edges

db4
Björn Lindqvist 2014-12-10 23:53:35 +01:00
parent 00e2d9f116
commit 628c87c5b1
2 changed files with 8 additions and 8 deletions

View File

@ -177,13 +177,6 @@ IN: compiler.cfg.stacks.vacant.tests
{ { 0 { -1 } } } [ cfg1 output-stack-map first ] unit-test { { 0 { -1 } } } [ cfg1 output-stack-map first ] unit-test
: connect-bbs ( from to -- )
[ [ successors>> ] dip suffix! drop ]
[ predecessors>> swap suffix! drop ] 2bi ;
: make-edges ( block-map edgelist -- )
[ [ of ] with map first2 connect-bbs ] with each ;
! Same cfg structure as the bug1021:run-test word but with ! Same cfg structure as the bug1021:run-test word but with
! non-datastack instructions mostly omitted. ! non-datastack instructions mostly omitted.
: bug1021-cfg ( -- cfg ) : bug1021-cfg ( -- cfg )
@ -230,7 +223,7 @@ IN: compiler.cfg.stacks.vacant.tests
T{ ##alien-invoke { gc-map T{ gc-map { scrub-d { } } } } } T{ ##alien-invoke { gc-map T{ gc-map { scrub-d { } } } } }
} }
} }
} [ over insns>block ] assoc-map dup } [ over insns>block ] assoc-map dup
{ { 0 1 } { 1 2 } { 2 3 } { 3 8 } { 8 10 } } make-edges 0 of block>cfg ; { { 0 1 } { 1 2 } { 2 3 } { 3 8 } { 8 10 } } make-edges 0 of block>cfg ;
{ { 4 { 3 2 1 -3 0 -2 -1 } } } [ { { 4 { 3 2 1 -3 0 -2 -1 } } } [

View File

@ -86,3 +86,10 @@ IN: compiler.cfg.utilities
: apply-passes ( obj passes -- ) : apply-passes ( obj passes -- )
[ execute( x -- ) ] with each ; [ execute( x -- ) ] with each ;
: connect-bbs ( from to -- )
[ [ successors>> ] dip suffix! drop ]
[ predecessors>> swap suffix! drop ] 2bi ;
: make-edges ( block-map edgelist -- )
[ [ of ] with map first2 connect-bbs ] with each ;