compiler.cfg.predecessors: delete dead predecessors from phi nodes
parent
92b7f32aaa
commit
2c3b2a0b71
|
@ -1,8 +1,8 @@
|
||||||
IN: compiler.cfg.branch-folding.tests
|
IN: compiler.cfg.branch-folding.tests
|
||||||
USING: compiler.cfg.branch-folding compiler.cfg.instructions
|
USING: compiler.cfg.branch-folding compiler.cfg.instructions
|
||||||
compiler.cfg compiler.cfg.registers compiler.cfg.debugger
|
compiler.cfg compiler.cfg.registers compiler.cfg.debugger
|
||||||
arrays compiler.cfg.phi-elimination
|
arrays compiler.cfg.phi-elimination compiler.cfg.dce
|
||||||
compiler.cfg.predecessors kernel accessors
|
compiler.cfg.predecessors kernel accessors assocs
|
||||||
sequences classes namespaces tools.test cpu.architecture ;
|
sequences classes namespaces tools.test cpu.architecture ;
|
||||||
|
|
||||||
V{ T{ ##branch } } 0 test-bb
|
V{ T{ ##branch } } 0 test-bb
|
||||||
|
@ -41,4 +41,45 @@ test-diamond
|
||||||
[ t ] [ 1 get successors>> first 3 get eq? ] unit-test
|
[ t ] [ 1 get successors>> first 3 get eq? ] unit-test
|
||||||
|
|
||||||
[ T{ ##copy f V int-regs 3 V int-regs 2 } ] [ 3 get instructions>> second ] unit-test
|
[ T{ ##copy f V int-regs 3 V int-regs 2 } ] [ 3 get instructions>> second ] unit-test
|
||||||
[ 2 ] [ 4 get instructions>> length ] unit-test
|
[ 2 ] [ 4 get instructions>> length ] unit-test
|
||||||
|
|
||||||
|
V{
|
||||||
|
T{ ##peek f V int-regs 0 D 0 }
|
||||||
|
T{ ##branch }
|
||||||
|
} 0 test-bb
|
||||||
|
|
||||||
|
V{
|
||||||
|
T{ ##peek f V int-regs 1 D 1 }
|
||||||
|
T{ ##compare-branch f V int-regs 1 V int-regs 1 cc< }
|
||||||
|
} 1 test-bb
|
||||||
|
|
||||||
|
V{
|
||||||
|
T{ ##copy f V int-regs 2 V int-regs 0 }
|
||||||
|
T{ ##branch }
|
||||||
|
} 2 test-bb
|
||||||
|
|
||||||
|
V{
|
||||||
|
T{ ##phi f V int-regs 3 V{ } }
|
||||||
|
T{ ##branch }
|
||||||
|
} 3 test-bb
|
||||||
|
|
||||||
|
V{
|
||||||
|
T{ ##replace f V int-regs 3 D 0 }
|
||||||
|
T{ ##return }
|
||||||
|
} 4 test-bb
|
||||||
|
|
||||||
|
1 get V int-regs 1 2array
|
||||||
|
2 get V int-regs 0 2array 2array 3 get instructions>> first (>>inputs)
|
||||||
|
|
||||||
|
test-diamond
|
||||||
|
|
||||||
|
[ ] [
|
||||||
|
cfg new 0 get >>entry
|
||||||
|
compute-predecessors
|
||||||
|
fold-branches
|
||||||
|
compute-predecessors
|
||||||
|
eliminate-dead-code
|
||||||
|
drop
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[ 1 ] [ 3 get instructions>> first inputs>> assoc-size ] unit-test
|
|
@ -1,17 +1,13 @@
|
||||||
! Copyright (C) 2009 Slava Pestov.
|
! Copyright (C) 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors kernel sequences assocs
|
USING: accessors kernel sequences assocs
|
||||||
cpu.architecture compiler.cfg.rpo
|
compiler.cfg.rpo compiler.cfg.instructions
|
||||||
compiler.cfg.liveness compiler.cfg.instructions
|
|
||||||
compiler.cfg.hats ;
|
compiler.cfg.hats ;
|
||||||
IN: compiler.cfg.gc-checks
|
IN: compiler.cfg.gc-checks
|
||||||
|
|
||||||
: gc? ( bb -- ? )
|
: gc? ( bb -- ? )
|
||||||
instructions>> [ ##allocation? ] any? ;
|
instructions>> [ ##allocation? ] any? ;
|
||||||
|
|
||||||
: object-pointer-regs ( basic-block -- vregs )
|
|
||||||
live-in keys [ reg-class>> int-regs eq? ] filter ;
|
|
||||||
|
|
||||||
: insert-gc-check ( basic-block -- )
|
: insert-gc-check ( basic-block -- )
|
||||||
dup gc? [
|
dup gc? [
|
||||||
[ i i f f \ ##gc new-insn prefix ] change-instructions drop
|
[ i i f f \ ##gc new-insn prefix ] change-instructions drop
|
||||||
|
|
|
@ -1,13 +1,27 @@
|
||||||
! Copyright (C) 2008, 2009 Slava Pestov.
|
! Copyright (C) 2008, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel accessors sequences compiler.cfg.rpo ;
|
USING: kernel accessors combinators fry sequences assocs compiler.cfg.rpo
|
||||||
|
compiler.cfg.instructions ;
|
||||||
IN: compiler.cfg.predecessors
|
IN: compiler.cfg.predecessors
|
||||||
|
|
||||||
: predecessors-step ( bb -- )
|
: update-predecessors ( bb -- )
|
||||||
dup successors>> [ predecessors>> push ] with each ;
|
dup successors>> [ predecessors>> push ] with each ;
|
||||||
|
|
||||||
|
: update-phi ( bb ##phi -- )
|
||||||
|
[
|
||||||
|
swap predecessors>>
|
||||||
|
'[ drop _ memq? ] assoc-filter
|
||||||
|
] change-inputs drop ;
|
||||||
|
|
||||||
|
: update-phis ( bb -- )
|
||||||
|
dup instructions>> [
|
||||||
|
dup ##phi? [ update-phi ] [ 2drop ] if
|
||||||
|
] with each ;
|
||||||
|
|
||||||
: compute-predecessors ( cfg -- cfg' )
|
: compute-predecessors ( cfg -- cfg' )
|
||||||
[ [ V{ } clone >>predecessors drop ] each-basic-block ]
|
{
|
||||||
[ [ predecessors-step ] each-basic-block ]
|
[ [ V{ } clone >>predecessors drop ] each-basic-block ]
|
||||||
[ ]
|
[ [ update-predecessors ] each-basic-block ]
|
||||||
tri ;
|
[ [ update-phis ] each-basic-block ]
|
||||||
|
[ ]
|
||||||
|
} cleave ;
|
||||||
|
|
Loading…
Reference in New Issue