]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/cfg/dominance/dominance-tests.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / basis / compiler / cfg / dominance / dominance-tests.factor
1 IN: compiler.cfg.dominance.tests
2 USING: tools.test sequences vectors namespaces kernel accessors assocs sets
3 math.ranges arrays compiler.cfg compiler.cfg.dominance compiler.cfg.debugger
4 compiler.cfg.predecessors ;
5
6 : test-dominance ( -- )
7     cfg new 0 get >>entry
8     compute-predecessors
9     compute-dominance
10     drop ;
11
12 ! Example with no back edges
13 V{ } 0 test-bb
14 V{ } 1 test-bb
15 V{ } 2 test-bb
16 V{ } 3 test-bb
17 V{ } 4 test-bb
18 V{ } 5 test-bb
19
20 0 get 1 get 2 get V{ } 2sequence >>successors drop
21 1 get 3 get 1vector >>successors drop
22 2 get 4 get 1vector >>successors drop
23 3 get 4 get 1vector >>successors drop
24 4 get 5 get 1vector >>successors drop
25
26 [ ] [ test-dominance ] unit-test
27
28 [ t ] [ 0 get dom-parent 0 get eq? ] unit-test
29 [ t ] [ 1 get dom-parent 0 get eq? ] unit-test
30 [ t ] [ 2 get dom-parent 0 get eq? ] unit-test
31 [ t ] [ 4 get dom-parent 0 get eq? ] unit-test
32 [ t ] [ 3 get dom-parent 1 get eq? ] unit-test
33 [ t ] [ 5 get dom-parent 4 get eq? ] unit-test
34
35 [ t ] [ 0 get dom-children 1 get 2 get 4 get 3array set= ] unit-test
36
37 [ { 4 } ] [ 1 get dom-frontier [ number>> ] map ] unit-test
38 [ { 4 } ] [ 2 get dom-frontier [ number>> ] map ] unit-test
39 [ f ] [ 0 get dom-frontier ] unit-test
40 [ f ] [ 4 get dom-frontier ] unit-test
41
42 ! Example from the paper
43 V{ } 0 test-bb
44 V{ } 1 test-bb
45 V{ } 2 test-bb
46 V{ } 3 test-bb
47 V{ } 4 test-bb
48
49 0 get 1 get 2 get V{ } 2sequence >>successors drop
50 1 get 3 get 1vector >>successors drop
51 2 get 4 get 1vector >>successors drop
52 3 get 4 get 1vector >>successors drop
53 4 get 3 get 1vector >>successors drop
54
55 [ ] [ test-dominance ] unit-test
56
57 [ t ] [ 0 4 [a,b] [ get dom-parent 0 get eq? ] all? ] unit-test
58
59 ! The other example from the paper
60 V{ } 0 test-bb
61 V{ } 1 test-bb
62 V{ } 2 test-bb
63 V{ } 3 test-bb
64 V{ } 4 test-bb
65 V{ } 5 test-bb
66
67 0 get 1 get 2 get V{ } 2sequence >>successors drop
68 1 get 5 get 1vector >>successors drop
69 2 get 4 get 3 get V{ } 2sequence >>successors drop
70 5 get 4 get 1vector >>successors drop
71 4 get 5 get 3 get V{ } 2sequence >>successors drop
72 3 get 4 get 1vector >>successors drop
73
74 [ ] [ test-dominance ] unit-test
75
76 [ t ] [ 0 5 [a,b] [ get dom-parent 0 get eq? ] all? ] unit-test