compiler.cfg.graphviz: tweak code & output a little
parent
d6849da7ec
commit
51b3b1fd87
|
@ -42,41 +42,28 @@ IN: compiler.cfg.graphviz
|
||||||
[ number>> ] bi@ ->
|
[ number>> ] bi@ ->
|
||||||
] with each ;
|
] with each ;
|
||||||
|
|
||||||
SYMBOL: linearize?
|
: cfgviz ( cfg -- graph )
|
||||||
linearize? off
|
|
||||||
|
|
||||||
: ?linearize ( graph cfg -- graph' )
|
|
||||||
linearize? get [
|
|
||||||
<anon>
|
|
||||||
edge[ "invis" =style ];
|
|
||||||
swap linearization-order [ number>> ] map ~->
|
|
||||||
add
|
|
||||||
] [ drop ] if ;
|
|
||||||
|
|
||||||
: cfgviz ( cfg filename -- cfg )
|
|
||||||
over
|
|
||||||
<digraph>
|
<digraph>
|
||||||
graph[ "t" =labelloc ];
|
graph[ "t" =labelloc ];
|
||||||
node[ "box" =shape "Courier" =fontname 10 =fontsize ];
|
node[ "box" =shape "Courier" =fontname 10 =fontsize ];
|
||||||
swap
|
swap [
|
||||||
[ ?linearize ]
|
[ add-cfg-vertex ] [ add-cfg-edges ] bi
|
||||||
[ [ add-cfg-vertex ] each-basic-block ]
|
] each-basic-block ;
|
||||||
[ [ add-cfg-edges ] each-basic-block ]
|
|
||||||
tri
|
|
||||||
swap png ;
|
|
||||||
|
|
||||||
: perform-pass ( cfg pass -- cfg' )
|
: perform-pass ( cfg pass pass# -- cfg' )
|
||||||
def>> call( cfg -- cfg' ) ;
|
drop def>> call( cfg -- cfg' ) ;
|
||||||
|
|
||||||
: pass-file ( pass pass# -- path )
|
: draw-cfg ( cfg pass pass# -- cfg )
|
||||||
[ name>> ] [ number>string "-" append ] bi* prepend ;
|
[ dup cfgviz ]
|
||||||
|
[ name>> "After " prepend =label ]
|
||||||
|
[ number>string png ]
|
||||||
|
tri* ;
|
||||||
|
|
||||||
: watch-pass ( cfg pass pass# -- cfg' )
|
: watch-pass ( cfg pass pass# -- cfg' )
|
||||||
[ drop perform-pass ] 2keep
|
[ perform-pass ] 2keep draw-cfg ;
|
||||||
pass-file cfgviz ;
|
|
||||||
|
|
||||||
: begin-watching-passes ( cfg -- cfg )
|
: begin-watching-passes ( cfg -- cfg )
|
||||||
"0-build-cfg" cfgviz ;
|
\ build-cfg 0 draw-cfg ;
|
||||||
|
|
||||||
: watch-passes ( cfg -- cfg' )
|
: watch-passes ( cfg -- cfg' )
|
||||||
\ optimize-cfg def>> [ 1 + watch-pass ] each-index ;
|
\ optimize-cfg def>> [ 1 + watch-pass ] each-index ;
|
||||||
|
|
Loading…
Reference in New Issue