]> gitweb.factorcode.org Git - factor.git/blob - extra/compiler/cfg/gvn/slots/slots.factor
compiler.cfg.gvn.slots: make simplify-slot-addressing non-destructive
[factor.git] / extra / compiler / cfg / gvn / slots / slots.factor
1 ! Copyright (C) 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors combinators.short-circuit cpu.architecture fry
4 kernel math
5 compiler.cfg.instructions
6 compiler.cfg.gvn.graph
7 compiler.cfg.gvn.rewrite ;
8 IN: compiler.cfg.gvn.slots
9
10 : simplify-slot-addressing? ( insn -- ? )
11     complex-addressing?
12     [ slot>> vreg>insn ##add-imm? ] [ drop f ] if ;
13
14 : simplify-slot-addressing ( insn -- insn/f )
15     dup simplify-slot-addressing? [
16         clone dup slot>> vreg>insn
17         [ src1>> >>slot ]
18         [ src2>> over scale>> '[ _ _ shift - ] change-tag ]
19         bi
20     ] [ drop f ] if ;
21
22 M: ##slot rewrite simplify-slot-addressing ;
23 M: ##set-slot rewrite simplify-slot-addressing ;
24 M: ##write-barrier rewrite simplify-slot-addressing ;