]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/cfg/renaming/functor/functor.factor
compiler.cfg.ssa.construction: use the optimization from the pruned-SSA paper to...
[factor.git] / basis / compiler / cfg / renaming / functor / functor.factor
1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: functors assocs kernel accessors compiler.cfg.instructions
4 lexer parser ;
5 IN: compiler.cfg.renaming.functor
6
7 FUNCTOR: define-renaming ( NAME DEF-QUOT USE-QUOT -- )
8
9 rename-insn-defs DEFINES ${NAME}-insn-defs
10 rename-insn-uses DEFINES ${NAME}-insn-uses
11
12 WHERE
13
14 GENERIC: rename-insn-defs ( insn -- )
15
16 M: ##flushable rename-insn-defs
17     DEF-QUOT change-dst
18     drop ;
19
20 M: ##fixnum-overflow rename-insn-defs
21     DEF-QUOT change-dst
22     drop ;
23
24 M: _fixnum-overflow rename-insn-defs
25     DEF-QUOT change-dst
26     drop ;
27
28 M: insn rename-insn-defs drop ;
29
30 GENERIC: rename-insn-uses ( insn -- )
31
32 M: ##effect rename-insn-uses
33     USE-QUOT change-src
34     drop ;
35
36 M: ##unary rename-insn-uses
37     USE-QUOT change-src
38     drop ;
39
40 M: ##binary rename-insn-uses
41     USE-QUOT change-src1
42     USE-QUOT change-src2
43     drop ;
44
45 M: ##binary-imm rename-insn-uses
46     USE-QUOT change-src1
47     drop ;
48
49 M: ##slot rename-insn-uses
50     USE-QUOT change-obj
51     USE-QUOT change-slot
52     drop ;
53
54 M: ##slot-imm rename-insn-uses
55     USE-QUOT change-obj
56     drop ;
57
58 M: ##set-slot rename-insn-uses
59     dup call-next-method
60     USE-QUOT change-obj
61     USE-QUOT change-slot
62     drop ;
63
64 M: ##string-nth rename-insn-uses
65     USE-QUOT change-obj
66     USE-QUOT change-index
67     drop ;
68
69 M: ##set-string-nth-fast rename-insn-uses
70     dup call-next-method
71     USE-QUOT change-obj
72     USE-QUOT change-index
73     drop ;
74
75 M: ##set-slot-imm rename-insn-uses
76     dup call-next-method
77     USE-QUOT change-obj
78     drop ;
79
80 M: ##alien-getter rename-insn-uses
81     dup call-next-method
82     USE-QUOT change-src
83     drop ;
84
85 M: ##alien-setter rename-insn-uses
86     dup call-next-method
87     USE-QUOT change-value
88     drop ;
89
90 M: ##conditional-branch rename-insn-uses
91     USE-QUOT change-src1
92     USE-QUOT change-src2
93     drop ;
94
95 M: ##compare-imm-branch rename-insn-uses
96     USE-QUOT change-src1
97     drop ;
98
99 M: ##dispatch rename-insn-uses
100     USE-QUOT change-src
101     drop ;
102
103 M: ##fixnum-overflow rename-insn-uses
104     USE-QUOT change-src1
105     USE-QUOT change-src2
106     drop ;
107
108 M: ##phi rename-insn-uses
109     [ USE-QUOT assoc-map ] change-inputs
110     drop ;
111
112 M: insn rename-insn-uses drop ;
113
114 ;FUNCTOR
115
116 SYNTAX: RENAMING: scan scan-object scan-object define-renaming ;