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 /sml/trunk/src/MLRISC/x86/c-calls/ia32-svid.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/x86/c-calls/ia32-svid.sml

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

revision 1669, Wed Oct 27 22:49:25 2004 UTC revision 1670, Thu Oct 28 02:18:58 2004 UTC
# Line 28  Line 28 
28   *      + Struct results are returned in space provided by the caller.   *      + Struct results are returned in space provided by the caller.
29   *        The address of this space is passed to the callee as an   *        The address of this space is passed to the callee as an
30   *        implicit 0th argument, and on return %eax contains this   *        implicit 0th argument, and on return %eax contains this
31   *        address.   *        address.  The called function is responsible for removing
32     *        this argument from the stack.
33   *   *
34   *    Function arguments:   *    Function arguments:
35   *      + Arguments are pushed on the stack right to left.   *      + Arguments are pushed on the stack right to left.
# Line 281  Line 282 
282            val argAlloc = if ((#szb argMem = 0) orelse paramAlloc argMem)            val argAlloc = if ((#szb argMem = 0) orelse paramAlloc argMem)
283                  then []                  then []
284                  else [T.MV(wordTy, sp, T.SUB(wordTy, spR, T.LI(IntInf.fromInt(#szb argMem))))]                  else [T.MV(wordTy, sp, T.SUB(wordTy, spR, T.LI(IntInf.fromInt(#szb argMem))))]
285          (* for functions that return a struct/union, pass the location          (* for functions that return a struct/union, pass the location as an
286           * as an implicit first argument.           * implicit first argument.  Because the callee removes this implicit
287           *)           * argument from the stack, we must also keep track of the size of the
288            val (args, argLocs, argMem') = (case structRetLoc           * explicit arguments.
289                   of SOME pos => (ARG(structRet pos)::args,           *)
290                                   Stk(wordTy, 0)::argLocs,            val (args, argLocs, explicitArgSzB) = (case structRetLoc
291                                   { szb = #szb argMem - 4, align = #align argMem })                   of SOME pos =>
292                    | NONE => (args, argLocs, argMem)                        (ARG(structRet pos)::args, Stk(wordTy, 0)::argLocs, #szb argMem - 4)
293                      | NONE => (args, argLocs, #szb argMem)
294                  (* end case *))                  (* end case *))
295          (* generate instructions to copy arguments into argument area          (* generate instructions to copy arguments into argument area
296           * using %esp to address the argument area.           * using %esp to address the argument area.
# Line 378  Line 380 
380            val callStm = T.CALL{            val callStm = T.CALL{
381                    funct=name, targets=[], defs=defs, uses=[],                    funct=name, targets=[], defs=defs, uses=[],
382                    region = mem,                    region = mem,
383                    pops = if calleePops then Int32.fromInt(#szb argMem)                    pops = if calleePops
384                           else Int32.fromInt (#szb argMem - #szb argMem')                        then Int32.fromInt(#szb argMem)
385                          else Int32.fromInt(#szb argMem - explicitArgSzB)
386                  }                  }
387            val callStm = (case callComment            val callStm = (case callComment
388                   of NONE => callStm                   of NONE => callStm
# Line 399  Line 402 
402          (* code to pop the arguments from the stack *)          (* code to pop the arguments from the stack *)
403            val popArgs = if calleePops            val popArgs = if calleePops
404                  then []                  then []
405                  else [T.MV(wordTy, sp, T.ADD(wordTy, spR, T.LI(IntInf.fromInt(#szb argMem'))))]                  else [T.MV(wordTy, sp, T.ADD(wordTy, spR, T.LI(IntInf.fromInt explicitArgSzB)))]
406          (* code to copy the result into fresh pseudo registers *)          (* code to copy the result into fresh pseudo registers *)
407            val (resultRegs, copyResult) = (case resLoc            val (resultRegs, copyResult) = (case resLoc
408                   of NONE => ([], [])                   of NONE => ([], [])

Legend:
Removed from v.1669  
changed lines
  Added in v.1670

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