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

Diff of /sml/trunk/src/MLRISC/sparc/c-calls/sparc-c-calls.sml

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

revision 841, Fri Jun 15 21:38:20 2001 UTC revision 1523, Tue Jul 6 19:48:33 2004 UTC
# Line 68  Line 68 
68      val mem = T.Region.memory      val mem = T.Region.memory
69      val stack = T.Region.memory      val stack = T.Region.memory
70    
71        val maxRegArgs = 6
72        val paramAreaOffset = 68
73    
74      fun LI i = T.LI (T.I.fromInt (32, i))      fun LI i = T.LI (T.I.fromInt (32, i))
75    
76      val GP = C.GPReg      val GP = C.GPReg
# Line 75  Line 78 
78    
79      fun greg r = GP r      fun greg r = GP r
80      fun oreg r = GP (r + 8)      fun oreg r = GP (r + 8)
81        fun ireg r = GP (r + 24)
82      fun freg r = FP r      fun freg r = FP r
83    
84      fun reg32 r = T.REG (32, r)      fun reg32 r = T.REG (32, r)
# Line 93  Line 97 
97                | _ => T.ADD (32, x, T.LI d')                | _ => T.ADD (32, x, T.LI d')
98          end          end
99    
100      fun argaddr n = addli (spreg, 68+4*n)      fun argaddr n = addli (spreg, paramAreaOffset + 4*n)
101    
102      (* temp location for transfers through memory *)      (* temp location for transfers through memory *)
103      val tmpaddr = argaddr 1      val tmpaddr = argaddr 1
# Line 134  Line 138 
138              pack (0, 1, l)              pack (0, 1, l)
139          end          end
140    
141      fun genCall { name, proto, structRet, saveRestoreDedicated,  (**** START NEW CODE ****)
142    
143      (* the location of arguments/parameters; offsets are given with respect to the
144       * low end of the parameter area (see paramAreaOffset above).
145       *)
146        datatype arg_location
147          = Reg of T.ty * T.reg * T.I.machine_int option
148                                            (* integer/pointer argument in register *)
149          | FReg of T.fty * T.reg * T.I.machine_int option
150                                            (* floating-point argument in register *)
151          | Stk of T.ty * T.I.machine_int   (* integer/pointer argument in parameter area *)
152          | FStk of T.fty * T.I.machine_int (* floating-point argument in parameter area *)
153          | Args of arg_location list
154    
155        fun layout {conv, retTy, paramTys} = let
156              in
157                raise Fail "layout not implemented yet"
158              end
159    
160      (* C callee-save registers *)
161        val calleeSaveRegs = (* %l0-%l7 and %i0-%i7 *)
162              List.tabulate (16, fn r => GP(r+16))
163        val calleeSaveFRegs = []
164    
165    (**** END NEW CODE ****)
166    
167        fun genCall { name, proto, paramAlloc, structRet, saveRestoreDedicated,
168                    callComment, args } = let                    callComment, args } = let
169          val { conv, retTy, paramTys } = proto          val { conv, retTy, paramTys } = proto
170          val _ = case conv of          val _ = case conv of
# Line 157  Line 187 
187              loop (paramTys, 0)              loop (paramTys, 0)
188          end          end
189    
190          val regargwords = Int.min (nargwords, 6)          val regargwords = Int.min (nargwords, maxRegArgs)
191          val stackargwords = Int.max (nargwords, 6) - 6          val stackargwords = Int.max (nargwords, maxRegArgs) - maxRegArgs
192    
193          val scratchstart = 92 + 4*stackargwords          val stackargsstart = paramAreaOffset + 4 * maxRegArgs
194    
195            val scratchstart = stackargsstart + 4 * stackargwords
196    
197          (* Copy struct or part thereof to designated area on the stack.          (* Copy struct or part thereof to designated area on the stack.
198           * An already properly aligned address (relative to %sp) is           * An already properly aligned address (relative to %sp) is
# Line 243  Line 275 
275              end              end
276    
277          val (stackdelta, argsetupcode, copycode) = let          val (stackdelta, argsetupcode, copycode) = let
278              fun loop ([], [], _, ss, asc, cpc) = (roundup (ss, 8), asc, cpc)              fun loop ([], [], _, ss, asc, cpc) =
279                    (roundup (Int.max (0, ss - stackargsstart), 8), asc, cpc)
280                | loop (t :: tl, a :: al, n, ss, asc, cpc) = let                | loop (t :: tl, a :: al, n, ss, asc, cpc) = let
281                      fun wordassign a =                      fun wordassign a =
282                          if n < 6 then T.MV (32, oreg n, a)                          if n < 6 then T.MV (32, oreg n, a)
# Line 375  Line 408 
408    
409              val defs = g_regs @ a_regs @ l_reg :: f_regs              val defs = g_regs @ a_regs @ l_reg :: f_regs
410              (* A call instruction "uses" just the argument registers. *)              (* A call instruction "uses" just the argument registers. *)
411              val uses = List.take (a_regs, stackargwords)              val uses = List.take (a_regs, regargwords)
412          in          in
413              (defs, uses)              (defs, uses)
414          end          end
# Line 420  Line 453 
453                | SOME c =>                | SOME c =>
454                  T.ANNOTATION (call, #create MLRiscAnnotations.COMMENT c)                  T.ANNOTATION (call, #create MLRiscAnnotations.COMMENT c)
455    
456            val (sp_sub, sp_add) =
457                if stackdelta = 0 then ([], []) else
458                if paramAlloc { szb = stackdelta, align = 4 } then ([], [])
459                else ([T.MV (32, sp, T.SUB (32, spreg, LI stackdelta))],
460                      [T.MV (32, sp, addli (spreg, stackdelta))])
461    
462          val callseq =          val callseq =
463              List.concat [[T.MV (32, sp, T.SUB (32, spreg, LI stackdelta))],              List.concat [sp_sub,
464                           copycode,                           copycode,
465                           argsetupcode,                           argsetupcode,
466                           sretsetup,                           sretsetup,
# Line 429  Line 468 
468                           [call],                           [call],
469                           srethandshake,                           srethandshake,
470                           restore,                           restore,
471                           [T.MV (32, sp, addli (spreg, stackdelta))]]                           sp_add]
472    
473      in      in
474          { callseq = callseq, result = result }          { callseq = callseq, result = result }

Legend:
Removed from v.841  
changed lines
  Added in v.1523

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