]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/cfg/stack-analysis/merge/merge-tests.factor
db configurations factored out through db.info
[factor.git] / basis / compiler / cfg / stack-analysis / merge / merge-tests.factor
1 IN: compiler.cfg.stack-analysis.merge.tests
2 USING: compiler.cfg.stack-analysis.merge tools.test arrays accessors
3  compiler.cfg.instructions compiler.cfg.stack-analysis.state
4 compiler.cfg.utilities compiler.cfg compiler.cfg.registers
5 compiler.cfg.debugger cpu.architecture make assocs namespaces
6 sequences kernel classes ;
7
8 [
9     { D 0 }
10     { V int-regs 0 V int-regs 1 }
11 ] [
12     <state>
13
14     <basic-block> V{ T{ ##branch } } >>instructions dup 1 set
15     <basic-block> V{ T{ ##branch } } >>instructions dup 2 set 2array
16
17     <state> H{ { D 0 V int-regs 0 } } >>locs>vregs
18     <state> H{ { D 0 V int-regs 1 } } >>locs>vregs 2array
19
20     H{ } clone added-instructions set
21     V{ } clone added-phis set
22     merge-locs locs>vregs>> keys added-phis get values first
23 ] unit-test
24
25 [
26     { D 0 }
27     ##peek
28 ] [
29     <state>
30
31     <basic-block> V{ T{ ##branch } } >>instructions dup 1 set
32     <basic-block> V{ T{ ##branch } } >>instructions dup 2 set 2array
33
34     <state>
35     <state> H{ { D 0 V int-regs 1 } } >>locs>vregs 2array
36
37     H{ } clone added-instructions set
38     V{ } clone added-phis set
39     [ merge-locs locs>vregs>> keys ] { } make drop
40     1 get added-instructions get at first class
41 ] unit-test
42
43 [
44     0 ##inc-d
45 ] [
46     <state>
47
48     <basic-block> V{ T{ ##branch } } >>instructions dup 1 set
49     <basic-block> V{ T{ ##branch } } >>instructions dup 2 set 2array
50
51     H{ } clone added-instructions set
52     V{ } clone added-phis set
53
54     <state> -1 >>ds-height
55     <state> 2array
56
57     [ merge-ds-heights ds-height>> ] { } make drop
58     1 get added-instructions get at first class
59 ] unit-test
60
61 [
62     0
63     { D 0 }
64     { 1 1 }
65 ] [
66     <state>
67
68     <basic-block> V{ T{ ##branch } } >>instructions
69     <basic-block> V{ T{ ##branch } } >>instructions 2array
70
71     H{ } clone added-instructions set
72     V{ } clone added-phis set
73     
74     [
75         <state> -1 >>ds-height H{ { D 1 V int-regs 0 } } >>locs>vregs
76         <state> H{ { D 0 V int-regs 1 } } >>locs>vregs 2array
77
78         [ merge-locs [ ds-height>> ] [ locs>vregs>> keys ] bi ] { } make drop
79     ] keep
80     [ instructions>> length ] map
81 ] unit-test
82
83 [
84     -1
85     { D -1 }
86     { 1 1 }
87 ] [
88     <state>
89
90     <basic-block> V{ T{ ##branch } } >>instructions
91     <basic-block> V{ T{ ##branch } } >>instructions 2array
92
93     H{ } clone added-instructions set
94     V{ } clone added-phis set
95     
96     [
97         <state> -1 >>ds-height H{ { D -1 V int-regs 0 } } >>locs>vregs
98         <state> -1 >>ds-height H{ { D -1 V int-regs 1 } } >>locs>vregs 2array
99
100         [ [ merge-ds-heights ] [ merge-locs ] 2bi ] { } make drop
101         [ ds-height>> ] [ locs>vregs>> keys ] bi
102     ] keep
103     [ instructions>> length ] map
104 ] unit-test