1 ! Copyright (C) 2009, 2011 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs compiler.cfg.def-use compiler.cfg.dominance
4 compiler.cfg.instructions compiler.cfg.liveness
5 compiler.cfg.parallel-copy compiler.cfg.rpo compiler.cfg.ssa.cssa
6 compiler.cfg.ssa.destruction.coalescing compiler.cfg.ssa.destruction.leaders
7 compiler.cfg.ssa.interference.live-ranges compiler.cfg.utilities
8 kernel make sequences ;
9 FROM: namespaces => set ;
10 IN: compiler.cfg.ssa.destruction
14 GENERIC: cleanup-insn ( insn -- )
16 : useful-copy? ( insn -- ? )
17 [ dst>> ] [ src>> ] bi leaders = not ; inline
19 M: ##copy cleanup-insn
20 dup useful-copy? [ , ] [ drop ] if ;
22 M: ##parallel-copy cleanup-insn
23 values>> [ leaders ] assoc-map [ first2 = ] reject
26 M: ##tagged>integer cleanup-insn
27 dup useful-copy? [ , ] [ drop ] if ;
29 M: ##phi cleanup-insn drop ;
31 M: insn cleanup-insn , ;
33 : cleanup-cfg ( cfg -- )
34 [ [ [ cleanup-insn ] each ] V{ } make ] simple-optimization ;
38 : destruct-ssa ( cfg -- )