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/mltree/x86.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/x86/mltree/x86.sml

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

revision 591, Mon Apr 3 01:19:20 2000 UTC revision 593, Tue Apr 4 07:26:33 2000 UTC
# Line 37  Line 37 
37       sharing X86MLTree.LabelExp = X86Instr.LabelExp       sharing X86MLTree.LabelExp = X86Instr.LabelExp
38      datatype arch = Pentium | PentiumPro | PentiumII | PentiumIII      datatype arch = Pentium | PentiumPro | PentiumII | PentiumIII
39      val arch : arch ref      val arch : arch ref
40      val tempMem : X86Instr.operand (* temporary for CVTI2F *)      val cvti2f :
41             (* source operand, guaranteed to be non-memory! *)
42             {ty: X86MLTree.ty, src: X86Instr.operand} ->
43             {instrs : X86Instr.instruction list,(* the instructions *)
44              tempMem: X86Instr.operand,         (* temporary for CVTI2F *)
45              cleanup: X86Instr.instruction list (* cleanup code *)
46             }
47    ) : sig include MLTREECOMP    ) : sig include MLTREECOMP
48            val rewriteMemReg : bool            val rewriteMemReg : bool
49        end =        end =
# Line 992  Line 998 
998             mark(fstp(fty, address(ea, mem)), an)             mark(fstp(fty, address(ea, mem)), an)
999            )            )
1000    
1001        and fexpr e = error "fexpr"        and fexpr e = (reduceFexp(64, e, []); C.ST(0))
1002    
1003            (* generate floating point expression and put the result in fd *)            (* generate floating point expression and put the result in fd *)
1004        and doFexpr(fty, T.FREG(_, fs), fd, an) =        and doFexpr(fty, T.FREG(_, fs), fd, an) =
# Line 1017  Line 1023 
1023        and reduceFexp(fty, fexp, an)  =        and reduceFexp(fty, fexp, an)  =
1024            let val ST = I.ST(C.ST 0)            let val ST = I.ST(C.ST 0)
1025                val ST1 = I.ST(C.ST 1)                val ST1 = I.ST(C.ST 1)
1026                  val cleanupCode = ref [] : I.instruction list ref
1027    
1028                datatype su_tree =                datatype su_tree =
1029                  LEAF of int * T.fexp * ans                  LEAF of int * T.fexp * ans
# Line 1168  Line 1175 
1175                 *)                 *)
1176                and leafEA(T.FREG(fty, f)) = (REAL, fty, I.FDirect f)                and leafEA(T.FREG(fty, f)) = (REAL, fty, I.FDirect f)
1177                  | leafEA(T.FLOAD(fty, ea, mem)) = (REAL, fty, address(ea, mem))                  | leafEA(T.FLOAD(fty, ea, mem)) = (REAL, fty, address(ea, mem))
1178                  | leafEA(T.CVTI2F(_, 32, t)) = int2real(32, I.MOVL, t)                  | leafEA(T.CVTI2F(_, 32, t)) = int2real(32, t)
1179                  | leafEA(T.CVTI2F(_, 16, t)) = int2real(16, I.MOVSWL, t)                  | leafEA(T.CVTI2F(_, 16, t)) = int2real(16, t)
1180                  | leafEA(T.CVTI2F(_, 8, t))  = int2real(8, I.MOVSBL, t)                  | leafEA(T.CVTI2F(_, 8, t))  = int2real(8, t)
1181                  | leafEA _ = error "leafEA"                  | leafEA _ = error "leafEA"
1182    
1183                (* Move integer t of size ty into a memory location *)                (* Move integer t of size ty into a memory location *)
1184                and int2real(ty, mov, t) =                and int2real(ty, t) =
1185                    let val opnd = operand t                    let val opnd = operand t
1186                    in  if isMemOpnd opnd andalso (ty = 16 orelse ty = 32)                    in  if isMemOpnd opnd andalso (ty = 16 orelse ty = 32)
1187                        then (INTEGER, ty, opnd)                        then (INTEGER, ty, opnd)
1188                        else (emit(I.MOVE{mvOp=mov, src=opnd, dst=tempMem});                        else
1189                              (INTEGER, 32, tempMem))                          let val {instrs, tempMem, cleanup} =
1190                                       cvti2f{ty=ty, src=opnd}
1191                            in  app emit instrs;
1192                                cleanupCode := !cleanupCode @ cleanup;
1193                                (INTEGER, 32, tempMem)
1194                            end
1195                    end                    end
1196            in  gencode(su fexp)            in  gencode(su fexp);
1197                  app emit(!cleanupCode)
1198            end (*reduceFexp*)            end (*reduceFexp*)
1199    
1200            (* generate code for a statement *)            (* generate code for a statement *)

Legend:
Removed from v.591  
changed lines
  Added in v.593

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