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
7 : get-predecessors ( cfg -- assoc )
8 H{ } clone [ '[ [ predecessors>> ] keep _ set-at ] each-basic-block ] keep ;
10 : check-predecessors ( cfg -- )
12 [ needs-predecessors ]
13 [ get-predecessors ] tri assert= ;
15 : check-branch-splitting ( cfg -- )
16 [ needs-predecessors ] [ split-branches ] [ check-predecessors ] tri ;
18 : test-branch-splitting ( -- )
19 0 get block>cfg check-branch-splitting ;
21 V{ T{ ##branch } } 0 test-bb
23 V{ T{ ##branch } } 1 test-bb
25 V{ T{ ##branch } } 2 test-bb
27 V{ T{ ##branch } } 3 test-bb
29 V{ T{ ##branch } } 4 test-bb
33 { } [ test-branch-splitting ] unit-test
35 V{ T{ ##branch } } 0 test-bb
37 V{ T{ ##branch } } 1 test-bb
39 V{ T{ ##branch } } 2 test-bb
41 V{ T{ ##branch } } 3 test-bb
43 V{ T{ ##branch } } 4 test-bb
45 V{ T{ ##branch } } 5 test-bb
53 { } [ test-branch-splitting ] unit-test
55 V{ T{ ##branch } } 0 test-bb
57 V{ T{ ##branch } } 1 test-bb
59 V{ T{ ##branch } } 2 test-bb
61 V{ T{ ##branch } } 3 test-bb
63 V{ T{ ##branch } } 4 test-bb
71 { } [ test-branch-splitting ] unit-test
73 V{ T{ ##branch } } 0 test-bb
75 V{ T{ ##branch } } 1 test-bb
77 V{ T{ ##branch } } 2 test-bb
83 { } [ test-branch-splitting ] unit-test