## graph-ssa

Compute static single assignment form of a graph.

## TOC »

## Usage

(require-extension graph-ssa)

## Documentation

This code is based on the algorithm from *Efficiently computing static single assignment form and the control dependence graph*, ACM Transactions on Programming Languages and Systems 1991 13(4), pp. 451-490.

### Procedures

`graph->ssa-graph:`procedureComputes the dominance frontiers of the nodes in the graph, and returns the list of nodes augmented with this information.

`graph-ssa-find-joins:`procedureGiven a list of SSA nodes, returns the list of nodes

`N`for which there are (at least) two paths`... N_0 M_0 ... M_i N`and`... N_1 P_0 ... P_j N`such that`N_0`and`N_1`are distinct members of`NODES`and the M's and P's are disjoint sets.

## Examples

(require-extension srfi-1) (require-extension digraph) (require-extension graph-dominators) (define used-by '((a . b) (b . c) (c . d) (c . b) (b . e) (d . d) (d . e) )) (define g (make-digraph 'cfg "control flow graph")) (define node-list (delete-duplicates (concatenate (list (map car used-by) (map cdr used-by))))) (define node-ids (list-tabulate (length node-list) values)) (for-each (lambda (i n) ((g 'add-node!) i (list #f n))) node-ids node-list) (define node-map (zip node-list node-ids)) (for-each (lambda (e) (match e ((ni . nj) (let ((i (car (alist-ref ni node-map))) (j (car (alist-ref nj node-map)))) ((g 'add-edge!) (list i j (format "~A->~A" ni nj))))) (else (error "invalid edge " e)))) used-by) (define ssa-graph (graph->ssa-graph g)) (graph-ssa-find-joins ssa-graph)

## About this egg

### Author

Richard Kelsey; ported to Chicken by Ivan Raikov

### Version history

- 1.3
- Documentation converted to wiki format
- 1.2
- Ported to Chicken 4
- 1.0
- Initial release

### License

Copyright by Richard Kelsey. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.