! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
- USING: kernel combinators.short-circuit accessors math sequences sets
- assocs compiler.cfg.instructions compiler.cfg.rpo compiler.cfg.def-use
- compiler.cfg.linearization compiler.cfg.liveness
- compiler.cfg.utilities ;
+ USING: kernel compiler.cfg.instructions compiler.cfg.rpo
-compiler.cfg.def-use compiler.cfg.linearization
++compiler.cfg.def-use compiler.cfg.linearization compiler.cfg.utilities
+ combinators.short-circuit accessors math sequences sets assocs ;
IN: compiler.cfg.checker
-ERROR: last-insn-not-a-jump insn ;
+ERROR: bad-kill-block bb ;
+
+: check-kill-block ( bb -- )
+ dup instructions>> first2
+ swap ##epilogue? [ [ ##return? ] [ ##callback-return? ] bi or ] [ ##branch? ] if
+ [ drop ] [ bad-kill-block ] if ;
+
+ERROR: last-insn-not-a-jump bb ;
: check-last-instruction ( bb -- )
- last dup {
+ dup instructions>> last {
[ ##branch? ]
[ ##dispatch? ]
[ ##conditional-branch? ]
M: _compare-imm-branch uses-vregs src1>> 1array ;
M: _dispatch uses-vregs src>> 1array ;
M: insn uses-vregs drop f ;
-! Instructions that use vregs
-UNION: vreg-insn
-##flushable
-##write-barrier
-##dispatch
-##effect
-##fixnum-overflow
-##conditional-branch
-##compare-imm-branch
-##phi
-##gc
-_conditional-branch
-_compare-imm-branch
-_dispatch ;
-
+
+ : map-unique ( seq quot -- assoc )
+ map concat unique ; inline
+
+ : gen-set ( instructions -- seq )
+ [ uses-vregs ] map-unique ;
+
+ : kill-set ( instructions -- seq )
+ [ defs-vregs ] map-unique ;