add branch splitting pass to compiler.cfg

db4
Doug Coleman 2009-06-30 15:31:48 -05:00
parent 1fab8efeee
commit ea072731d4
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1 @@
Doug Coleman

View File

@ -0,0 +1,29 @@
! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators.short-circuit compiler.cfg.def-use
compiler.cfg.rpo kernel math sequences ;
IN: compiler.cfg.branch-splitting
: split-branch ( branch -- )
[
[ instructions>> ] [ predecessors>> ] bi [
instructions>> [ pop* ] [ push-all ] bi
] with each
] [
[ successors>> ] [ predecessors>> ] bi [
[ drop clone ] change-successors drop
] with each
] bi ;
: split-branches? ( bb -- ? )
{
[ predecessors>> length 1 >= ]
[ successors>> length 1 <= ]
[ instructions>> [ defs-vregs ] any? not ]
[ instructions>> [ temp-vregs ] any? not ]
} 1&& ;
: split-branches ( cfg -- cfg' )
dup [
dup split-branches? [ split-branch ] [ drop ] if
] each-basic-block f >>post-order ;