Ken Wakita (https://wakita.github.io/fp2017/)
Nov 13, 2017
Vp:Closure.prog→SparcAsm.progVf:Closure.fundef→SparcAsm.fundefVe:Closure.t→SparcAsm.t
Variables that occur in RHS but not in LHS are fresh.
Rhp is a register specifically used as heap pointer.
e1;e2 is a short hand notation for x←e1;e2.
x←E1;E2 is a short hand notation for x1→e1;…;xn→en;E2, where (x1→e1;…;xn→en;E2)=E1.
VF(Lx(y1,…,ym)(z1,…,zn)=e)=Lx(y1,…,ym)=z1←R0.(4);…;z=n←R0.(4n);Ve(e)
int
and float
values (four and eight, respectively).Ve((x1,…,xn))=y←Rhp;Rhp←Rhp+4n;y.(0)←x1;…;y.(4(n−1))←xn;y
Ve(make_closure x=(Lx,(y1,…,ym)) in e)x←Rhp;Rhp←Rhp+r(n+1);z←Lx;x.(0)←z;x.(1)←y1;…;x.(m)←ym;Ve(e)
Ve(let x=e1 in e2)=x←V(e1)V(e2)
Ve(let (x1,…,xn)=y in e)=xi1←y.(4(i1−1));…xim←y.(4(im−1));where {xi1,…,xim}={x1,…,xn}∩FV(e)
V(x.(y))=y′←4y;x.(y′)V(x.(y)←z)=y′←4y;x.(y′)←z