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 1527, Fri Jul 9 22:42:16 2004 UTC revision 1528, Fri Jul 9 23:30:57 2004 UTC
# Line 112  Line 112 
112    (* registers used for parameter passing *)    (* registers used for parameter passing *)
113      val argGPRs = List.map C.GPReg [3, 4, 5, 6, 7, 8, 9, 10]      val argGPRs = List.map C.GPReg [3, 4, 5, 6, 7, 8, 9, 10]
114      val argFPRs = List.map C.FPReg [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]      val argFPRs = List.map C.FPReg [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
115      val resGPR = C.GPReg 3      val resRegLoc = Reg(wordTy, C.GPReg 3, NONE)
116      val resFPR = C.FPReg 1      val resFPR = C.FPReg 1
117    
118    (* C callee-save registers *)    (* C callee-save registers *)
# Line 127  Line 127 
127    
128    (* C caller-save registers (including argument registers) *)    (* C caller-save registers (including argument registers) *)
129      val callerSaveRegs =      val callerSaveRegs =
130  (* FIXME: also need link register *)            T.FPR(T.FREG(dblTy, C.FPReg 0)) ::
131            (List.map C.GPReg [2, 11, 12]) @ argGPRs @ (List.map C.FPReg [0]) @ argFPRs              (List.map (fn r => T.GPR(T.REG(wordTy, C.GPReg r))) [2, 11, 12])
132    
133        val linkReg = T.GPR(T.REG(wordTy, C.lr))
134    
135    (* the parameter area lies just above the linkage area in the caller's frame.    (* the parameter area lies just above the linkage area in the caller's frame.
136     * The linkage area is 24 bytes, so the first parameter is at 24(sp).     * The linkage area is 24 bytes, so the first parameter is at 24(sp).
# Line 167  Line 169 
169      fun layout {conv, retTy, paramTys} = let      fun layout {conv, retTy, paramTys} = let
170            fun gprRes isz = (case #sz(sizeOf isz)            fun gprRes isz = (case #sz(sizeOf isz)
171                   of 8 => raise Fail "register pairs not yet supported"                   of 8 => raise Fail "register pairs not yet supported"
172                    | _ => SOME(Reg(wordTy, resGPR, NONE))                    | _ => SOME resRegLoc
173                  (* end case *))                  (* end case *))
174            val (resLoc, argGPRs, structRet) = (case retTy            val (resLoc, argGPRs, structRet) = (case retTy
175                   of CTy.C_void => (NONE, argGPRs, NONE)                   of CTy.C_void => (NONE, argGPRs, NONE)
# Line 176  Line 178 
178                    | CTy.C_long_double => (SOME(FReg(dblTy, resFPR, NONE)), argGPRs, NONE)                    | CTy.C_long_double => (SOME(FReg(dblTy, resFPR, NONE)), argGPRs, NONE)
179                    | CTy.C_unsigned isz => (gprRes isz, argGPRs, NONE)                    | CTy.C_unsigned isz => (gprRes isz, argGPRs, NONE)
180                    | CTy.C_signed isz => (gprRes isz, argGPRs, NONE)                    | CTy.C_signed isz => (gprRes isz, argGPRs, NONE)
181                    | CTy.C_PTR => (SOME(Reg(wordTy, resGPR, NONE)), argGPRs, NONE)                    | CTy.C_PTR => (SOME resRegLoc, argGPRs, NONE)
182                    | CTy.C_ARRAY _ => error "array return type"                    | CTy.C_ARRAY _ => error "array return type"
183                    | CTy.C_STRUCT s => let                    | CTy.C_STRUCT s => let
184                        val sz = sizeOfStruct s                        val sz = sizeOfStruct s
# Line 185  Line 187 
187                         * In Linux, GPR3/GPR4 are used to return composite values of 8 bytes.                         * In Linux, GPR3/GPR4 are used to return composite values of 8 bytes.
188                         *)                         *)
189                          if (sz > 4)                          if (sz > 4)
190                            then (SOME resGPR, List.tl argGPRs, SOME{szb=sz, align=4})                            then (SOME resRegLoc, List.tl argGPRs, SOME{szb=sz, align=4})
191                            else (SOME resGPR, argGPRs, NONE)                            else (SOME resRegLoc, argGPRs, NONE)
192                        end                        end
193                  (* end case *))                  (* end case *))
194            fun assign ([], offset, _, _, layout) = List.rev layout            fun assign ([], offset, _, _, layout) = List.rev layout
# Line 298  Line 300 
300                    | addArgReg (_::locs, argRegs) = addArgReg(locs, argRegs)                    | addArgReg (_::locs, argRegs) = addArgReg(locs, argRegs)
301                  val argRegs = addArgReg (locs, [])                  val argRegs = addArgReg (locs, [])
302                  in                  in
303                    (argRegs, callerSaveRegs)                    (argRegs, linkReg :: callerSaveRegs)
304                  end                  end
305          (* the actual call instruction *)          (* the actual call instruction *)
306            val callStm = T.CALL {            val callStm = T.CALL {

Legend:
Removed from v.1527  
changed lines
  Added in v.1528

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