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

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

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

revision 803, Thu Mar 22 19:30:19 2001 UTC revision 804, Thu Mar 22 19:37:34 2001 UTC
# Line 34  Line 34 
34    val edx = 2   val esi = 6    val edx = 2   val esi = 6
35    val ebx = 3   val edi = 7    val ebx = 3   val edi = 7
36    
37      val opnd16Prefix = 0x66
38    
39    fun const c = Int32.fromInt(Const.valueOf c)    fun const c = Int32.fromInt(Const.valueOf c)
40    fun lexp le = Int32.fromInt(LE.valueOf le)    fun lexp le = Int32.fromInt(LE.valueOf le)
41    
42    val toWord8 = Word8.fromLargeWord o LargeWord.fromLargeInt o Int32.toLarge    val toWord8 = Word8.fromLargeWord o LargeWord.fromLargeInt o Int32.toLarge
43    val eBytes = Word8Vector.fromList    val eBytes = Word8Vector.fromList
44    fun eByte i = eBytes [W8.fromInt i]    fun eByte i = eBytes [W8.fromInt i]
45      local
46        val toLWord = (W.fromLargeInt o Int32.toLarge)
47        fun shift (w,cnt) = W8.fromLargeWord(W.>>(w, cnt))
48      in
49        fun eShort i16 = let
50          val w = toLWord i16
51        in [shift(w, 0w0), shift(w,0w8)]
52        end
53    fun eLong i32 = let    fun eLong i32 = let
54      val w = (W.fromLargeInt o Int32.toLarge) i32        val w = toLWord i32
55      fun shift cnt = W8.fromLargeWord(W.>>(w, cnt))      in [shift(w, 0w0), shift(w,0w8), shift(w,0w16), shift(w,0w24)]
56    in [shift(0w0), shift(0w8), shift(0w16), shift(0w24)]      end
57    end    end
58    
59    fun emitInstrs(instrs) = Word8Vector.concat(map emitInstr instrs)    fun emitInstrs(instrs) = Word8Vector.concat(map emitInstr instrs)
# Line 141  Line 151 
151      fun encodeReg(byte1, reg, opnd) = encode(byte1, rNum reg, opnd)      fun encodeReg(byte1, reg, opnd) = encode(byte1, rNum reg, opnd)
152      fun encodeLongImm(byte1, opc, opnd, i) =      fun encodeLongImm(byte1, opc, opnd, i) =
153           eBytes(byte1 :: (eImmedExt(opc, opnd) @ eLong i))           eBytes(byte1 :: (eImmedExt(opc, opnd) @ eLong i))
154        fun encodeShortImm(byte1, opc, opnd, w) =
155             eBytes(byte1 :: (eImmedExt(opc, opnd) @ eShort w))
156      fun encodeByteImm(byte1, opc, opnd, b) =      fun encodeByteImm(byte1, opc, opnd, b) =
157           eBytes(byte1 :: (eImmedExt(opc, opnd) @ [toWord8 b]))           eBytes(byte1 :: (eImmedExt(opc, opnd) @ [toWord8 b]))
158    
# Line 257  Line 269 
269               | mv(src, dst as I.MemReg _) = mv(src, memReg dst)               | mv(src, dst as I.MemReg _) = mv(src, memReg dst)
270               | mv(src,dst) = arith(0wx88, 0) (src, dst)               | mv(src,dst) = arith(0wx88, 0) (src, dst)
271         in  mv(src,dst) end         in  mv(src,dst) end
272         | I.MOVE{mvOp=I.MOVW, src, dst} => let
273              fun immed16 i = Int32.<(i, 32768) andalso Int32.<=(~32768, i)
274              fun prefix v = Word8Vector.concat[eByte(opnd16Prefix), v]
275              fun mv(I.Immed(i), _) =
276                  (case dst
277                   of I.Direct r =>
278                      if immed16 i then
279                        prefix(eBytes(W8.+(0wxb8, W8.fromInt(rNum r)):: eShort(i)))
280                      else error "MOVW: Immediate too large"
281                    | _ => prefix(encodeShortImm(0wxc7, 0, dst, i))
282                  (*esac*))
283                | mv(src as I.MemReg _, dst) = mv(memReg src, dst)
284                | mv(src, dst as I.MemReg _) = mv(src, memReg dst)
285                | mv(src, dst) = prefix(arith(0wx88, 0) (src, dst))
286           in mv(src, dst)
287           end
288       | I.MOVE{mvOp=I.MOVB, dst, src=I.Immed(i)} =>       | I.MOVE{mvOp=I.MOVB, dst, src=I.Immed(i)} =>
289         (case size i         (case size i
290           of Bits32 => error "MOVE: MOVB: imm8"           of Bits32 => error "MOVE: MOVB: imm8"
# Line 483  Line 511 
511       | I.FLDLG2 => eBytes[0wxd9,0wxec]       | I.FLDLG2 => eBytes[0wxd9,0wxec]
512       | I.FLDLN2 => eBytes[0wxd9,0wxed]       | I.FLDLN2 => eBytes[0wxd9,0wxed]
513       | I.FLDZ   => eBytes[0wxd9,0wxee]       | I.FLDZ   => eBytes[0wxd9,0wxee]
514         | I.FLDS opnd => encode(0wxd9, 0, opnd)
515    
516       | I.FLDL(I.ST n) => encodeST(0wxd9, 24, n)       | I.FLDL(I.ST n) => encodeST(0wxd9, 24, n)
517       | I.FLDL opnd => encode(0wxdd, 0, opnd)       | I.FLDL opnd => encode(0wxdd, 0, opnd)

Legend:
Removed from v.803  
changed lines
  Added in v.804

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