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 774, Wed Jan 10 12:50:56 2001 UTC revision 775, Fri Jan 12 01:17:51 2001 UTC
# Line 39  Line 39 
39    
40  functor X86  functor X86
41    (structure X86Instr : X86INSTR    (structure X86Instr : X86INSTR
    structure X86MLTree : MLTREE  
42     structure ExtensionComp : MLTREE_EXTENSION_COMP     structure ExtensionComp : MLTREE_EXTENSION_COMP
43       where I = X86Instr and T = X86MLTree       where I = X86Instr
      sharing X86MLTree.Region = X86Instr.Region  
      sharing X86MLTree.LabelExp = X86Instr.LabelExp  
44      datatype arch = Pentium | PentiumPro | PentiumII | PentiumIII      datatype arch = Pentium | PentiumPro | PentiumII | PentiumIII
45      val arch : arch ref      val arch : arch ref
46      val cvti2f :      val cvti2f :
47           (* source operand, guaranteed to be non-memory! *)           (* source operand, guaranteed to be non-memory! *)
48           {ty: X86MLTree.ty, src: X86Instr.operand} ->           {ty: X86Instr.T.ty, src: X86Instr.operand} ->
49           {instrs : X86Instr.instruction list,(* the instructions *)           {instrs : X86Instr.instruction list,(* the instructions *)
50            tempMem: X86Instr.operand,         (* temporary for CVTI2F *)            tempMem: X86Instr.operand,         (* temporary for CVTI2F *)
51            cleanup: X86Instr.instruction list (* cleanup code *)            cleanup: X86Instr.instruction list (* cleanup code *)
# Line 61  Line 58 
58            val rewriteMemReg : bool            val rewriteMemReg : bool
59        end =        end =
60  struct  struct
   structure T = X86MLTree  
   structure S = T.Stream  
61    structure I = X86Instr    structure I = X86Instr
62      structure T = I.T
63      structure S = T.Stream
64    structure C = I.C    structure C = I.C
65    structure Shuffle = Shuffle(I)    structure Shuffle = Shuffle(I)
66    structure W32 = Word32    structure W32 = Word32
# Line 132  Line 129 
129              case !trapLabel of              case !trapLabel of
130                NONE => let val label = Label.newLabel "trap"                NONE => let val label = Label.newLabel "trap"
131                            val jmp   = I.JCC{cond=I.O,                            val jmp   = I.JCC{cond=I.O,
132                                              opnd=I.ImmedLabel(LE.LABEL label)}                                              opnd=I.ImmedLabel(T.LABEL label)}
133                        in  trapLabel := SOME(jmp, label); jmp end                        in  trapLabel := SOME(jmp, label); jmp end
134              | SOME(jmp, _) => jmp              | SOME(jmp, _) => jmp
135        in  emit jmp end        in  emit jmp end
# Line 191  Line 188 
188        val ecx = I.Direct(C.ecx)        val ecx = I.Direct(C.ecx)
189        val edx = I.Direct(C.edx)        val edx = I.Direct(C.edx)
190    
191        fun immedLabel lab = I.ImmedLabel(LE.LABEL lab)        fun immedLabel lab = I.ImmedLabel(T.LABEL lab)
192    
193        (* Is the expression zero? *)        (* Is the expression zero? *)
194        fun isZero(T.LI z) = T.I.isZero z        fun isZero(T.LI z) = T.I.isZero z
# Line 296  Line 293 
293              | doEA(t::trees, b, i, s, d) =              | doEA(t::trees, b, i, s, d) =
294                (case t of                (case t of
295                   T.LI n   => doEAImmed(trees, toInt32 n, b, i, s, d)                   T.LI n   => doEAImmed(trees, toInt32 n, b, i, s, d)
296                 | T.CONST c => doEALabel(trees, LE.CONST c, b, i, s, d)                 | T.CONST _ => doEALabel(trees, t, b, i, s, d)
297                 | T.LABEL le => doEALabel(trees, le, b, i, s, d)                 | T.LABEL _ => doEALabel(trees, t, b, i, s, d)
298                   | T.LABEXP le => doEALabel(trees, le, b, i, s, d)
299                 | T.ADD(32, t1, t2 as T.REG(_,r)) =>                 | T.ADD(32, t1, t2 as T.REG(_,r)) =>
300                      if isMemReg r then doEA(t2::t1::trees, b, i, s, d)                      if isMemReg r then doEA(t2::t1::trees, b, i, s, d)
301                      else doEA(t1::t2::trees, b, i, s, d)                      else doEA(t1::t2::trees, b, i, s, d)
# Line 322  Line 320 
320              | doEAImmed(trees, n, b, i, s, I.Immed m) =              | doEAImmed(trees, n, b, i, s, I.Immed m) =
321                   doEA(trees, b, i, s, I.Immed(n+m))                   doEA(trees, b, i, s, I.Immed(n+m))
322              | doEAImmed(trees, n, b, i, s, I.ImmedLabel le) =              | doEAImmed(trees, n, b, i, s, I.ImmedLabel le) =
323                   doEA(trees, b, i, s, I.ImmedLabel(LE.PLUS(le,LE.INT(Int32.toInt n))))                   doEA(trees, b, i, s,
324                          I.ImmedLabel(T.ADD(32,le,T.LI(T.I.fromInt32(32, n)))))
325              | doEAImmed(trees, n, b, i, s, _) = error "doEAImmed"              | doEAImmed(trees, n, b, i, s, _) = error "doEAImmed"
326    
327            (* Add a label expression *)            (* Add a label expression *)
# Line 330  Line 329 
329                   doEA(trees, b, i, s, I.ImmedLabel le)                   doEA(trees, b, i, s, I.ImmedLabel le)
330              | doEALabel(trees, le, b, i, s, I.Immed m) =              | doEALabel(trees, le, b, i, s, I.Immed m) =
331                   doEA(trees, b, i, s,                   doEA(trees, b, i, s,
332                        I.ImmedLabel(LE.PLUS(le,LE.INT(Int32.toInt m)))                        I.ImmedLabel(T.ADD(32,le,T.LI(T.I.fromInt32(32, m))))
333                        handle Overflow => error "doEALabel: constant too large")                        handle Overflow => error "doEALabel: constant too large")
334              | doEALabel(trees, le, b, i, s, I.ImmedLabel le') =              | doEALabel(trees, le, b, i, s, I.ImmedLabel le') =
335                   doEA(trees, b, i, s, I.ImmedLabel(LE.PLUS(le,le')))                   doEA(trees, b, i, s, I.ImmedLabel(T.ADD(32,le,le')))
336              | doEALabel(trees, le, b, i, s, _) = error "doEALabel"              | doEALabel(trees, le, b, i, s, _) = error "doEALabel"
337    
338            and makeAddressingMode(NONE, NONE, _, disp) = disp            and makeAddressingMode(NONE, NONE, _, disp) = disp
# Line 391  Line 390 
390    
391            (* reduce an expression into an operand *)            (* reduce an expression into an operand *)
392        and operand(T.LI i) = I.Immed(toInt32(i))        and operand(T.LI i) = I.Immed(toInt32(i))
393          | operand(T.CONST c) = I.ImmedLabel(LE.CONST c)          | operand(x as (T.CONST _ | T.LABEL _)) = I.ImmedLabel x
394          | operand(T.LABEL lab) = I.ImmedLabel lab          | operand(T.LABEXP le) = I.ImmedLabel le
395          | operand(T.REG(_,r)) = IntReg r          | operand(T.REG(_,r)) = IntReg r
396          | operand(T.LOAD(32,ea,mem)) = address(ea, mem)          | operand(T.LOAD(32,ea,mem)) = address(ea, mem)
397          | operand(t) = I.Direct(expr t)          | operand(t) = I.Direct(expr t)
# Line 787  Line 786 
786                   else                   else
787                     move'(I.Immed(n), rdOpnd, an)                     move'(I.Immed(n), rdOpnd, an)
788                 end                 end
789               | T.CONST c   => move'(I.ImmedLabel(LE.CONST c), rdOpnd, an)               | (T.CONST _ | T.LABEL _) =>
790               | T.LABEL lab => move'(I.ImmedLabel lab, rdOpnd, an)                   move'(I.ImmedLabel exp, rdOpnd, an)
791                 | T.LABEXP le => move'(I.ImmedLabel le, rdOpnd, an)
792    
793                 (* 32-bit addition *)                 (* 32-bit addition *)
794               | T.ADD(32, e1, e2 as T.LI n) => let               | T.ADD(32, e1, e2 as T.LI n) => let
# Line 1009  Line 1009 
1009            end            end
1010    
1011            (* generate code for jumps *)            (* generate code for jumps *)
1012        and jmp(T.LABEL(lexp as LE.LABEL lab), labs, an) =        and jmp(lexp as T.LABEL lab, labs, an) =
1013               mark(I.JMP(I.ImmedLabel lexp, [lab]), an)               mark(I.JMP(I.ImmedLabel lexp, [lab]), an)
1014          | jmp(T.LABEL lexp, labs, an) = mark(I.JMP(I.ImmedLabel lexp, labs), an)          | jmp(T.LABEXP le, labs, an) = mark(I.JMP(I.ImmedLabel le, labs), an)
1015          | jmp(ea, labs, an)           = mark(I.JMP(operand ea, labs), an)          | jmp(ea, labs, an)           = mark(I.JMP(operand ea, labs), an)
1016    
1017         (* convert mlrisc to cellset:         (* convert mlrisc to cellset:

Legend:
Removed from v.774  
changed lines
  Added in v.775

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