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/x86/c-calls/ia32-svid.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/x86/c-calls/ia32-svid.sml

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

revision 694, Thu Jul 27 16:00:25 2000 UTC revision 695, Mon Aug 7 23:57:38 2000 UTC
# Line 6  Line 6 
6   *   *
7   * Register conventions:   * Register conventions:
8   *   *
9   *    %eax      return value   *    %eax      return value            (caller save)
10   *    %ebx      global offset for PIC   (callee save)   *    %ebx      global offset for PIC   (callee save)
11   *    %ecx      scratch                 (caller save)   *    %ecx      scratch                 (caller save)
12   *    %edx      extra return/scratch    (caller save)   *    %edx      extra return/scratch    (caller save)
# Line 96  Line 96 
96      fun fpr(sz,f) = T.FPR(T.FREG(sz, f))      fun fpr(sz,f) = T.FPR(T.FREG(sz, f))
97      fun gpr(sz,r) = T.GPR(T.REG(sz, r))      fun gpr(sz,r) = T.GPR(T.REG(sz, r))
98      val st0 = C.ST(0)      val st0 = C.ST(0)
99      fun eax(sz) = [gpr(sz, C.eax)]    (* note that the caller saves includes the result register (%eax) *)
100      val eax32 = eax(32)      val callerSaves = [gpr(32, C.eax), gpr(32, C.ecx), gpr(32, C.edx)]
101      val pair = gpr(32, C.edx):: eax32      val oneRes = [gpr(32, C.eax)]
102        val twoRes = [gpr(32, C.edx), gpr(32, C.eax)]
103    in    in
104     (* List of result registers;     (* List of registers defined by a C Call; this is the result registers
105        * plus the caller save registers.
106      * Multiple returns have most significant register first.      * Multiple returns have most significant register first.
107      *)      *)
108      fun results(Ty.C_void) = []      fun resultsAndDefs (Ty.C_void) = ([], callerSaves)
109        | results(Ty.C_float) = [fpr(32, st0)]        | resultsAndDefs (Ty.C_float) =
110        | results(Ty.C_double) = [fpr(64, st0)]            ([fpr(32, st0)], fpr(32, st0) :: callerSaves)
111        | results(Ty.C_long_double) = [fpr(80, st0)]        | resultsAndDefs (Ty.C_double) =
112        | results(Ty.C_unsigned(Ty.I_long_long)) = pair            ([fpr(64, st0)], fpr(64, st0) :: callerSaves)
113        | results(Ty.C_signed(Ty.I_long_long)) =  pair        | resultsAndDefs (Ty.C_long_double) =
114        | results(Ty.C_unsigned i) = eax(intTy i)            ([fpr(80, st0)], fpr(80, st0) :: callerSaves)
115        | results(Ty.C_signed i) = eax(intTy i)        | resultsAndDefs (Ty.C_unsigned(Ty.I_long_long)) =
116        | results(Ty.C_PTR) = eax32            (twoRes, gpr(32, C.edx) :: callerSaves)
117        | results(Ty.C_ARRAY _) = eax32        | resultsAndDefs (Ty.C_signed(Ty.I_long_long)) =
118        | results(Ty.C_STRUCT _) = eax32            (twoRes, gpr(32, C.edx) :: callerSaves)
119          | resultsAndDefs (Ty.C_unsigned i) = (oneRes, callerSaves)
120          | resultsAndDefs (Ty.C_signed i) = (oneRes, callerSaves)
121          | resultsAndDefs (Ty.C_PTR) = (oneRes, callerSaves)
122          | resultsAndDefs (Ty.C_ARRAY _) = (oneRes, callerSaves)
123          | resultsAndDefs (Ty.C_STRUCT _) = (oneRes, callerSaves)
124    
125      fun fstp (sz, f)  =      fun fstp (sz, f)  =
126        (case sz        (case sz
# Line 288  Line 295 
295       (*esac*))       (*esac*))
296    
297      (* call defines callersave registers and uses result registers. *)      (* call defines callersave registers and uses result registers. *)
298      fun mkCall uses = let      fun mkCall defs = T.CALL{
299        val defs = [T.GPR(T.REG(32,C.ecx)), T.GPR(T.REG(32,C.edx))]              funct=name, targets=[], defs=defs, uses=[],
300      in T.CALL{funct=name, targets=[], defs=defs, uses=uses,              cdefs=[], cuses=[], region=T.Region.memory
301                cdefs=[], cuses=[], region=T.Region.memory}            }
     end  
302    
303      (* size to pop off on return *)      (* size to pop off on return *)
304      fun argsSz(Ty.C_STRUCT fields::rest) = let      fun argsSz(Ty.C_STRUCT fields::rest) = let
# Line 308  Line 314 
314        | argsSz [] = 0        | argsSz [] = 0
315    
316    
317      val c_rets = results(retTy)      val (cRets, cDefs) = resultsAndDefs (retTy)
318      val (retRegs, cpyOut) = copyOut(c_rets, [], [])      val (retRegs, cpyOut) = copyOut(cRets, [], [])
319      val popArgs = T.MV(32, sp, T.ADD(32, T.REG(32,sp), T.LI(argsSz paramTys)))      val call = mkCall(cDefs) :: (case argsSz paramTys
320      val call = mkCall(c_rets)::popArgs::cpyOut           of 0 => cpyOut
321              | n => T.MV(32, sp, T.ADD(32, T.REG(32,sp), T.LI n)) :: cpyOut
322            (* end case *))
323      val callSeq = pushArgs(paramTys, args, pushStructRetAddr(call))      val callSeq = pushArgs(paramTys, args, pushStructRetAddr(call))
324    in {callseq=callSeq, result=retRegs}    in {callseq=callSeq, result=retRegs}
325    end    end
# Line 321  Line 329 
329  end  end
330    
331    
332    

Legend:
Removed from v.694  
changed lines
  Added in v.695

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