UNPKG

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