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/vararg-ccall/ia32-vararg-ccall.sml
ViewVC logotype

Diff of /MLRISC/trunk/vararg-ccall/ia32-vararg-ccall.sml

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

revision 3067, Thu Jun 5 22:18:34 2008 UTC revision 3068, Fri Jun 6 00:25:53 2008 UTC
# Line 47  Line 47 
47    
48      structure CTy = CTypes      structure CTy = CTypes
49      structure Consts = VarargCCallConstants      structure Consts = VarargCCallConstants
     structure V = VarArgs  
50      structure CB = CellsBasis      structure CB = CellsBasis
51      structure T = X86MLTree      structure T = X86MLTree
52    
# Line 55  Line 54 
54    
55      val regToInt = CB.physicalRegisterNum      val regToInt = CB.physicalRegisterNum
56    
57      fun argToCTy (V.I _) = CTy.C_signed CTy.I_int      fun argToCTy (VarargCCall.I _) = CTy.C_signed CTy.I_int
58        | argToCTy (V.R _) = CTy.C_double        | argToCTy (VarargCCall.R _) = CTy.C_double
59        | argToCTy (V.B _) = CTy.C_signed CTy.I_int        | argToCTy (VarargCCall.B _) = CTy.C_signed CTy.I_int
60        | argToCTy (V.S _) = CTy.C_PTR        | argToCTy (VarargCCall.S _) = CTy.C_PTR
61    
62    (* runtime friendly representation of the C location *)    (* runtime friendly representation of the C location *)
63      fun encodeCLoc (CCall.C_GPR (ty, r)) = (Consts.GPR, regToInt r, ty)      fun encodeCLoc (CCall.C_GPR (ty, r)) = (Consts.GPR, regToInt r, ty)
# Line 73  Line 72 
72               (arg, k, l, ty)               (arg, k, l, ty)
73             end             end
74    
75        fun argToStr (CTy.C_double) = "doub"
76          | argToStr CTy.C_PTR = "ptr"
77          | argToStr _ = "int"
78    
79    
80    (* package the arguments with their locations *)    (* package the arguments with their locations *)
81      fun zipArgs args = let      fun zipArgs args = let
82              val argTys = List.map argToCTy args              val argTys = List.map argToCTy args
# Line 80  Line 84 
84            (* expect single locations, as we do not pass aggregates to vararg functions *)            (* expect single locations, as we do not pass aggregates to vararg functions *)
85              val argLocs = List.map List.hd argLocs              val argLocs = List.map List.hd argLocs
86              in              in
87                  (ListPair.mapEq varArg (args, List.rev argLocs), argMem)                  ListPair.mapEq varArg (args, argLocs)
88              end              end
89    
90    (* align the frame to 16 bytes *)      fun callWithArgs (cFun, args) = VarargCCall.vararg(cFun, zipArgs args)
     fun darwinStkSzB stkArgSzB = let  
            val retAndFrameSzB = 2*4  
            val stkAllocSzB = stkArgSzB + retAndFrameSzB  
            val stkAllocSzB = IA32CSizes.alignAddr(stkAllocSzB, 16)  
            val stkAllocSzB = stkAllocSzB - retAndFrameSzB  
            in  
                stkAllocSzB  
            end  
   
     fun callWithArgs (cFun, args) = let  
            val (zippedArgs, {szb, ...}) = zipArgs args  
            in  
               VarargCCall.vararg(cFun, zippedArgs, darwinStkSzB szb)  
            end  
91    
92    end    end
93    

Legend:
Removed from v.3067  
changed lines
  Added in v.3068

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