

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


signature FRAME = sig
.... end structure MipsFrame : FRAME = struct datatype access = InFrame of int | InReg of Temp.temp type frame = {name: Temp.label, formals: access list locals: int ref} ...... end structure SparcFrame : FRAME = ....
signature FRAME = sig type frame type access (* InFrame or InReg ) val newFrame : {name: Temp.label, (label of called fun) formals : bool list} -> frame ( formals specified with an escape flag ) val name : frame -> Temp.label ( the function label of a frame ) val formals : frame -> access list ( access info for formal parameters ) val allocLocal : frame -> bool -> access ( will go InReg or InFrame based on bool *)
(* more to come ...*)
end (* signature FRAME *)
31 $ ra return address
30 $ fp ($s8) frame pointer
29 $ sp stack pointer
28 $ gp global data pointer
26-27 $ k0- $ k1 exception handling
24-25 $ t8- $ t9 caller-saves temporaries
16-23 $ s0- $ s7 callee-saves temporaries
8-15 $ t0- $ t7 caller-saves temporaries
4-7 $ a0- $ a3 incoming args
2-3 $ v0- $ v1 function return value
1 $ at assmbler temporary
0 $ zero constant zero
Hardware Name Description
next frame
a
a
sn …
tk …
fp
ra
saved registers
local variables
escaping arguments
previous frame higher addresses
caller saves callee saves
spf
fpf
overflow outgoing args
spg
fph
function f(x0,x1,x2,x3,y4,y5) = let function g(u: int): int = x0 + x2 + u /* x0 and x2 escaping */ in g(3) end
next frame
fp
ra
x
x
y
y
previous frame fp
sp
signature ENV = sig datatype ententry = VarEntry of {access: Translate.access, ty: ty} | FunEntry of {level: Translate.level, label: Temp:label, formals: ty list, result: ty} .. end
structure TRANSLATE = sig type level type access (* level * Frame.access, i.e., level * offset *)
val outermost: level val newLevel: {parent: level, name: Temp.label, formals: bool list} -> level val formals: level -> access list val allocLocal: level -> bool -> access
end
structure Translate: TRANSLATE = …
datatype level = TOP or parent’s level Frame.frame ref…
...