1 (* Copyright (C) 2009,2014 Matthew Fluet.
2 * Copyright (C) 1999-2007 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 MACHINE_STRUCTS =
17 include MACHINE_STRUCTS
19 structure ObjectType: OBJECT_TYPE
20 structure ObjptrTycon: OBJPTR_TYCON
21 structure Runtime: RUNTIME
22 structure Switch: SWITCH
23 structure Type: REP_TYPE
26 sharing Atoms = Switch
27 sharing ObjectType = Type.ObjectType
28 sharing ObjptrTycon = ObjectType.ObjptrTycon = Type.ObjptrTycon
29 sharing Runtime = ObjectType.Runtime = Type.Runtime
31 structure ChunkLabel: ID
37 val equals: t * t -> bool
39 val indexOpt: t -> int option
40 val layout: t -> Layout.t
41 val new: Type.t * int option -> t
42 val setIndex: t * int -> unit
43 val toString: t -> string
51 val equals: t * t -> bool
54 val layout: t -> Layout.t
55 val new: {isRoot: bool, ty: Type.t} -> t
56 val numberOfNonRoot: unit -> int
57 val numberOfType: CType.t -> int
61 structure StackOffset:
63 datatype t = T of {offset: Bytes.t,
69 structure Scale: SCALE
70 sharing Scale = Type.Scale
75 ArrayOffset of {base: t,
81 | Contents of {oper: t,
92 | Register of Register.t
93 | StackOffset of StackOffset.t
97 val equals: t * t -> bool
98 val interfere: t * t -> bool
99 val isLocation: t -> bool
100 val layout: t -> Layout.t
101 val stackOffset: {offset: Bytes.t, ty: Type.t} -> t
102 val toString: t -> string
105 sharing Operand = Switch.Use
111 | Register of Register.t
112 | StackOffset of StackOffset.t
114 val equals: t * t -> bool
115 val fromOperand: Operand.t -> t option
116 val layout: t -> Layout.t
117 val toOperand: t -> Operand.t
124 (* When registers or offsets appear in operands, there is an
125 * implicit contents of.
126 * When they appear as locations, there is not.
128 Move of {dst: Operand.t,
131 | PrimApp of {args: Operand.t vector,
132 dst: Operand.t option,
134 | ProfileLabel of ProfileLabel.t
136 val foldOperands: t * 'a * (Operand.t * 'a -> 'a) -> 'a
137 val layout: t -> Layout.t
138 val move: {dst: Operand.t, src: Operand.t} -> t
139 (* Error if dsts and srcs aren't of same length. *)
140 val moves: {dsts: Operand.t vector,
141 srcs: Operand.t vector} -> t vector
142 val object: {dst: Operand.t, header: word, size: Bytes.t} -> t vector
147 datatype t = T of {frameLayoutsIndex: int}
149 val equals: t * t -> bool
150 val layout: t -> Layout.t
156 (* In an arith transfer, dst is modified whether or not the
159 Arith of {args: Operand.t vector,
164 | CCall of {args: Operand.t vector,
165 frameInfo: FrameInfo.t option,
166 func: Type.t CFunction.t,
167 (* return is NONE iff the func doesn't return.
168 * Else, return must be SOME l, where l is of CReturn
169 * kind with a matching func.
171 return: Label.t option}
172 | Call of {label: Label.t, (* label must be a Func *)
174 return: {return: Label.t,
175 handler: Label.t option,
176 size: Bytes.t} option}
177 | Goto of Label.t (* label must be a Jump *)
182 val foldOperands: t * 'a * (Operand.t * 'a -> 'a) -> 'a
183 val layout: t -> Layout.t
189 Cont of {args: Live.t vector,
190 frameInfo: FrameInfo.t}
191 | CReturn of {dst: Live.t option,
192 frameInfo: FrameInfo.t option,
193 func: Type.t CFunction.t}
195 | Handler of {frameInfo: FrameInfo.t,
196 handles: Live.t vector}
199 val frameInfoOpt: t -> FrameInfo.t option
207 (* Live registers and stack offsets at start of block. *)
209 raises: Live.t vector option,
210 returns: Live.t vector option,
211 statements: Statement.t vector,
212 transfer: Transfer.t}
214 val foldDefs: t * 'a * (Operand.t * 'a -> 'a) -> 'a
215 val label: t -> Label.t
221 T of {blocks: Block.t vector,
222 chunkLabel: ChunkLabel.t,
224 * <= regMax (Type.toCType (Register.ty r))
225 * for all registers in the chunk.
227 regMax: CType.t -> int}
230 structure ProfileInfo:
233 T of {(* For each frame, gives the index into sourceSeqs of the
234 * source functions corresponding to the frame.
236 frameSources: int vector,
237 labels: {label: ProfileLabel.t,
238 sourceSeqsIndex: int} vector,
239 names: string vector,
240 (* Each sourceSeq describes a sequence of source functions,
241 * each given as an index into the source vector.
243 sourceSeqs: int vector vector,
244 sources: {nameIndex: int,
245 successorsIndex: int} vector}
248 val modify: t -> {newProfileLabel: ProfileLabel.t -> ProfileLabel.t,
249 delProfileLabel: ProfileLabel.t -> unit,
250 getProfileInfo: unit -> t}
256 T of {chunks: Chunk.t list,
257 frameLayouts: {frameOffsetsIndex: int,
259 size: Bytes.t} vector,
260 (* Each vector in frame Offsets specifies the offsets
261 * of live pointers in a stack frame. A vector is referred
262 * to by index as the offsetsIndex in frameLayouts.
264 frameOffsets: Bytes.t vector vector,
265 handlesSignals: bool,
266 main: {chunkLabel: ChunkLabel.t,
268 maxFrameSize: Bytes.t,
269 objectTypes: Type.ObjectType.t vector,
270 profileInfo: ProfileInfo.t option,
271 reals: (Global.t * RealX.t) list,
272 vectors: (Global.t * WordXVector.t) list}
274 val frameSize: t * FrameInfo.t -> Bytes.t
275 val clearLabelNames: t -> unit
276 val layouts: t * (Layout.t -> unit) -> unit
277 val typeCheck: t -> unit