Remove old local DCE pass
parent
ce25e0ad8d
commit
2025823ba6
|
@ -1,9 +0,0 @@
|
||||||
USING: compiler.cfg.dead-code compiler.cfg.instructions
|
|
||||||
compiler.cfg.registers compiler.cfg.debugger
|
|
||||||
cpu.architecture tools.test ;
|
|
||||||
IN: compiler.cfg.dead-code.tests
|
|
||||||
|
|
||||||
[ { } ] [
|
|
||||||
{ T{ ##load-immediate f V int-regs 134 16 } }
|
|
||||||
eliminate-dead-code
|
|
||||||
] unit-test
|
|
|
@ -1,61 +0,0 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
|
||||||
USING: accessors assocs sets kernel namespaces sequences
|
|
||||||
compiler.cfg.instructions compiler.cfg.def-use ;
|
|
||||||
IN: compiler.cfg.dead-code
|
|
||||||
|
|
||||||
! Dead code elimination -- assumes compiler.cfg.alias-analysis
|
|
||||||
! has already run.
|
|
||||||
|
|
||||||
! Maps vregs to sequences of vregs
|
|
||||||
SYMBOL: liveness-graph
|
|
||||||
|
|
||||||
! vregs which participate in side effects and thus are always live
|
|
||||||
SYMBOL: live-vregs
|
|
||||||
|
|
||||||
! mapping vregs to stack locations
|
|
||||||
SYMBOL: vregs>locs
|
|
||||||
|
|
||||||
: init-dead-code ( -- )
|
|
||||||
H{ } clone liveness-graph set
|
|
||||||
H{ } clone live-vregs set
|
|
||||||
H{ } clone vregs>locs set ;
|
|
||||||
|
|
||||||
GENERIC: compute-liveness ( insn -- )
|
|
||||||
|
|
||||||
M: ##flushable compute-liveness
|
|
||||||
[ uses-vregs ] [ dst>> ] bi liveness-graph get set-at ;
|
|
||||||
|
|
||||||
M: ##peek compute-liveness
|
|
||||||
[ [ loc>> ] [ dst>> ] bi vregs>locs get set-at ]
|
|
||||||
[ call-next-method ]
|
|
||||||
bi ;
|
|
||||||
|
|
||||||
: live-replace? ( ##replace -- ? )
|
|
||||||
[ src>> vregs>locs get at ] [ loc>> ] bi = not ;
|
|
||||||
|
|
||||||
M: ##replace compute-liveness
|
|
||||||
dup live-replace? [ call-next-method ] [ drop ] if ;
|
|
||||||
|
|
||||||
: record-live ( vregs -- )
|
|
||||||
[
|
|
||||||
dup live-vregs get key? [ drop ] [
|
|
||||||
[ live-vregs get conjoin ]
|
|
||||||
[ liveness-graph get at record-live ]
|
|
||||||
bi
|
|
||||||
] if
|
|
||||||
] each ;
|
|
||||||
|
|
||||||
M: insn compute-liveness uses-vregs record-live ;
|
|
||||||
|
|
||||||
GENERIC: live-insn? ( insn -- ? )
|
|
||||||
|
|
||||||
M: ##flushable live-insn? dst>> live-vregs get key? ;
|
|
||||||
|
|
||||||
M: ##replace live-insn? live-replace? ;
|
|
||||||
|
|
||||||
M: insn live-insn? drop t ;
|
|
||||||
|
|
||||||
: eliminate-dead-code ( insns -- insns' )
|
|
||||||
init-dead-code
|
|
||||||
[ [ compute-liveness ] each ] [ [ live-insn? ] filter ] bi ;
|
|
|
@ -1 +0,0 @@
|
||||||
Dead-code elimination
|
|
Loading…
Reference in New Issue