7 |
* graph of blocks. |
* graph of blocks. |
8 |
*) |
*) |
9 |
|
|
10 |
functor SSAFn (Op : OPERATORS) (*: SSA*) = |
signature SSA = |
11 |
|
sig |
12 |
|
|
13 |
|
structure Op : OPERATORS |
14 |
|
|
15 |
|
datatype program = Program of { |
16 |
|
globals : var list, |
17 |
|
globalInit : stmt, |
18 |
|
actors : actor list |
19 |
|
(* initialization *) |
20 |
|
} |
21 |
|
|
22 |
|
and actor = Actor of { |
23 |
|
name : Atom.atom, |
24 |
|
params : var list, |
25 |
|
state : var list, |
26 |
|
stateInit : stmt, |
27 |
|
methods : method list |
28 |
|
} |
29 |
|
|
30 |
|
and method = Method of Atom.atom * stmt |
31 |
|
|
32 |
|
and stmt = STM of { |
33 |
|
id : Stamp.stamp, |
34 |
|
props : PropList.holder, |
35 |
|
preds : stmt list ref, |
36 |
|
phis : (var * var list) list ref, (* phi statements *) |
37 |
|
kind : stmt_kind ref |
38 |
|
} |
39 |
|
|
40 |
|
and stmt_kind |
41 |
|
= BLOCK of { |
42 |
|
succ : stmt, |
43 |
|
body : assign list |
44 |
|
} |
45 |
|
| IF of { |
46 |
|
cond : var, |
47 |
|
thenBranch : stmt, |
48 |
|
elseBranch : stmt |
49 |
|
} |
50 |
|
| LOOP of { |
51 |
|
hdr : stmt, |
52 |
|
cond : var, |
53 |
|
body : stmt, |
54 |
|
exit : stmt |
55 |
|
} |
56 |
|
| NEW of { |
57 |
|
actor : Atom.atom, |
58 |
|
args : var list, |
59 |
|
succ : stmt |
60 |
|
} |
61 |
|
| DIE |
62 |
|
| STABILIZE |
63 |
|
| EXIT |
64 |
|
|
65 |
|
and rhs |
66 |
|
= VAR of var |
67 |
|
| LIT of Literal.literal |
68 |
|
| OP of Op.rator * var list |
69 |
|
| CONS of var list (* tensor-value construction *) |
70 |
|
|
71 |
|
and var = V of { |
72 |
|
name : string, (* name *) |
73 |
|
id : Stamp.stamp, (* unique ID *) |
74 |
|
useCnt : int ref, (* count of uses *) |
75 |
|
props : PropList.holder |
76 |
|
} |
77 |
|
|
78 |
|
withtype assign = (var * rhs) |
79 |
|
|
80 |
|
val same : stmt * stmt -> bool |
81 |
|
val compare : stmt * stmt -> order |
82 |
|
val hash : stmt -> word |
83 |
|
|
84 |
|
val succs : stmt -> stmt list |
85 |
|
|
86 |
|
(* set the successor of a statement *) |
87 |
|
val setSucc : stmt * stmt -> unit |
88 |
|
|
89 |
|
val preds : stmt -> stmt list |
90 |
|
|
91 |
|
val addPred : stmt * stmt -> unit |
92 |
|
|
93 |
|
val dummy : stmt |
94 |
|
|
95 |
|
val mkBLOCK : {succ : stmt, body : assign list} -> stmt |
96 |
|
val mkIF : {cond : var, thenBranch : stmt, elseBranch : stmt} -> stmt |
97 |
|
val mkLOOP : {hdr : stmt, cond : var, body : stmt, exit : stmt} -> stmt |
98 |
|
val mkNEW : {actor : Atom.atom, args : var list, succ : stmt} -> stmt |
99 |
|
val mkDIE : unit -> stmt |
100 |
|
val mkSTABILIZE : unit -> stmt |
101 |
|
val mkEXIT : unit -> stmt |
102 |
|
|
103 |
|
val newVar : string -> var |
104 |
|
|
105 |
|
end |
106 |
|
|
107 |
|
functor SSAFn (Op : OPERATORS) : SSA = |
108 |
struct |
struct |
109 |
|
|
110 |
structure Op = Op |
structure Op = Op |