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_TREE_STRUCTS =
17 structure Label: LABEL
24 val equals: t * t -> bool
25 val foldLabel: t * 'a * (Label.t * 'a -> 'a) -> 'a
26 val foreachLabel: t * (Label.t -> unit) -> unit
27 val layout: t -> Layout.t
28 val map: t * (Label.t -> Label.t) -> t
33 structure Label: LABEL
35 structure Handler: HANDLER
36 sharing Label = Handler.Label
40 | NonTail of {cont: Label.t,
44 val compose: t * t -> t
45 val foldLabel: t * 'a * (Label.t * 'a -> 'a) -> 'a
46 val foreachHandler: t * (Label.t -> unit) -> unit
47 val foreachLabel: t * (Label.t -> unit) -> unit
48 val layout: t -> Layout.t
49 val map: t * (Label.t -> Label.t) -> t
54 include SSA_TREE_STRUCTS
75 val checkPrimApp: {targs: t vector,
80 val datatypee: Tycon.t -> t
83 val deDatatype: t -> Tycon.t
85 val deTuple: t -> t vector
86 val deTupleOpt: t -> t vector option
89 val deWord: t -> WordSize.t
90 val deWordOpt: t -> WordSize.t option
91 val equals: t * t -> bool
94 val isTuple: t -> bool
96 val layout: t -> Layout.t
97 val ofConst: Const.t -> t
98 val plist: t -> PropertyList.t
99 val real: RealSize.t -> t
102 val tuple: t vector -> t
105 val word: WordSize.t -> t
112 ConApp of {args: Var.t vector,
115 | PrimApp of {args: Var.t vector,
117 targs: Type.t vector}
118 | Profile of ProfileExp.t
119 | Select of {offset: int,
121 | Tuple of Var.t vector
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
136 datatype t = T of {exp: Exp.t,
140 val clear: t -> unit (* clear the var *)
142 val layout: t -> Layout.t
143 val profile: ProfileExp.t -> t
144 val var: t -> Var.t option
150 Con of (Con.t * Label.t) vector
151 | Word of WordSize.t * (WordX.t * Label.t) vector
153 val forall: t * (Label.t -> bool) -> bool
154 val foreach: t * (Label.t -> unit) -> unit
156 val isEmpty: t -> bool
158 val map: t * (Label.t -> Label.t) -> t
161 structure Handler: HANDLER
162 sharing Handler.Label = Label
164 structure Return: RETURN
165 sharing Return.Handler = Handler
170 Arith of {args: Var.t vector,
171 overflow: Label.t, (* Must be nullary. *)
173 success: Label.t, (* Must be unary. *)
174 ty: Type.t} (* int or word *)
175 | Bug (* MLton thought control couldn't reach here. *)
176 | Call of {args: Var.t vector,
179 | Case of {cases: Cases.t,
180 default: Label.t option, (* Must be nullary. *)
182 | Goto of {args: Var.t vector,
184 (* Raise implicitly raises to the caller.
185 * I.E. the local handler stack must be empty.
187 | Raise of Var.t vector
188 | Return of Var.t vector
189 | Runtime of {args: Var.t vector,
191 return: Label.t} (* Must be nullary. *)
193 val equals: t * t -> bool
194 val foreachFunc : t * (Func.t -> unit) -> unit
195 val foreachLabel: t * (Label.t -> unit) -> unit
196 val foreachLabelVar: t * (Label.t -> unit) * (Var.t -> unit) -> unit
197 val foreachVar: t * (Var.t -> unit) -> unit
198 val hash: t -> Word.t
199 val layout: t -> Layout.t
200 val replaceLabelVar: t * (Label.t -> Label.t) * (Var.t -> Var.t) -> t
201 val replaceLabel: t * (Label.t -> Label.t) -> t
202 val replaceVar: t * (Var.t -> Var.t) -> t
209 T of {args: (Var.t * Type.t) vector,
211 statements: Statement.t vector,
212 transfer: Transfer.t}
214 val args: t -> (Var.t * Type.t) vector
216 val label: t -> Label.t
217 val layout: t -> Layout.t
218 val sizeV: t vector * {sizeExp: Exp.t -> int, sizeTransfer: Transfer.t -> int} -> int
219 val statements: t -> Statement.t vector
220 val transfer: t -> Transfer.t
226 T of {cons: {args: Type.t vector,
230 val layout: t -> Layout.t
237 val alphaRename: t -> t
238 val blocks: t -> Block.t vector
239 (* clear the plists for all bound variables and labels that appear
240 * in the function, but not the function name's plist.
244 t -> {graph: unit DirectedGraph.t,
245 labelNode: Label.t -> unit DirectedGraph.Node.t,
246 nodeBlock: unit DirectedGraph.Node.t -> Block.t}
247 val dest: t -> {args: (Var.t * Type.t) vector,
248 blocks: Block.t vector,
251 raises: Type.t vector option,
252 returns: Type.t vector option,
254 (* dfs (f, v) visits the blocks in depth-first order, applying v b
255 * for block b to yield v', then visiting b's descendents,
256 * then applying v' ().
258 val dfs: t * (Block.t -> unit -> unit) -> unit
259 val dominatorTree: t -> Block.t Tree.t
260 val foreachVar: t * (Var.t * Type.t -> unit) -> unit
261 val layout: t -> Layout.t
263 t * (Var.t -> Layout.t) -> {destroy: unit -> unit,
264 controlFlowGraph: Layout.t,
265 dominatorTree: unit -> Layout.t,
266 loopForest: unit -> Layout.t}
267 val mayInline: t -> bool
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
277 val size: t * {sizeExp: Exp.t -> int, sizeTransfer: Transfer.t -> int} -> int
278 val sizeMax: t * {max: int option, sizeExp: Exp.t -> int, sizeTransfer: Transfer.t -> int} -> int option
284 T of {datatypes: Datatype.t vector,
285 functions: Function.t list,
286 globals: Statement.t vector,
287 main: Func.t (* Must be nullary. *)}
290 val clearTop: t -> unit
291 (* dfs (p, v) visits the functions in depth-first order, applying v f
292 * for function f to yield v', then visiting f's descendents,
293 * then applying v' ().
295 val dfs: t * (Function.t -> unit -> unit) -> unit
296 val foreachPrim: t * (Type.t Prim.t -> unit) -> unit
297 val foreachVar: t * (Var.t * Type.t -> unit) -> unit
298 val hasPrim: t * (Type.t Prim.t -> bool) -> bool
299 val layouts: t * (Layout.t -> unit) -> unit
300 val layoutStats: t -> Layout.t
301 val mainFunction: t -> Function.t