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 /MLRISC/trunk/staged-allocation/vararg-c-call-fn.sml
ViewVC logotype

Diff of /MLRISC/trunk/staged-allocation/vararg-c-call-fn.sml

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

revision 3063, Thu Jun 5 00:42:15 2008 UTC revision 3064, Thu Jun 5 07:20:32 2008 UTC
# Line 172  Line 172 
172             genStoreFStk arg fprTys             genStoreFStk arg fprTys
173          ]          ]
174    
   (* load a value from the argument *)  
     fun offArgs args 0 =  
             T.LOAD (wordTy, T.REG(wordTy, args), mem)  
       | offArgs args off =  
             T.LOAD (wordTy, T.ADD (wordTy, T.REG(wordTy, args), lit(off*defaultWidthB)), mem)  
   
175    (* call the varargs C function *)    (* call the varargs C function *)
176      fun genCallC cFun = let      fun genCallC cFun = let
177             val defs = List.map gpr CCall.callerSaveRegs @ List.map (fn r => fpr(64, r)) CCall.callerSaveFRegs             val defs = List.map gpr CCall.callerSaveRegs @ List.map (fn r => fpr(64, r)) CCall.callerSaveFRegs
# Line 190  Line 184 
184             end             end
185    
186    (* interpreter for varargs *)    (* interpreter for varargs *)
187      fun genInterp (args, argReg) = [      fun genInterp (args, argsReg, endOfArgs) = [
188             T.DEFINE interpLab,             T.DEFINE interpLab,
189           (* loop through the args *)           (* loop through the args *)
190             T.BCC (T.CMP(wordTy, T.EQ, T.REG (wordTy, args), lit Consts.NIL), gotoCLab),              T.MV (wordTy, argsReg, T.ADD (wordTy, args, lit Consts.zippedArgSzB)),
191             T.MV (wordTy, argReg, offArgs args Consts.HD),              T.BCC (T.CMP(wordTy, T.GE, args, endOfArgs), gotoCLab)
            T.MV(wordTy, args, offArgs args Consts.TL),  
            T.JMP (T.LABEL resolveKindsLab, [])  
192          ]          ]
193    
194    (* generate all possible general-purpose register loads *)    (* generate all possible general-purpose register loads *)
# Line 214  Line 206 
206              end              end
207    
208    (* generate instructions for making a varargs call *)    (* generate instructions for making a varargs call *)
209      fun genVarargs (cFun, args) = let      fun genVarargs (cFun, argsReg, endOfArgs) = let
210              val argReg = newReg ()              val arg = T.REG (wordTy, argsReg)
             val arg = T.REG(wordTy, argReg)  
211              in              in
212                List.concat [                List.concat [
213                   genInterp(args, argReg),                   genInterp(arg, argsReg, endOfArgs),
214                   genResolveKinds arg,                   genResolveKinds arg,
215                   resolveArgLocs arg,                   resolveArgLocs arg,
216                   genResolveTys arg,                   genResolveTys arg,

Legend:
Removed from v.3063  
changed lines
  Added in v.3064

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