compiler.cfg.dependence/scheduling: more readable version of the select word

db4
Björn Lindqvist 2014-11-09 04:34:10 +01:00 committed by Doug Coleman
parent b5754d32ef
commit 586c47e5ab
2 changed files with 8 additions and 13 deletions

View File

@ -119,8 +119,8 @@ M: object add-control-edge 2drop ;
: make-trees ( nodes -- trees ) : make-trees ( nodes -- trees )
[ [ choose-parent ] each ] [ [ parent>> not ] filter ] bi ; [ [ choose-parent ] each ] [ [ parent>> not ] filter ] bi ;
: initialize-scores ( trees -- )
[ -1/0. >>parent-index calculate-registers drop ] each ;
: build-fan-in-trees ( nodes -- ) : build-fan-in-trees ( nodes -- )
make-trees [ make-trees initialize-scores ;
-1/0. >>parent-index
calculate-registers drop
] each ;

View File

@ -28,14 +28,8 @@ ERROR: bad-delete-at key assoc ;
: score ( node -- n ) : score ( node -- n )
[ parent-index>> ] [ registers>> neg ] [ insn>> insn#>> ] tri 3array ; [ parent-index>> ] [ registers>> neg ] [ insn>> insn#>> ] tri 3array ;
: pull-out-nth ( n seq -- elt ) : select ( vector quot: ( elt -- score ) -- elt )
[ nth ] [ remove-nth! drop ] 2bi ; dupd supremum-by swap dupd remove-eq! drop ; inline
: select ( vector quot -- elt )
! This could be sped up by a constant factor
[ dup <enum> ] dip '[ _ call( insn -- score ) ] assoc-map
dup values supremum '[ nip _ = ] assoc-find
2drop swap pull-out-nth ; inline
: select-instruction ( -- insn/f ) : select-instruction ( -- insn/f )
roots get [ f ] [ roots get [ f ] [
@ -83,4 +77,5 @@ conditional-branch-insn
! TODO: stack effect should be ( cfg -- ) ! TODO: stack effect should be ( cfg -- )
: schedule-instructions ( cfg -- cfg' ) : schedule-instructions ( cfg -- cfg' )
dup number-instructions dup number-instructions
dup reverse-post-order [ kill-block?>> not ] filter [ schedule-block ] each ; dup reverse-post-order [ kill-block?>> not ] filter
[ schedule-block ] each ;