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/amd64/staged-allocation/amd64-svid-fn.sml
ViewVC logotype

Diff of /MLRISC/trunk/amd64/staged-allocation/amd64-svid-fn.sml

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

revision 3048, Thu May 29 22:14:42 2008 UTC revision 3049, Fri May 30 00:58:55 2008 UTC
# Line 25  Line 25 
25      fun sum ls = List.foldl (op +) 0 ls      fun sum ls = List.foldl (op +) 0 ls
26      fun szBOfCTy cTy = #sz (CSizes.sizeOfTy cTy)      fun szBOfCTy cTy = #sz (CSizes.sizeOfTy cTy)
27      fun alignBOfCTy cTy = #align (CSizes.sizeOfTy cTy)      fun alignBOfCTy cTy = #align (CSizes.sizeOfTy cTy)
28        val spReg = T.REG (wordTy, C.rsp)
29        fun offSp 0 = spReg
30          | offSp offset = T.ADD (wordTy, spReg, T.LI offset)
31    
32      fun toGpr r = (wordTy, r)      structure CCall = CCallFn (
33      fun toGprs gprs = List.map toGpr gprs                          structure T = T
34      fun toFpr r = (64, r)                          structure C = C
35      fun toFprs fprs = List.map toFpr fprs                          val wordTy = wordTy
36                            val offSp = offSp)
37    
38      datatype location_kind      datatype c_arg = datatype CCall.c_arg
39        = K_GPR                (* general-purpose registers *)      datatype arg_location = datatype CCall.arg_location
40        | K_FPR                (* floating-point registers *)      datatype location_kinds = datatype CCall.location_kinds
       | K_MEM                (* memory locations *)  
41    
42      structure SA = StagedAllocationFn (      structure SA = StagedAllocationFn (
43                           structure T = T                           type reg = T.reg
44                           structure TargetLang = struct                           datatype location_kinds = datatype location_kinds
                            datatype location_kind = datatype location_kind  
                          end  
45                           val memSize = 8 (* bytes *))                           val memSize = 8 (* bytes *))
46    
47      structure CCs =      structure CCs =
48        struct        struct
49    
50            fun toGpr r = (wordTy, r)
51            fun toGprs gprs = List.map toGpr gprs
52            fun toFpr r = (64, r)
53            fun toFprs fprs = List.map toFpr fprs
54    
55          val calleeSaveRegs = toGprs [C.rbx, C.r12, C.r13, C.r14, C.r15]          val calleeSaveRegs = toGprs [C.rbx, C.r12, C.r13, C.r14, C.r15]
56          val callerSaveRegs = toGprs [C.rax, C.rcx, C.rdx, C.rsi, C.rdi, C.r8, C.r9, C.r10, C.r11]          val callerSaveRegs = toGprs [C.rax, C.rcx, C.rdx, C.rsi, C.rdi, C.r8, C.r9, C.r10, C.r11]
57          val callerSaveFRegs = toFprs (C.Regs CB.FP {from=0, to=15, step=1})          val callerSaveFRegs = toFprs (C.Regs CB.FP {from=0, to=15, step=1})
58          val calleeSaveFRegs = []          val calleeSaveFRegs = []
         val spReg = T.REG (wordTy, C.rsp)  
59    
60          val frameAlignB = 16          val frameAlignB = 16
61          val maxAlign = 16          val maxAlign = 16
# Line 107  Line 112 
112    
113      val calleeSaveRegs : CB.cell list = List.map (fn (_, r) => r) CCs.calleeSaveRegs      val calleeSaveRegs : CB.cell list = List.map (fn (_, r) => r) CCs.calleeSaveRegs
114      val calleeSaveFRegs :CB.cell list = List.map (fn (_, r) => r) CCs.calleeSaveFRegs      val calleeSaveFRegs :CB.cell list = List.map (fn (_, r) => r) CCs.calleeSaveFRegs
115        val callerSaveRegs : CB.cell list = List.map (fn (_, r) => r) CCs.callerSaveRegs
116      fun offSp 0 = CCs.spReg      val callerSaveFRegs :CB.cell list = List.map (fn (_, r) => r) CCs.callerSaveFRegs
       | offSp offset = T.ADD (wordTy, CCs.spReg, T.LI offset)  
   
     structure CCall = CCallFn (  
                         structure T = T  
                         structure C = C  
                         val wordTy = wordTy  
                         val offSp = offSp)  
   
     datatype c_arg = datatype CCall.c_arg  
     datatype arg_location = datatype CCall.arg_location  
117    
118    (* convert a list of C types to a list of eight bytes *)    (* convert a list of C types to a list of eight bytes *)
119      fun eightBytesOfCTys ([], [], ebs) = List.rev (List.map List.rev ebs)      fun eightBytesOfCTys ([], [], ebs) = List.rev (List.map List.rev ebs)
# Line 195  Line 190 
190                  of CTy.C_void => ([], NONE, CCs.str0)                  of CTy.C_void => ([], NONE, CCs.str0)
191                   | retTy => let                   | retTy => let
192                         val (str, locs) = SA.doStagedAllocation(CCs.str0, returnStepper, slotsOfCTy retTy)                         val (str, locs) = SA.doStagedAllocation(CCs.str0, returnStepper, slotsOfCTy retTy)
193                           val {sz, align} = CSizes.sizeOfTy retTy
194                         in                         in
195                             (List.map cLocOfStagedAlloc locs, SOME (CSizes.sizeOfTy retTy), str)                             (List.map cLocOfStagedAlloc locs, SOME {szb=szb, align=align}, str)
196                         end                         end
197              end              end
198    
# Line 244  Line 240 
240          val {argLocs, argMem, resLocs, structRetLoc} = layout(proto)          val {argLocs, argMem, resLocs, structRetLoc} = layout(proto)
241          val argAlloc = if ((#szb argMem = 0) orelse paramAlloc argMem)          val argAlloc = if ((#szb argMem = 0) orelse paramAlloc argMem)
242                          then []                          then []
243                          else [T.MV (wordTy, C.rsp, T.SUB (wordTy, CCs.spReg,                          else [T.MV (wordTy, C.rsp, T.SUB (wordTy, spReg,
244                                T.LI (T.I.fromInt (wordTy, #szb argMem))))]                                T.LI (T.I.fromInt (wordTy, #szb argMem))))]
245          val (copyArgs, gprUses, fprUses) = CCall.copyArgs(args, argLocs)          val (copyArgs, gprUses, fprUses) = CCall.copyArgs(args, argLocs)
246         (* the defined registers of the call depend on the calling convention *)         (* the defined registers of the call depend on the calling convention *)

Legend:
Removed from v.3048  
changed lines
  Added in v.3049

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