Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /MLRISC/trunk/x86/staged-allocation/ia32-svid-fn.sml
ViewVC logotype

Diff of /MLRISC/trunk/x86/staged-allocation/ia32-svid-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3067, Thu Jun 5 22:18:34 2008 UTC revision 3068, Fri Jun 6 00:25:53 2008 UTC
# Line 107  Line 107 
107          val fpStk = List.tabulate(8, fn i => fpr (C.ST i))          val fpStk = List.tabulate(8, fn i => fpr (C.ST i))
108    
109        (* conventions for calling a C function *)        (* conventions for calling a C function *)
110          val alignB = 4          val alignB = 16
111          val cStack = SA.freshCounter()          val cStack = SA.freshCounter()
112          val callStages = [          val callStages = [
113                SA.SEQ[                SA.SEQ[
# Line 166  Line 166 
166    (* convert a finalized staged-allocation location into a C location *)    (* convert a finalized staged-allocation location into a C location *)
167      fun saToCLoc (ty, SA.REG(_, r), K_GPR) = CCall.C_GPR(ty, r)      fun saToCLoc (ty, SA.REG(_, r), K_GPR) = CCall.C_GPR(ty, r)
168        | saToCLoc (ty, SA.REG(_, r), K_FPR) = CCall.C_FPR(ty, r)        | saToCLoc (ty, SA.REG(_, r), K_FPR) = CCall.C_FPR(ty, r)
169        | saToCLoc (ty, SA.BLOCK_OFFSET offB, _) = CCall.C_STK(ty, T.I.fromInt (32, offB))        | saToCLoc (ty, SA.BLOCK_OFFSET offB, K_GPR) = CCall.C_STK(ty, T.I.fromInt (32, offB))
170        | saToCLoc (ty, SA.NARROW(loc, ty', k), _) = saToCLoc (ty, loc, k)        | saToCLoc (ty, SA.BLOCK_OFFSET offB, K_FPR) = CCall.C_FSTK(ty, T.I.fromInt (32, offB))
171          | saToCLoc (ty, SA.NARROW(loc, ty', _), k) = saToCLoc (ty, loc, k)
172    
173      val frameAlign = 8      val frameAlign = 8
174    
# Line 195  Line 196 
196              in              in
197                 (str', (List.map saToCLoc paramLocs) :: paramLocss)                 (str', (List.map saToCLoc paramLocs) :: paramLocss)
198              end              end
199          val (str, paramLocss) = List.foldl doParam (str, []) paramTys          val (str, paramLocs) = List.foldl doParam (str, []) paramTys
200          val paramLocs = List.rev paramLocss          val paramLocs = List.rev paramLocs
201    
202          (* number of bytes allocated for the call *)          (* number of bytes allocated for the call *)
203          val cStkSzB = let          val cStkSzB = let
# Line 254  Line 255 
255           *)           *)
256            val (args, argLocs, explicitArgSzB) = (case structRetLoc            val (args, argLocs, explicitArgSzB) = (case structRetLoc
257                   of SOME pos =>                   of SOME pos =>
258                        (ARG(structRet pos)::args, [CCall.C_STK(wordTy, T.I.fromInt (wordTy, 0))]::argLocs, #szb argMem - 4)                        (ARG(structRet pos)::args, [CCall.C_STK(wordTy, T.I.fromInt (wordTy, 0))]::argLocs, #szb argMem)
259                    | NONE => (args, argLocs, #szb argMem)                    | NONE => (args, argLocs, #szb argMem)
260                  (* end case *))                  (* end case *))
261    
262          (* instruction to allocate space for arguments *)          (* instruction to allocate space for arguments *)
263            val argAlloc = if ((#szb argMem = 0) orelse paramAlloc argMem)            val argAlloc = if ((#szb argMem = 0) orelse paramAlloc argMem)
264                  then []                  then []
265                    else if abi = "Darwin"
266                          then let
267                            val szb = IA32CSizes.alignAddr(#szb argMem + 2*4, 16)-2*4
268                            in
269                              [T.MV(wordTy, C.esp, T.SUB(wordTy, spReg, T.LI(IntInf.fromInt szb)))]
270                            end
271                  else [T.MV(wordTy, C.esp, T.SUB(wordTy, spReg, T.LI(IntInf.fromInt(#szb argMem))))]                  else [T.MV(wordTy, C.esp, T.SUB(wordTy, spReg, T.LI(IntInf.fromInt(#szb argMem))))]
272            val (copyArgs, gprUses, fprUses) = CCall.copyArgs(args, argLocs)            val (copyArgs, gprUses, fprUses) = CCall.copyArgs(args, argLocs)
273    
# Line 327  Line 334 
334                  else callStm                  else callStm
335    
336          (* assemble the call sequence *)          (* assemble the call sequence *)
337            val callSeq = argAlloc @ copyArgs @ save @ [callStm] @ restore(* @ popArgs*) @ copyResult            val callSeq = argAlloc @ copyArgs @ save @ [callStm] @ restore @ popArgs @ copyResult
338    
339            in            in
340              {callseq=callSeq, result=resultRegs}              {callseq=callSeq, result=resultRegs}

Legend:
Removed from v.3067  
changed lines
  Added in v.3068

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0