]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/cfg/branch-splitting/branch-splitting-tests.factor
factor: trim more using lists.
[factor.git] / basis / compiler / cfg / branch-splitting / branch-splitting-tests.factor
1 USING: accessors assocs compiler.cfg.branch-splitting
2 compiler.cfg.instructions compiler.cfg.predecessors compiler.cfg.rpo
3 compiler.cfg.utilities compiler.test kernel namespaces tools.test ;
4 IN: compiler.cfg.branch-splitting.tests
5
6 : get-predecessors ( cfg -- assoc )
7     H{ } clone [ '[ [ predecessors>> ] keep _ set-at ] each-basic-block ] keep ;
8
9 : check-predecessors ( cfg -- )
10     [ get-predecessors ]
11     [ needs-predecessors ]
12     [ get-predecessors ] tri assert= ;
13
14 : check-branch-splitting ( cfg -- )
15     [ needs-predecessors ] [ split-branches ] [ check-predecessors ] tri ;
16
17 : test-branch-splitting ( -- )
18     0 get block>cfg check-branch-splitting ;
19
20 V{ T{ ##branch } } 0 test-bb
21
22 V{ T{ ##branch } } 1 test-bb
23
24 V{ T{ ##branch } } 2 test-bb
25
26 V{ T{ ##branch } } 3 test-bb
27
28 V{ T{ ##branch } } 4 test-bb
29
30 test-diamond
31
32 { } [ test-branch-splitting ] unit-test
33
34 V{ T{ ##branch } } 0 test-bb
35
36 V{ T{ ##branch } } 1 test-bb
37
38 V{ T{ ##branch } } 2 test-bb
39
40 V{ T{ ##branch } } 3 test-bb
41
42 V{ T{ ##branch } } 4 test-bb
43
44 V{ T{ ##branch } } 5 test-bb
45
46 0 { 1 2 } edges
47
48 1 { 3 4 } edges
49
50 2 { 3 4 } edges
51
52 { } [ test-branch-splitting ] unit-test
53
54 V{ T{ ##branch } } 0 test-bb
55
56 V{ T{ ##branch } } 1 test-bb
57
58 V{ T{ ##branch } } 2 test-bb
59
60 V{ T{ ##branch } } 3 test-bb
61
62 V{ T{ ##branch } } 4 test-bb
63
64 0 { 1 2 } edges
65
66 1 { 3 4 } edges
67
68 2 4 edge
69
70 { } [ test-branch-splitting ] unit-test
71
72 V{ T{ ##branch } } 0 test-bb
73
74 V{ T{ ##branch } } 1 test-bb
75
76 V{ T{ ##branch } } 2 test-bb
77
78 0 { 1 2 } edges
79
80 1 2 edge
81
82 { } [ test-branch-splitting ] unit-test