CVS: sml/src/MLRISC/x86/c-calls ia32-svid.sml,1.36,1.37

John Reppy <[email protected]>
Newsgroups gmane.comp.lang.sml.smlnj.commits
Message-ID <[email protected]>
Update of /cvsroot/smlnj/sml/src/MLRISC/x86/c-calls
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29839

Modified Files:
	ia32-svid.sml 
Log Message:
  Two bugs fixed: the floating-point stack needs to be killed by calls
  and %st(0) was being returned as the result register (instead of the
  freshly allocated pseudo register).


Index: ia32-svid.sml
===================================================================
RCS file: /cvsroot/smlnj/sml/src/MLRISC/x86/c-calls/ia32-svid.sml,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** ia32-svid.sml	28 Oct 2004 04:15:08 -0000	1.36
--- ia32-svid.sml	13 Feb 2005 03:52:06 -0000	1.37
***************
*** 93,96 ****
--- 93,102 ----
      val st0 = C.ST(0)
  
+   (* the C calling convention requires that the FP stack be empty on function
+    * entry.  We add the fpStk list to the defs when the fast_floating_point flag
+    * is set.
+    *)
+     val fpStk = List.tabulate(8, fn i => fpr(xdblTy, C.ST i))
+ 
    (* note that the caller saves includes the result register (%eax) *)
      val callerSaves = [gpr(wordTy, eax), gpr(wordTy, C.ecx), gpr(wordTy, C.edx)]
***************
*** 263,272 ****
     * is the result registers plus the caller-save registers.
     *)
!     fun definedRegs (Ty.C_float) = fpr(fltTy, st0) :: callerSaves
!       | definedRegs (Ty.C_double) = fpr(dblTy, st0) :: callerSaves
!       | definedRegs (Ty.C_long_double) = fpr(xdblTy, st0) :: callerSaves
!       | definedRegs (Ty.C_unsigned(Ty.I_long_long)) = gpr(wordTy, C.edx) :: callerSaves
!       | definedRegs (Ty.C_signed(Ty.I_long_long)) = gpr(wordTy, C.edx) :: callerSaves
!       | definedRegs _ = callerSaves
  
      fun fstp (32, f) = T.EXT(ix(IX.FSTPS(f)))
--- 269,290 ----
     * is the result registers plus the caller-save registers.
     *)
!     fun definedRegs resTy = if !fast_floating_point
! 	  then let
! 	    val defs = callerSaves @ fpStk
! 	    in
! 	      case resTy
! 	       of (Ty.C_unsigned(Ty.I_long_long)) => gpr(wordTy, C.edx) :: defs
! 		| (Ty.C_signed(Ty.I_long_long)) => gpr(wordTy, C.edx) :: defs
! 		| _ => defs
! 	      (* end case *)
! 	    end
! 	  else (case resTy
! 	     of (Ty.C_float) => fpr(fltTy, st0) :: callerSaves
! 	      | (Ty.C_double) => fpr(dblTy, st0) :: callerSaves
! 	      | (Ty.C_long_double) => fpr(xdblTy, st0) :: callerSaves
! 	      | (Ty.C_unsigned(Ty.I_long_long)) => gpr(wordTy, C.edx) :: callerSaves
! 	      | (Ty.C_signed(Ty.I_long_long)) => gpr(wordTy, C.edx) :: callerSaves
! 	      | _ => callerSaves
! 	    (* end case *))
  
      fun fstp (32, f) = T.EXT(ix(IX.FSTPS(f)))
***************
*** 414,418 ****
  		  | SOME(FReg(ty, r, _)) => let
  		      val resReg = C.newFreg()
! 		      val res = [T.FPR(T.FREG(ty, r))]
  		      in
          	      (* If we are using fast floating point mode then do NOT 
--- 432,436 ----
  		  | SOME(FReg(ty, r, _)) => let
  		      val resReg = C.newFreg()
! 		      val res = [T.FPR(T.FREG(ty, resReg))]
  		      in
          	      (* If we are using fast floating point mode then do NOT 



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.