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
 [smlnj] / sml / trunk / src / MLRISC / ppc / c-calls / ppc-macosx.sml

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

revision 1444, Sun Jan 25 19:32:40 2004 UTC revision 1445, Mon Jan 26 15:20:12 2004 UTC
# Line 202  Line 202
202            end            end
203      end      end
204
205      datatype arg      fun assignIntLoc (ty, gprs, offset) = let
206        = Simple of (Ty.c_type * arg_pos)         (* includes arrays *)            val {sz, alignStk, alignStruct} = szal ty
207        | Struct of arg list            val offset = align(offset, alignStk)
208              in
209    (* layout arguments *)              case (sz, gprs)
210      fun layout argTys = let               of (_, []) => ({offset = offset, loc = ARG(??)}, offset+sz, [])
fun assign ([], _, _, offset, args) = (offset, List.rev args)
| assign (x::xs, gprs, fprs, offset, args) = let
fun assignInt sz = (case (sz, gprs)
of (_, []) =>
assign(xs, [], fprs,
211                          | (8, [r]) =>                          | (8, [r]) =>
212                          | (8, r1::r2::rs) =>                          | (8, r1::r2::rs) =>
213                          | (_, r::rs) =>                | (_, r::rs) =>({offset = offset, loc = GPR r}, offset+sz, rs)
(* end case *))
in
case x
of (Ty.C_unsigned _) => assignInt x
| (Ty.C_signed _) => assignInt x
| (Ty.C_PTR) => assignInt x
| (Ty.C_float) => assignFlt x
| (Ty.C_double) => assignFlt x
| (Ty.C_long_double) => assignFlt x
| (Ty.C_ARRAY(ty, n)) =>
| (Ty.CSTRUCT tys) =>
214                    (* end case *)                    (* end case *)
215                  end                  end
216
217        fun genCall {
218              name, proto, paramAlloc, structRet, saveRestoreDedicated,
219              callComment, args
220            } = let
221              val {conv, retTy, paramTys} = proto
222              val callseq = List.concat [
223                      sp_sub,
224                      copycode,
225                      argsetupcode,
226                      sretsetup,
227                      save,
228                      [call],
229                      srethandshake,
230                      restore,
232                    ]
233            in            in
234              (* check calling convention *)
235                case conv
236                 of ("" | "ccall") => ()
237                  | _ => error (concat [
238                        "unknown calling convention \"",
239                        String.toString conv, "\""
240                      ])
241                (* end case *);
242                {callseq = callseq, result = result}
243            end            end
244
245      fun genCall { name, proto, paramAlloc, structRet, saveRestoreDedicated,  (******
246                    callComment, args } = let          val res_szal = (case retTy
247          val { conv, retTy, paramTys } = proto                 of (Ty.C_long_double | Ty.C_STRUCT _) => SOME(szal retTy)
val _ = case conv of
("" | "ccall") => ()
| _ => error (concat ["unknown calling convention \"",
String.toString conv, "\""])
val res_szal =
case retTy of
(Ty.C_long_double | Ty.C_STRUCT _) => SOME (szal retTy)
248                | _ => NONE                | _ => NONE
249
250          val nargwords = let          val nargwords = let
# Line 541  Line 544
544      in      in
545          { callseq = callseq, result = result }          { callseq = callseq, result = result }
546      end      end
547    *****)
548
549  end  end

Legend:
 Removed from v.1444 changed lines Added in v.1445