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 1445, Mon Jan 26 15:20:12 2004 UTC revision 1521, Wed Jun 30 21:44:58 2004 UTC
# Line 84  Line 84 
84    
85    ): PPC_MACOSX_C_CALLS = struct    ): PPC_MACOSX_C_CALLS = struct
86      structure T  = T      structure T  = T
87      structure Ty = CTypes      structure CTy = CTypes
88      structure C = PPCCells      structure C = PPCCells
89      structure IX = PPCInstrExt      structure IX = PPCInstrExt
90    
91      fun error msg = MLRiscErrorMsg.error ("PPCCompCCalls", msg)      fun error msg = MLRiscErrorMsg.error ("PPCCompCCalls", msg)
92    
93      (* the location of arguments/parameters; offsets are given with respect to the
94       * low end of the parameter area.
95       *)
96        datatype arg_location
97          = Reg of T.ty * T.reg             (* integer/pointer argument in register *)
98          | FReg of T.fty * T.freg          (* floating-point argument in register *)
99          | Stk of T.ty * T.I.machine_int   (* integer/pointer argument in parameter area *)
100          | FStk of T.fty * T.I.machine_int (* floating-point argument in parameter area *)
101          | Args of arg_location list
102    
103    (* ?? use arg_location instead of the following? *)
104      datatype arg_loc      datatype arg_loc
105        = GPR of C.cell        = GPR of C.cell
106          | GPR2 of C.cell * C.cell
107        | FPR of C.cell        | FPR of C.cell
108        | STK        | STK
109    
# Line 100  Line 112 
112          loc : arg_loc           (* location where argument is passed *)          loc : arg_loc           (* location where argument is passed *)
113        }        }
114    
115      (* registers used for parameter passing *)
116        val argGPRs = List.map C.GPReg [3, 4, 5, 6, 7, 8, 9, 10]
117        val argFPRs = List.map C.FPReg [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
118    
119      (* C callee-save registers *)
120        val calleeSaveRegs = List.map C.GPReg [
121                13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
122                23, 24, 25, 26, 27, 28, 29, 30, 31
123              ]
124        val calleeSaveFRegs = List.map C.FPReg [
125                14, 15, 16, 17, 18, 19, 20, 21, 22,
126                23, 24, 25, 26, 27, 28, 29, 30, 31
127              ]
128    
129      (* size of integer types *)
130        fun sizeOf CTy.I_char = {sz = 1, pad = 3}
131          | sizeOf CTy.I_short = {sz = 2, pad = 2}
132          | sizeOf CTy.I_int = {sz = 4, pad = 0}
133          | sizeOf CTy.I_long = {sz = 4, pad = 0}
134          | sizeOf CTy.I_long_long = {sz = 8, pad = 0}
135    
136      (* compute the layout of a C call's arguments *)
137        fun layout {conv, retTy, paramTys} = let
138              val structRet = (case retTy
139                     of CTy.C_STRUCT _ => true
140                      | _ => false
141                    (* end case *))
142              fun assign ([], offset, _, _, layout) = {sz = offset, layout = List.rev layout}
143                | assign (arg::args, offset, availGPRs, availFPRs, layout) = (
144                    case arg
145                     of CTy.C_void => error "unexpected void argument type"
146                      | CTy.C_float =>
147                      | CTy.C_double =>
148                      | CTy.C_long_double =>
149                      | CTy.C_unsigned isz =>
150                      | CTy.C_signed isz =>
151                      | CTy.C_PTR =>
152                      | CTy.C_ARRAY _ =>
153                      | CTy.C_STRUCT tys =>
154                    (* end case *))
155              and assignGPR (offset, sz, pad, availGPRs, availFPRs) = let
156                    val offset' = offset + sz + pad
157                    in
158                      ({offset = offset, loc = loc}, offset')
159                    end
160                | assignGPR (args, offset, [], availFPRs) =
161              and assignFPR (offset, gpr::availGPRs, fpr::availFPRs) =
162                | assignFPR (offset, [], fpr::availFPRs) =
163                | assignFPR (offset, [], []) =
164              in
165                assign (paramTys, 0, argGPRs, argFPRs, [])
166              end
167    
168      datatype c_arg      datatype c_arg
169        = ARG of T.rexp        = ARG of T.rexp
170        | FARG of T.fexp        | FARG of T.fexp

Legend:
Removed from v.1445  
changed lines
  Added in v.1521

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