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
6 : get-predecessors ( cfg -- assoc )
7 H{ } clone [ '[ [ predecessors>> ] keep _ set-at ] each-basic-block ] keep ;
9 : check-predecessors ( cfg -- )
11 [ needs-predecessors ]
12 [ get-predecessors ] tri assert= ;
14 : check-branch-splitting ( cfg -- )
15 [ needs-predecessors ] [ split-branches ] [ check-predecessors ] tri ;
17 : test-branch-splitting ( -- )
18 0 get block>cfg check-branch-splitting ;
20 V{ T{ ##branch } } 0 test-bb
22 V{ T{ ##branch } } 1 test-bb
24 V{ T{ ##branch } } 2 test-bb
26 V{ T{ ##branch } } 3 test-bb
28 V{ T{ ##branch } } 4 test-bb
32 { } [ test-branch-splitting ] unit-test
34 V{ T{ ##branch } } 0 test-bb
36 V{ T{ ##branch } } 1 test-bb
38 V{ T{ ##branch } } 2 test-bb
40 V{ T{ ##branch } } 3 test-bb
42 V{ T{ ##branch } } 4 test-bb
44 V{ T{ ##branch } } 5 test-bb
52 { } [ test-branch-splitting ] unit-test
54 V{ T{ ##branch } } 0 test-bb
56 V{ T{ ##branch } } 1 test-bb
58 V{ T{ ##branch } } 2 test-bb
60 V{ T{ ##branch } } 3 test-bb
62 V{ T{ ##branch } } 4 test-bb
70 { } [ test-branch-splitting ] unit-test
72 V{ T{ ##branch } } 0 test-bb
74 V{ T{ ##branch } } 1 test-bb
76 V{ T{ ##branch } } 2 test-bb
82 { } [ test-branch-splitting ] unit-test