[MLton] cvs commit: extended ArrayOffset in x86-translate.

Matthew Fluet fluet@mlton.org
Mon, 26 Jul 2004 14:22:14 -0700


fluet       04/07/26 14:22:13

  Modified:    mlton/codegen/x86-codegen x86-translate.fun
  Log:
  MAIL extended ArrayOffset in x86-translate.

Revision  Changes    Path
1.63      +9 -4      mlton/mlton/codegen/x86-codegen/x86-translate.fun

Index: x86-translate.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/codegen/x86-codegen/x86-translate.fun,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- x86-translate.fun	24 Jul 2004 13:55:48 -0000	1.62
+++ x86-translate.fun	26 Jul 2004 21:22:13 -0000	1.63
@@ -78,10 +78,6 @@
       val rec toX86Operand : t -> (x86.Operand.t * x86.Size.t) vector =
 	 fn ArrayOffset {base, index, offset, ty}
  	    => let
-		  val _ =
-		     if Bytes.isZero offset
-			then ()
-		     else Error.bug "toX86Operand can't handle nonzero offset"
 		  val base = toX86Operand base
 		  val _ = Assert.assert("x86Translate.Operand.toX86Operand: Array/base",
 					fn () => Vector.length base = 1)
@@ -90,6 +86,7 @@
 		  val _ = Assert.assert("x86Translate.Operand.toX86Operand: Array/index",
 				       fn () => Vector.length index = 1)
 		  val index = getOp0 index
+
 		  val ty = Type.toCType ty
 		  val origin =
 		     case (x86.Operand.deMemloc base,
@@ -114,6 +111,14 @@
 						x86.Operand.toString base,
 						" index: ",
 						x86.Operand.toString index])
+		  val origin =
+		     if Bytes.isZero offset
+			then origin
+			else x86.MemLoc.shift
+			     {origin = origin,
+			      disp = x86.Immediate.const_int (Bytes.toInt offset),
+			      scale = x86.Scale.One,
+			      size = x86.Size.BYTE}
 		  val sizes = x86.Size.fromCType ty
 	       in
 		  (#1 o Vector.mapAndFold)