((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/graph-ssa" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.") (tags "egg")) (section 2 "graph-ssa" (p "Compute static single assignment form of a graph.") (toc)) (section 2 "Usage" (p "(require-extension graph-ssa)")) (section 2 "Documentation" (p "This code is based on the algorithm from " (i "Efficiently computing static single assignment form and the control dependence graph") ", ACM Transactions on Programming Languages and Systems 1991 13(4), pp. 451-490.") (section 3 "Procedures" (def (sig (procedure "graph->ssa-graph:: G -> SSA-GRAPH" (id graph->ssa-graph))) (p "Computes the dominance frontiers of the nodes in the graph, and returns the list of nodes augmented with this information.")) (def (sig (procedure "graph-ssa-find-joins:: SSA-GRAPH -> NODES" (id graph-ssa-find-joins))) (p "Given a list of SSA nodes, returns the list of nodes " (tt "N") " for which there are (at least) two paths " (tt "... N_0 M_0 ... M_i N") " and " (tt " ... N_1 P_0 ... P_j N") " such that " (tt "N_0") " and " (tt "N_1") " are distinct members of " (tt "NODES") " and the M's and P's are disjoint sets.")))) (section 2 "Examples" (pre "\n(require-extension srfi-1)\n(require-extension digraph)\n(require-extension graph-dominators)\n\n(define used-by '((a . b) (b . c) (c . d) (c . b) (b . e) (d . d) (d . e) ))\n\n(define g (make-digraph 'cfg \"control flow graph\"))\n\n(define node-list (delete-duplicates \n\t\t   (concatenate (list (map car used-by) (map cdr used-by)))))\n\n(define node-ids (list-tabulate (length node-list) values))\n \n(for-each (lambda (i n) ((g 'add-node!) i (list #f n))) node-ids node-list)\n(define node-map (zip node-list node-ids))\n\n(for-each (lambda (e) \n\t    (match e ((ni . nj) (let ((i (car (alist-ref ni node-map)))\n\t\t\t\t      (j (car (alist-ref nj node-map))))\n\t\t\t\t  ((g 'add-edge!) (list i j (format \"~A->~A\" ni nj)))))\n\t\t   (else (error \"invalid edge \" e))))\n\t  used-by)\n\n(define ssa-graph (graph->ssa-graph g))\n(graph-ssa-find-joins ssa-graph)\n\n")) (section 2 "About this egg" (section 3 "Author" (p "Richard Kelsey; ported to Chicken by " (int-link "/users/ivan raikov" "Ivan Raikov"))) (section 3 "Version history" (dl (dt "1.3") (dd "Documentation converted to wiki format") (dt "1.2") (dd "Ported to Chicken 4") (dt "1.0") (dd "Initial release"))) (section 3 "License" (pre "Copyright by Richard Kelsey.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n- Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\n- Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following\ndisclaimer in the documentation and/or other materials provided\nwith the distribution.\n\n- Neither name of the copyright holders nor the names of its\ncontributors may be used to endorse or promote products derived\nfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND THE\nCONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES,\nINCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR THE\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\nUSE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\nAND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\nANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE."))))