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 776, Fri Jan 12 04:14:06 2001 UTC revision 777, Fri Jan 12 12:17:38 2001 UTC
# Line 58  Line 58 
58      | FARG of T.fexp      | FARG of T.fexp
59      | ARGS of c_arg list      | ARGS of c_arg list
60    
61    fun genCall0 use_tmpsp    fun genCall {name, proto={conv, retTy, paramTys}, structRet, args} =
62                 {name, proto={conv="", retTy, paramTys}, structRet, args} =        (* If use_tmpsp, then we must use a temporary stack pointer
63        let val mem = T.Region.memory         * almost all the time.  (If virtual registers are used,
64           * they are being accessed via the real stack pointer.
65           * Moving that stack pointer before all references to
66           * virtual registers are done with would obviously break
67           * things... *)
68          let val use_tmpsp =
69                  case conv of
70                      "SMLNJ" => true
71                    | "" => false
72                    | _ => error(concat["unknown calling convention \"",
73                                        String.toString conv, "\""])
74    
75              val mem = T.Region.memory
76            val stack = T.Region.memory            val stack = T.Region.memory
77    
78            (* map C integer types to their MLRisc type *)            (* map C integer types to their MLRisc type *)
# Line 329  Line 341 
341                  (*esac*))                  (*esac*))
342    
343            (* call defines callersave registers and uses result registers. *)            (* call defines callersave registers and uses result registers. *)
344            fun mkCall (defs, 0) =            fun mkCall (defs, n) = let
               [T.CALL { funct = name, targets = [], defs = defs, uses = [],  
                         region = T.Region.memory }]  
             | mkCall (defs, n) = let  
345                    fun call f = T.CALL { funct = f, targets = [],                    fun call f = T.CALL { funct = f, targets = [],
346                                          defs = defs, uses = [],                                          defs = defs, uses = [],
347                                          region=T.Region.memory }                                          region=T.Region.memory }
348                    val pop = T.MV (32, sp, T.ADD (32, T.REG (32, sp), LI n))                    val pop = T.MV (32, sp, T.ADD (32, T.REG (32, sp), LI n))
349                in                in
350                    if use_tmpsp then [T.MV (32, C.eax, name),                (* Although the real stack pointer needs to be moved
351                   * eventually even when use_tmpsp is set, we do so at the
352                   * last possible moment to avoid earlier interferences with
353                   * virtual registers. *)
354                  case (use_tmpsp, n) of
355                      (false, 0) => [call name]
356                    | (true, 0) => [T.MV (32, C.eax, name), (* why? *)
357                                    call (T.REG (32, C.eax))]
358                    | (false, _) => [call name,
359                                     pop]
360                    | (true, _) => [T.MV (32, C.eax, name),
361                                       T.MV (32, sp, T.REG(32,mysp)),                                       T.MV (32, sp, T.REG(32,mysp)),
362                                       call (T.REG(32,C.eax)),                                       call (T.REG(32,C.eax)),
363                                       pop]                                       pop]
                   else [call name, pop]  
364                end                end
365    
366            (* size to pop off on return *)            (* size to pop off on return *)
# Line 365  Line 383 
383                else callSeq0                else callSeq0
384        in {callseq=callSeq, result=retRegs}        in {callseq=callSeq, result=retRegs}
385        end        end
     | genCall0 _ {proto={conv, ...}, ...} =  
       error(concat["unknown calling convention \"",  
                    String.toString conv, "\""])  
   
   val genCall = genCall0 false  
   val tmpsp_genCall = genCall0 true  
386  end  end

Legend:
Removed from v.776  
changed lines
  Added in v.777

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