compiler.cfg.dependence: now the nodes are on the stack instead of being saved in a dynamic variable (fp++)

db4
Björn Lindqvist 2014-11-09 01:46:04 +01:00 committed by Doug Coleman
parent 2cfd55b864
commit 3f3cc0eb8a
2 changed files with 12 additions and 21 deletions

View File

@ -9,7 +9,6 @@ IN: compiler.cfg.dependence
SYMBOL: roots SYMBOL: roots
SYMBOL: node-number SYMBOL: node-number
SYMBOL: nodes
SYMBOL: +data+ SYMBOL: +data+
SYMBOL: +control+ SYMBOL: +control+
@ -121,31 +120,28 @@ M: object add-control-edge 2drop ;
] [ drop ] if ; ] [ drop ] if ;
: make-trees ( nodes -- trees ) : make-trees ( nodes -- trees )
[ [ choose-parent ] each ] [ [ choose-parent ] each ] [ [ parent>> not ] filter ] bi ;
[ [ parent>> not ] filter ] bi ;
ERROR: node-missing-parent trees nodes ; ERROR: node-missing-parent trees nodes ;
ERROR: node-missing-children trees nodes ; ERROR: node-missing-children trees nodes ;
: flatten-tree ( node -- nodes ) : flatten-tree ( node -- nodes )
[ children>> [ flatten-tree ] map concat ] keep [ children>> [ flatten-tree ] map concat ] keep suffix ;
suffix ;
: verify-parents ( trees -- trees ) : verify-parents ( nodes trees -- )
nodes get over '[ [ parent>> ] [ _ member? ] bi or ] all? 2dup '[ [ parent>> ] [ _ member? ] bi or ] all?
[ nodes get node-missing-parent ] unless ; [ 2drop ] [ node-missing-parent ] if ;
: verify-children ( trees -- trees ) : verify-children ( nodes trees -- )
dup [ flatten-tree ] map concat 2dup [ flatten-tree ] map concat
nodes get
{ [ [ length ] same? ] [ set= ] } 2&& { [ [ length ] same? ] [ set= ] } 2&&
[ nodes get node-missing-children ] unless ; [ 2drop ] [ node-missing-children ] if ;
: verify-trees ( trees -- trees ) : verify-trees ( nodes trees -- )
verify-parents verify-children ; [ verify-parents ] [ verify-children ] 2bi ;
: build-fan-in-trees ( nodes -- ) : build-fan-in-trees ( nodes -- )
dup nodes set make-trees verify-trees [ dup make-trees [ verify-trees ] keep [
-1/0. >>parent-index -1/0. >>parent-index
calculate-registers drop calculate-registers drop
] each ; ] each ;

View File

@ -66,13 +66,8 @@ conditional-branch-insn
: final-insn-start ( insns -- n ) : final-insn-start ( insns -- n )
[ final-insn? not ] find-last drop [ 1 + ] [ 0 ] if* ; [ final-insn? not ] find-last drop [ 1 + ] [ 0 ] if* ;
! hack to get bootstrapping working
: split-indices-int ( seq indices -- pieces )
over length suffix 0 swap [ dup swapd 2array ] map nip
[ first2 rot subseq ] with map ;
: split-insns ( insns -- pre/body/post ) : split-insns ( insns -- pre/body/post )
dup [ initial-insn-end ] [ final-insn-start ] bi 2array split-indices-int ; dup [ initial-insn-end ] [ final-insn-start ] bi 2array split-indices ;
: reorder-body ( body -- body' ) : reorder-body ( body -- body' )
[ <node> ] map [ <node> ] map