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