1 (* Copyright (C) 2009,2017 Matthew Fluet.
2 * Copyright (C) 1999-2008 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 * Copyright (C) 1997-2000 NEC Research Institute.
6 * MLton is released under a BSD-style license.
7 * See the file MLton-LICENSE for details.
10 signature SSA_TREE2_STRUCTS =
17 include SSA_TREE2_STRUCTS
23 val allAreImmutable: 'a t -> bool
24 val allAreMutable: 'a t -> bool
25 val dest: 'a t -> {elt: 'a, isMutable: bool} vector
26 val elt: 'a t * int -> 'a
27 val empty: unit -> 'a t
28 val fold: 'a t * 'b * ('a * 'b -> 'b) -> 'b
29 val foreach: 'a t * ('a -> unit) -> unit
30 val isEmpty: 'a t -> bool
31 val keepAllMap: 'a t * ('a -> 'b option) -> 'b t
32 val layout: 'a t * ('a -> Layout.t) -> Layout.t
33 val length: 'a t -> int
34 val make: {elt: 'a, isMutable: bool} vector -> 'a t
35 val map: 'a t * ('a -> 'b) -> 'b t
36 val someIsImmutable: 'a t -> bool
37 val someIsMutable: 'a t -> bool
38 val sub: 'a t * int -> {elt: 'a, isMutable: bool}
48 val isVector: t -> bool
49 val layout: t -> Layout.t
60 | Object of {args: t Prod.t,
69 val conApp: Con.t * t Prod.t -> t
70 val checkPrimApp: {args: t vector,
74 val datatypee: Tycon.t -> t
77 val deVectorOpt: t -> t Prod.t option
78 val equals: t * t -> bool
80 val isVector: t -> bool
82 val layout: t -> Layout.t
83 val object: {args: t Prod.t, con: ObjectCon.t} -> t
84 val ofConst: Const.t -> t
85 val plist: t -> PropertyList.t
86 val real: RealSize.t -> t
89 val tuple: t Prod.t -> t
90 val vector: t Prod.t -> t
93 val word: WordSize.t -> t
101 | VectorSub of {index: 'a,
104 val foreach: 'a t * ('a -> unit) -> unit
105 val layout: 'a t * ('a -> Layout.t) -> Layout.t
106 val map: 'a t * ('a -> 'b) -> 'b t
107 val object: 'a t -> 'a
114 | Inject of {sum: Tycon.t,
116 | Object of {args: Var.t vector,
118 | PrimApp of {args: Var.t vector,
120 | Select of {base: Var.t Base.t,
124 val equals: t * t -> bool
125 val foreachVar: t * (Var.t -> unit) -> unit
126 val hash: t -> Word.t
127 val layout: t -> Layout.t
128 val maySideEffect: t -> bool
129 val replaceVar: t * (Var.t -> Var.t) -> t
139 | Profile of ProfileExp.t
140 | Update of {base: Var.t Base.t,
144 val clear: t -> unit (* clear the var *)
145 val foreachDef: t * (Var.t * Type.t -> unit) -> unit
146 val foreachUse: t * (Var.t -> unit) -> unit
147 val layout: t -> Layout.t
148 val profile: ProfileExp.t -> t
149 val replaceUses: t * (Var.t -> Var.t) -> t
155 Con of (Con.t * Label.t) vector
156 | Word of WordSize.t * (WordX.t * Label.t) vector
158 val forall: t * (Label.t -> bool) -> bool
159 val foreach: t * (Label.t -> unit) -> unit
161 val isEmpty: t -> bool
162 val map: t * (Label.t -> Label.t) -> t
165 structure Handler: HANDLER
166 sharing Handler.Label = Label
168 structure Return: RETURN
169 sharing Return.Handler = Handler
174 Arith of {args: Var.t vector,
175 overflow: Label.t, (* Must be nullary. *)
177 success: Label.t, (* Must be unary. *)
178 ty: Type.t} (* int or word *)
179 | Bug (* MLton thought control couldn't reach here. *)
180 | Call of {args: Var.t vector,
183 | Case of {cases: Cases.t,
184 default: Label.t option, (* Must be nullary. *)
186 | Goto of {args: Var.t vector,
188 (* Raise implicitly raises to the caller.
189 * I.E. the local handler stack must be empty.
191 | Raise of Var.t vector
192 | Return of Var.t vector
193 | Runtime of {args: Var.t vector,
195 return: Label.t} (* Must be nullary. *)
197 val equals: t * t -> bool
198 val foreachFunc : t * (Func.t -> unit) -> unit
199 val foreachLabel: t * (Label.t -> unit) -> unit
200 val foreachLabelVar: t * (Label.t -> unit) * (Var.t -> unit) -> unit
201 val foreachVar: t * (Var.t -> unit) -> unit
202 val hash: t -> Word.t
203 val layout: t -> Layout.t
204 val replaceLabelVar: t * (Label.t -> Label.t) * (Var.t -> Var.t) -> t
205 val replaceLabel: t * (Label.t -> Label.t) -> t
206 val replaceVar: t * (Var.t -> Var.t) -> t
212 T of {args: (Var.t * Type.t) vector,
214 statements: Statement.t vector,
215 transfer: Transfer.t}
217 val args: t -> (Var.t * Type.t) vector
219 val label: t -> Label.t
220 val layout: t -> Layout.t
221 val transfer: t -> Transfer.t
227 T of {cons: {args: Type.t Prod.t,
231 val layout: t -> Layout.t
238 val alphaRename: t -> t
239 val blocks: t -> Block.t vector
240 (* clear the plists for all bound variables and labels that appear
241 * in the function, but not the function name's plist.
245 t -> {graph: unit DirectedGraph.t,
246 labelNode: Label.t -> unit DirectedGraph.Node.t,
247 nodeBlock: unit DirectedGraph.Node.t -> Block.t}
248 val dest: t -> {args: (Var.t * Type.t) vector,
249 blocks: Block.t vector,
252 raises: Type.t vector option,
253 returns: Type.t vector option,
255 (* dfs (f, v) visits the blocks in depth-first order, applying v b
256 * for block b to yield v', then visiting b's descendents,
257 * then applying v' ().
259 val dfs: t * (Block.t -> unit -> unit) -> unit
260 val dominatorTree: t -> Block.t Tree.t
261 val foreachVar: t * (Var.t * Type.t -> unit) -> unit
262 val layout: t -> Layout.t
264 t * (Var.t -> Layout.t) -> {destroy: unit -> unit,
265 controlFlowGraph: Layout.t,
266 dominatorTree: unit -> Layout.t,
267 loopForest: unit -> Layout.t}
268 val name: t -> Func.t
269 val new: {args: (Var.t * Type.t) vector,
270 blocks: Block.t vector,
273 raises: Type.t vector option,
274 returns: Type.t vector option,
276 val profile: t * SourceInfo.t -> t
282 T of {datatypes: Datatype.t vector,
283 functions: Function.t list,
284 globals: Statement.t vector,
285 main: Func.t (* Must be nullary. *)}
288 val clearTop: t -> unit
289 (* dfs (p, v) visits the functions in depth-first order, applying v f
290 * for function f to yield v', then visiting f's descendents,
291 * then applying v' ().
293 val dfs: t * (Function.t -> unit -> unit) -> unit
295 t * ({args: Var.t vector, prim: Type.t Prim.t} -> unit) -> unit
296 val foreachVar: t * (Var.t * Type.t -> unit) -> unit
297 val hasPrim: t * (Type.t Prim.t -> bool) -> bool
298 val layouts: t * (Layout.t -> unit) -> unit
299 val layoutStats: t -> Layout.t