1 | # SSA IR
|
2 |
|
3 | ## Usage
|
4 |
|
5 | ```javascript
|
6 | var ssa = require('ssa-ir');
|
7 |
|
8 | var cfg = ssa.parse(function() {/*
|
9 | block B1 -> B2, B3
|
10 | arg1 = instr1 %literal1, %literal2
|
11 | id2 = instr2 arg1
|
12 | block B2
|
13 | ret id2
|
14 | block B3
|
15 | ret arg1
|
16 | */});
|
17 |
|
18 | console.log(cfg);
|
19 | /*
|
20 | [ { id: 'B1',
|
21 | instructions:
|
22 | [ { id: 'arg1',
|
23 | type: 'instr1',
|
24 | inputs: [ { type: 'js', value: 'literal1' }, { type: 'js', value: 42 } ] },
|
25 | { id: 'id2',
|
26 | type: 'instr2',
|
27 | inputs: [ { type: 'instruction', id: 'arg1' } ] } ],
|
28 | successors: [ 'B2', 'B3' ] },
|
29 | { id: 'B2',
|
30 | instructions:
|
31 | [ { id: null,
|
32 | type: 'ret',
|
33 | inputs: [ { type: 'instruction', id: 'id2' } ] } ],
|
34 | successors: [] },
|
35 | { id: 'B3',
|
36 | instructions:
|
37 | [ { id: null,
|
38 | type: 'ret',
|
39 | inputs: [ { type: 'instruction', id: 'arg1' } ] } ],
|
40 | successors: [] } ]
|
41 | */
|
42 |
|
43 | console.log(ssa.stringify(cfg));
|
44 | /*
|
45 | block B1 -> B2, B3
|
46 | instr1 %"literal1", %42
|
47 | instr2 arg1
|
48 | block B2
|
49 | ret id2
|
50 | block B3
|
51 | ret arg1
|
52 | */
|
53 | ```
|
54 |
|
55 | #### LICENSE
|
56 |
|
57 | This software is licensed under the MIT License.
|
58 |
|
59 | Copyright Fedor Indutny, 2014.
|
60 |
|
61 | Permission is hereby granted, free of charge, to any person obtaining a
|
62 | copy of this software and associated documentation files (the
|
63 | "Software"), to deal in the Software without restriction, including
|
64 | without limitation the rights to use, copy, modify, merge, publish,
|
65 | distribute, sublicense, and/or sell copies of the Software, and to permit
|
66 | persons to whom the Software is furnished to do so, subject to the
|
67 | following conditions:
|
68 |
|
69 | The above copyright notice and this permission notice shall be included
|
70 | in all copies or substantial portions of the Software.
|
71 |
|
72 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
73 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
74 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
75 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
76 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
77 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
78 | USE OR OTHER DEALINGS IN THE SOFTWARE.
|
79 |
|
80 | [0]: http://en.wikipedia.org/wiki/Static_single_assignment_form
|