]> gitweb.factorcode.org Git - factor.git/blob - extra/compiler/cfg/gvn/slots/slots.factor
afd2ab89e5f70f68adac02743de96ab1665d19d3
[factor.git] / extra / compiler / cfg / gvn / slots / slots.factor
1 ! Copyright (C) 2010 Slava Pestov, 2011 Alex Vondrak.
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.avail
8 compiler.cfg.gvn.rewrite ;
9 IN: compiler.cfg.gvn.slots
10
11 : simplify-slot-addressing? ( insn -- ? )
12     complex-addressing? [
13         slot>> vreg>insn [ ##add-imm? ] with-available-uses?
14     ] [ drop f ] if ;
15
16 : simplify-slot-addressing ( insn -- insn/f )
17     dup simplify-slot-addressing? [
18         clone dup slot>> vreg>insn
19         [ src1>> >>slot ]
20         [ src2>> over scale>> '[ _ _ shift - ] change-tag ]
21         bi
22     ] [ drop f ] if ;
23
24 M: ##slot rewrite simplify-slot-addressing ;
25 M: ##set-slot rewrite simplify-slot-addressing ;
26 M: ##write-barrier rewrite simplify-slot-addressing ;