68 |
val mem = T.Region.memory |
val mem = T.Region.memory |
69 |
val stack = T.Region.memory |
val stack = T.Region.memory |
70 |
|
|
71 |
|
val maxRegArgs = 6 |
72 |
val paramAreaOffset = 68 |
val paramAreaOffset = 68 |
73 |
|
|
74 |
fun LI i = T.LI (T.I.fromInt (32, i)) |
fun LI i = T.LI (T.I.fromInt (32, i)) |
160 |
loop (paramTys, 0) |
loop (paramTys, 0) |
161 |
end |
end |
162 |
|
|
163 |
val regargwords = Int.min (nargwords, 6) |
val regargwords = Int.min (nargwords, maxRegArgs) |
164 |
val stackargwords = Int.max (nargwords, 6) - 6 |
val stackargwords = Int.max (nargwords, maxRegArgs) - maxRegArgs |
165 |
|
|
166 |
val scratchstart = 92 + 4*stackargwords |
val scratchstart = paramAreaOffset + 4 * (maxRegArgs + stackargwords) |
167 |
|
|
168 |
(* Copy struct or part thereof to designated area on the stack. |
(* Copy struct or part thereof to designated area on the stack. |
169 |
* An already properly aligned address (relative to %sp) is |
* An already properly aligned address (relative to %sp) is |
378 |
|
|
379 |
val defs = g_regs @ a_regs @ l_reg :: f_regs |
val defs = g_regs @ a_regs @ l_reg :: f_regs |
380 |
(* A call instruction "uses" just the argument registers. *) |
(* A call instruction "uses" just the argument registers. *) |
381 |
val uses = List.take (a_regs, stackargwords) |
val uses = List.take (a_regs, regargwords) |
382 |
in |
in |
383 |
(defs, uses) |
(defs, uses) |
384 |
end |
end |
423 |
| SOME c => |
| SOME c => |
424 |
T.ANNOTATION (call, #create MLRiscAnnotations.COMMENT c) |
T.ANNOTATION (call, #create MLRiscAnnotations.COMMENT c) |
425 |
|
|
426 |
|
val (sp_sub, sp_add) = |
427 |
|
if stackdelta = 0 then ([], []) else |
428 |
|
if paramAlloc { szb = stackdelta, align = 4 } then ([], []) |
429 |
|
else ([T.MV (32, sp, T.SUB (32, spreg, LI stackdelta))], |
430 |
|
[T.MV (32, sp, addli (spreg, stackdelta))]) |
431 |
|
|
432 |
val callseq = |
val callseq = |
433 |
List.concat [[T.MV (32, sp, T.SUB (32, spreg, LI stackdelta))], |
List.concat [sp_sub, |
434 |
copycode, |
copycode, |
435 |
argsetupcode, |
argsetupcode, |
436 |
sretsetup, |
sretsetup, |
438 |
[call], |
[call], |
439 |
srethandshake, |
srethandshake, |
440 |
restore, |
restore, |
441 |
[T.MV (32, sp, addli (spreg, stackdelta))]] |
sp_add] |
442 |
|
|
443 |
in |
in |
444 |
{ callseq = callseq, result = result } |
{ callseq = callseq, result = result } |