source: project/release/4/graph-ssa/trunk/ssa-eggdoc.scm @ 14375

Last change on this file since 14375 was 14375, checked in by Ivan Raikov, 11 years ago

graph-ssa ported to Chicken 4

File size: 3.9 KB
Line 
1
2
3(use eggdoc)
4
5(define doc
6  `((eggdoc:begin
7     (name "graph-ssa")
8     (description "Compute static single assignment form of a graph.")
9     (author (p "Richard Kelsey; ported to Chicken by " 
10                (url "http://chicken.wiki.br/ivan raikov" "Ivan Raikov")))
11
12     (history 
13      (version "1.2" "Ported to Chicken 4")
14      (version "1.0" "Initial release"))
15
16     (requires (url "graph-dominators.html" "graph-dominators")
17               (url "matchable.html" "matchable"))
18
19     (download "graph-ssa.egg")
20
21     (usage "(require-extension graph-ssa)")
22
23     (documentation
24     
25      (p "This code is based on the algorithm from " 
26         (i "Efficiently computing static single assignment form and the control dependence graph") ", "
27         "ACM Transactions on Programming Languages and Systems 1991 13(4), pp. 451-490. ")
28
29      (subsection "Procedures"
30
31      (procedure "graph->ssa-graph:: G -> SSA-GRAPH"
32                 
33                 (p  "Computes the dominance frontiers of the nodes in the graph, and returns "
34                     "the list of nodes augmented with this information. "))
35
36      (procedure "graph-ssa-find-joins:: SSA-GRAPH -> NODES"
37                 
38                 (p "Given a list of SSA nodes, returns the list of nodes " (tt "N")
39                    " for which there are (at least) two paths " (tt "... N_0 M_0 ... M_i N")
40                    " and " (tt " ... N_1 P_0 ... P_j N") " such that " (tt "N_0") " and " 
41                    (tt "N_1") " are distinct members of " (tt "NODES") 
42                    " and the M's and P's are disjoint sets.")))
43
44
45     (examples (pre #<<EOF
46
47(require-extension srfi-1)
48(require-extension digraph)
49(require-extension graph-dominators)
50
51(define used-by '((a . b) (b . c) (c . d) (c . b) (b . e) (d . d) (d . e) ))
52
53(define g (make-digraph 'cfg "control flow graph"))
54
55(define node-list (delete-duplicates 
56                   (concatenate (list (map car used-by) (map cdr used-by)))))
57
58(define node-ids (list-tabulate (length node-list) values))
59 
60(for-each (lambda (i n) ((g 'add-node!) i (list #f n))) node-ids node-list)
61(define node-map (zip node-list node-ids))
62
63(for-each (lambda (e) 
64            (match e ((ni . nj) (let ((i (car (alist-ref ni node-map)))
65                                      (j (car (alist-ref nj node-map))))
66                                  ((g 'add-edge!) (list i j (format "~A->~A" ni nj)))))
67                   (else (error "invalid edge " e))))
68          used-by)
69
70(define ssa-graph (graph->ssa-graph g))
71(graph-ssa-find-joins ssa-graph)
72
73
74EOF
75))
76     (license
77      "Copyright (c) 1993-1999 by Richard Kelsey. 
78
79   Ported to Chicken Scheme by Ivan Raikov.
80
81   Redistribution and use in source and binary forms, with or without
82   modification, are permitted provided that the following conditions
83   are met:
84   
85     1. Redistributions of source code must retain the above copyright
86        notice, this list of conditions and the following disclaimer.
87
88     2. Redistributions in binary form must reproduce the above copyright
89        notice, this list of conditions and the following disclaimer in the
90        documentation and/or other materials provided with the distribution.
91
92     3. The names of its contributors may not be used to endorse or promote
93        products derived from this software without specific prior written
94        permission.
95
96   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
97   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
98   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
99   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
100   OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
101   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
102   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
103   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
104   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
105   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
106   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
107)))))
108
109(if (eggdoc->html doc) (void))
Note: See TracBrowser for help on using the repository browser.