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/ppc/c-calls/ppc-macosx.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/ppc/c-calls/ppc-macosx.sml

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

revision 1536, Tue Jul 13 18:30:33 2004 UTC revision 1544, Wed Jul 14 16:08:37 2004 UTC
# Line 251  Line 251 
251                        assignGPR(sizeOfPtr, tys, offset, availGPRs, availFPRs, layout)                        assignGPR(sizeOfPtr, tys, offset, availGPRs, availFPRs, layout)
252                    | CTy.C_ARRAY _ =>                    | CTy.C_ARRAY _ =>
253                        assignGPR(sizeOfPtr, tys, offset, availGPRs, availFPRs, layout)                        assignGPR(sizeOfPtr, tys, offset, availGPRs, availFPRs, layout)
254                    | CTy.C_STRUCT tys' => raise Fail "struct arguments not supported yet"                    | CTy.C_STRUCT tys' => let
255                          val sz = IntInf.fromInt(sizeOfStruct tys')
256                          fun assignMem (relOffset, availGPRs, fields) =
257                                if (relOffset < sz)
258                                  then let
259                                    val (loc, availGPRs) = (case availGPRs
260                                           of [] => (Stk(wordTy, offset+relOffset), [])
261                                            | r1::rs => (Reg(wordTy, r1, SOME(offset+relOffset)), rs)
262                                          (* end case *))
263                                    in
264                                      assignMem (relOffset+4, availGPRs, loc::fields)
265                                    end
266                                  else assign (tys, offset+relOffset, availGPRs, availFPRs,
267                                      Args(List.rev fields) :: layout)
268                          in
269                            assignMem (0, availGPRs, [])
270                          end
271                  (* end case *))                  (* end case *))
272          (* assign a GP register and memory for an integer/pointer argument. *)          (* assign a GP register and memory for an integer/pointer argument. *)
273            and assignGPR ({sz, pad, ...}, args, offset, availGPRs, availFPRs, layout) = let            and assignGPR ({sz, pad, ...}, args, offset, availGPRs, availFPRs, layout) = let
# Line 318  Line 334 
334              | assignArgs (FStk(ty, off) :: locs, FARG fexp :: args, stms) =              | assignArgs (FStk(ty, off) :: locs, FARG fexp :: args, stms) =
335                  assignArgs (locs, args, T.FSTORE(ty, paramAddr off, fexp, stkRg) :: stms)                  assignArgs (locs, args, T.FSTORE(ty, paramAddr off, fexp, stkRg) :: stms)
336              | assignArgs ((Args locs') :: locs, (ARGS args') :: args, stms) =              | assignArgs ((Args locs') :: locs, (ARGS args') :: args, stms) =
337                  assignArgs (locs, args, assignArgs(locs', args', stms))                  raise Fail "ARGS constructor is obsolete"
338                | assignArgs ((Args locs') :: locs, ARG exp :: args, stms) = let
339                  (* MLRISC expression for address inside the struct *)
340                    fun addr 0 = T.LOAD(wordTy, exp, memRg)
341                      | addr offset = T.LOAD(wordTy, T.ADD(wordTy, exp, T.LI offset), memRg)
342                    fun copy ([], _, stms) = assignArgs(locs, args, stms)
343                      | copy (Reg(ty, r, _) :: locs, offset, stms) =
344                          copy (locs, offset+4, T.MV(ty, r, addr offset)::stms)
345                      | copy (Stk(ty, off) :: locs, offset, stms) = let
346                          val r = C.newReg()
347                          in
348                            copy (locs, offset+4,
349                              T.STORE(ty, paramAddr off, T.REG(wordTy, r), stkRg)
350                              :: T.MV(ty, r, addr offset) :: stms)
351                          end
352                      | copy _ = raise Fail "unexpected FReg/FStk/Args in location list"
353                    in
354                    (* copy data from memory specified by exp to locs' *)
355                      copy (locs', 0, stms)
356                    end
357              | assignArgs _ = error "argument/formal mismatch"              | assignArgs _ = error "argument/formal mismatch"
358            val argSetupCode = List.rev(assignArgs(argLocs, args, []))            val argSetupCode = List.rev(assignArgs(argLocs, args, []))
359          (* convert the result location to an MLRISC expression list *)          (* convert the result location to an MLRISC expression list *)

Legend:
Removed from v.1536  
changed lines
  Added in v.1544

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