[MLton-commit] r5560

Matthew Fluet fluet at mlton.org
Wed May 16 08:31:58 PDT 2007


Greatly simplify the representation of immediates.  We only need Word,
Label, and LabelPlusWord.  Furthermore, Word immediates, we use
WordX.t rather than Word.t.

Vetting these changes in the x86-codegen in preparation for the
amd64-codegen; amd64 assembly only allows 32-bit immediates in most
64-bit instructions.  Simplifying the possible immediates makes it
easier to determine if an immediate can be satisfactorily represented
by 32-bits.  Also, we need to represent 64-bit immediate values in the
amd64-codegen, which wasn't possible with collapsing all constant
immediates to Word.t.


----------------------------------------------------------------------

U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/sources.cm
U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/sources.mlb
U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-allocate-registers.fun
U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-codegen.fun
U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-generate-transfers.fun
U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-mlton-basic.fun
U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-mlton-basic.sig
U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-mlton.fun
U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-pseudo.sig
U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-simplify.fun
U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-translate.fun
U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86.fun
U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86.sig

----------------------------------------------------------------------

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/sources.cm
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/sources.cm	2007-05-16 15:27:33 UTC (rev 5559)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/sources.cm	2007-05-16 15:31:52 UTC (rev 5560)
@@ -13,6 +13,7 @@
 is
 
 ../../../lib/mlton/sources.cm
+../../ast/sources.cm
 ../../atoms/sources.cm
 ../../control/sources.cm
 ../../backend/sources.cm

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/sources.mlb
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/sources.mlb	2007-05-16 15:27:33 UTC (rev 5559)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/sources.mlb	2007-05-16 15:31:52 UTC (rev 5560)
@@ -8,6 +8,7 @@
 
 local
    ../../../lib/mlton/sources.mlb
+   ../../ast/sources.mlb
    ../../atoms/sources.mlb
    ../../control/sources.mlb
    ../../backend/sources.mlb

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-allocate-registers.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-allocate-registers.fun	2007-05-16 15:27:33 UTC (rev 5559)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-allocate-registers.fun	2007-05-16 15:31:52 UTC (rev 5560)
@@ -2443,7 +2443,7 @@
                   => let        
                        val spillMemLoc
                          = MemLoc.imm {base = Immediate.label spillLabel,
-                                       index = Immediate.const_int spillEnd,
+                                       index = Immediate.int spillEnd,
                                        scale = x86MLton.wordScale,
                                        size = MemLoc.size memloc,
                                        class = x86MLton.Classes.Temp}
@@ -2730,7 +2730,7 @@
                                          = MemLoc.imm
                                            {base = Immediate.label
                                                    (Label.fromString "BUG"),
-                                            index = Immediate.const_int 0,
+                                            index = Immediate.zero,
                                             scale = Scale.One,
                                             size = MemLoc.size memloc,
                                             class = MemLoc.Class.Temp},
@@ -3447,14 +3447,17 @@
                 = MemLoc.destruct memloc
 
               val disp 
-                = Immediate.binexp
-                  {oper = Immediate.Addition,
-                   exp1 = case immBase
-                            of NONE => Immediate.const_int 0
-                             | SOME immBase => immBase,
-                   exp2 = case immIndex
-                            of NONE => Immediate.const_int 0
-                             | SOME immIndex => immIndex}
+                = case (immBase, immIndex) of
+                     (NONE, NONE) => Immediate.zero
+                   | (SOME immBase, NONE) => immBase
+                   | (NONE, SOME immIndex) => immIndex
+                   | (SOME immBase, SOME immIndex) 
+                   => (case (Immediate.destruct immBase, Immediate.destruct immIndex) of
+                          (Immediate.Label l1, Immediate.Word w2) => 
+                             Immediate.labelPlusWord (l1, w2)
+                        | (Immediate.LabelPlusWord (l1, w1), Immediate.Word w2) => 
+                             Immediate.labelPlusWord (l1, WordX.add (w1, w2))
+                        | _ => Error.bug "x86AllocateRegisters.RegisterAllocation.toAddressMemLoc:disp")
 
               val {register = register_base,
                    assembly = assembly_base,
@@ -4792,7 +4795,7 @@
                      val temp 
                        = MemLoc.imm
                          {base = Immediate.label (Label.fromString "raTemp2"),
-                          index = Immediate.const_int 0,
+                          index = Immediate.zero,
                           scale = Scale.Eight,
                           size = Size.DBLE,
                           class = MemLoc.Class.Temp}
@@ -5893,8 +5896,8 @@
             {assembly = AppendList.appends
                         [assembly_reserve,
                          assembly_shuffle,
-                         assembly_commit_registers,
                          assembly_commit_fltregisters,
+                         assembly_commit_registers,
                          assembly_unreserve],
              registerAllocation = registerAllocation}
           end
@@ -8024,11 +8027,7 @@
                              info = info,
                              registerAllocation = registerAllocation}
 
-                        val isConst0
-                          = fn Immediate.Const (Immediate.Char #"\000") => true
-                             | Immediate.Const (Immediate.Int 0) => true
-                             | Immediate.Const (Immediate.Word 0wx0) => true
-                             | _ => false
+                        val isConst0 = Immediate.isZero
 
                         (* special case moving 0 to a register
                          *)
@@ -8036,7 +8035,7 @@
                           = case (final_src, final_dst)
                               of (Operand.Immediate immediate,
                                   Operand.Register _)
-                               => if isConst0 (Immediate.destruct immediate)
+                               => if isConst0 immediate
                                     then Instruction.BinAL
                                          {oper = XOR,
                                           src = final_dst,

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-codegen.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-codegen.fun	2007-05-16 15:27:33 UTC (rev 5559)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-codegen.fun	2007-05-16 15:31:52 UTC (rev 5560)
@@ -12,9 +12,10 @@
 
   structure x86 = x86 (open Machine
                        structure RepType = Type)
+  structure x86Pseudo = x86PseudoCheck (structure S = x86)
 
   structure x86MLtonBasic
-    = x86MLtonBasic (structure x86 = x86
+    = x86MLtonBasic (structure x86 = x86Pseudo
                      structure Machine = Machine)
 
   structure x86Liveness
@@ -169,7 +170,7 @@
         fun file_begin file
           = [x86.Assembly.pseudoop_data (),
              x86.Assembly.pseudoop_p2align 
-             (x86.Immediate.const_int 2, NONE, NONE),
+             (x86.Immediate.int 2, NONE, NONE),
              x86.Assembly.label x86MLton.fileNameLabel,
              x86.Assembly.pseudoop_string [file]]
 
@@ -187,17 +188,17 @@
                  [
                   x86.Assembly.pseudoop_text (),
                   x86.Assembly.pseudoop_p2align 
-                  (x86.Immediate.const_int 4, NONE, NONE),
+                  (x86.Immediate.int 4, NONE, NONE),
                   x86.Assembly.pseudoop_global jumpToSML,
                   x86.Assembly.label jumpToSML,
                   x86.Assembly.instruction_binal
                   {oper = x86.Instruction.SUB,
-                   src = x86.Operand.immediate_const_int 28,
+                   src = x86.Operand.immediate_int 28,
                    dst = x86.Operand.register x86.Register.esp,
                    size = x86.Size.LONG},
                   x86.Assembly.instruction_mov
                   {src = (x86.Operand.address o x86.Address.T)
-                         {disp = SOME (x86.Immediate.const_int 32),
+                         {disp = SOME (x86.Immediate.int 32),
                           base = SOME x86.Register.esp,
                           index= NONE, scale = NONE},
                    dst = x86.Operand.register x86.Register.eax,
@@ -205,28 +206,28 @@
                   x86.Assembly.instruction_mov
                   {src = x86.Operand.register x86.Register.ebp,
                    dst = (x86.Operand.address o x86.Address.T)
-                         {disp = SOME (x86.Immediate.const_int 24),
+                         {disp = SOME (x86.Immediate.int 24),
                           base = SOME x86.Register.esp,
                           index= NONE, scale = NONE},
                    size = x86.Size.LONG},
                   x86.Assembly.instruction_mov
                   {src = x86.Operand.register x86.Register.ebx,
                    dst = (x86.Operand.address o x86.Address.T)
-                         {disp = SOME (x86.Immediate.const_int 20),
+                         {disp = SOME (x86.Immediate.int 20),
                           base = SOME x86.Register.esp,
                           index= NONE, scale = NONE},
                    size = x86.Size.LONG},
                   x86.Assembly.instruction_mov
                   {src = x86.Operand.register x86.Register.edi,
                    dst = (x86.Operand.address o x86.Address.T)
-                         {disp = SOME (x86.Immediate.const_int 16),
+                         {disp = SOME (x86.Immediate.int 16),
                           base = SOME x86.Register.esp,
                           index= NONE, scale = NONE},
                    size = x86.Size.LONG},
                   x86.Assembly.instruction_mov
                   {src = x86.Operand.register x86.Register.esi,
                    dst = (x86.Operand.address o x86.Address.T)
-                         {disp = SOME (x86.Immediate.const_int 12),
+                         {disp = SOME (x86.Immediate.int 12),
                           base = SOME x86.Register.esp,
                           index = NONE, scale = NONE},
                    size = x86.Size.LONG},
@@ -239,7 +240,7 @@
                   x86.Assembly.instruction_mov
                   {src = x86.Operand.register x86.Register.ebx,
                    dst = (x86.Operand.address o x86.Address.T)
-                         {disp = SOME (x86.Immediate.const_int 8),
+                         {disp = SOME (x86.Immediate.int 8),
                           base = SOME x86.Register.esp,
                           index = NONE, scale = NONE},
                    size = x86.Size.LONG},
@@ -251,25 +252,21 @@
                    size = x86.Size.LONG},
                   x86.Assembly.instruction_mov
                   {src = (x86.Operand.address o x86.Address.T)
-                         {disp = (SOME o x86.Immediate.binexp)
-                                 {oper = x86.Immediate.Addition,
-                                  exp1 = x86.Immediate.label x86MLton.gcState_label,
-                                  exp2 = x86.Immediate.const_int 
-                                         (Bytes.toInt 
-                                          (Machine.Runtime.GCField.offset
-                                           Machine.Runtime.GCField.StackTop))},
+                         {disp = (SOME o x86.Immediate.labelPlusInt)
+                                 (x86MLton.gcState_label,
+                                  Bytes.toInt 
+                                  (Machine.Runtime.GCField.offset
+                                   Machine.Runtime.GCField.StackTop)),
                           base = NONE, index = NONE, scale = NONE},
                    dst = x86.Operand.register stackTopReg,
                    size = x86.Size.LONG},
                   x86.Assembly.instruction_mov
                   {src = (x86.Operand.address o x86.Address.T)
-                         {disp = (SOME o x86.Immediate.binexp)
-                                 {oper = x86.Immediate.Addition,
-                                  exp1 = x86.Immediate.label x86MLton.gcState_label,
-                                  exp2 = x86.Immediate.const_int 
-                                         (Bytes.toInt 
-                                          (Machine.Runtime.GCField.offset
-                                           Machine.Runtime.GCField.Frontier))},
+                         {disp = (SOME o x86.Immediate.labelPlusInt)
+                                 (x86MLton.gcState_label,
+                                  Bytes.toInt 
+                                  (Machine.Runtime.GCField.offset
+                                   Machine.Runtime.GCField.Frontier)),
                           base = NONE, index = NONE, scale = NONE},
                    dst = x86.Operand.register frontierReg,
                    size = x86.Size.LONG},
@@ -277,7 +274,7 @@
                   {target = x86.Operand.register x86.Register.eax,
                    absolute = true},
                   x86.Assembly.pseudoop_p2align 
-                  (x86.Immediate.const_int 4, NONE, NONE),
+                  (x86.Immediate.int 4, NONE, NONE),
                   x86.Assembly.pseudoop_global returnToC,
                   x86.Assembly.label returnToC,
                   x86.Assembly.instruction_mov
@@ -288,7 +285,7 @@
                    size = x86.Size.LONG},
                   x86.Assembly.instruction_mov
                   {src = (x86.Operand.address o x86.Address.T)
-                         {disp = SOME (x86.Immediate.const_int 8),
+                         {disp = SOME (x86.Immediate.int 8),
                           base = SOME x86.Register.esp,
                           index = NONE, scale = NONE},
                    dst = x86.Operand.register x86.Register.ebx,
@@ -301,35 +298,35 @@
                    size = x86.Size.LONG},
                   x86.Assembly.instruction_mov
                   {src = (x86.Operand.address o x86.Address.T)
-                         {disp = SOME (x86.Immediate.const_int 12),
+                         {disp = SOME (x86.Immediate.int 12),
                           base = SOME x86.Register.esp,
                           index = NONE, scale = NONE},
                    dst = x86.Operand.register x86.Register.esi,
                    size = x86.Size.LONG},
                   x86.Assembly.instruction_mov
                   {src = (x86.Operand.address o x86.Address.T)
-                         {disp = SOME (x86.Immediate.const_int 16),
+                         {disp = SOME (x86.Immediate.int 16),
                           base = SOME x86.Register.esp,
                           index = NONE, scale = NONE},
                    dst = x86.Operand.register x86.Register.edi,
                    size = x86.Size.LONG},
                   x86.Assembly.instruction_mov
                   {src = (x86.Operand.address o x86.Address.T)
-                         {disp = SOME (x86.Immediate.const_int 20),
+                         {disp = SOME (x86.Immediate.int 20),
                           base = SOME x86.Register.esp,
                           index = NONE, scale = NONE},
                    dst = x86.Operand.register x86.Register.ebx,
                    size = x86.Size.LONG},
                   x86.Assembly.instruction_mov
                   {src = (x86.Operand.address o x86.Address.T)
-                         {disp = SOME (x86.Immediate.const_int 24),
+                         {disp = SOME (x86.Immediate.int 24),
                           base = SOME x86.Register.esp,
                           index = NONE, scale = NONE},
                    dst = x86.Operand.register x86.Register.ebp,
                    size = x86.Size.LONG},
                   x86.Assembly.instruction_binal
                   {oper = x86.Instruction.ADD,
-                   src = x86.Operand.immediate_const_int 28,
+                   src = x86.Operand.immediate_int 28,
                    dst = x86.Operand.register x86.Register.esp,
                    size = x86.Size.LONG},
                   x86.Assembly.instruction_ret {src = NONE}

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-generate-transfers.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-generate-transfers.fun	2007-05-16 15:27:33 UTC (rev 5559)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-generate-transfers.fun	2007-05-16 15:31:52 UTC (rev 5560)
@@ -23,9 +23,10 @@
      structure CFunction = CFunction
   end
 
-  val rec ones : int -> word
-    = fn 0 => 0wx0
-       | n => Word.orb(Word.<<(ones (n-1), 0wx1),0wx1)
+  val ones : int * WordSize.t -> WordX.t
+    = fn (i, ws) => (WordX.notb o WordX.lshift) 
+                    (WordX.allOnes ws,
+                     WordX.fromIntInf (IntInf.fromInt i, ws))
 
   val tracerTop = x86.tracerTop
 
@@ -478,15 +479,15 @@
                                  then
                                     AppendList.single
                                     (Assembly.pseudoop_p2align 
-                                     (Immediate.const_int 4,
+                                     (Immediate.int 4,
                                       NONE,
-                                      SOME (Immediate.const_int 7)))
+                                      SOME (Immediate.int 7)))
                               else if falling
                                       then AppendList.empty
                                    else
                                       AppendList.single
                                       (Assembly.pseudoop_p2align
-                                       (Immediate.const_int 4, 
+                                       (Immediate.int 4, 
                                         NONE, 
                                         NONE))
                            val assumes =
@@ -567,7 +568,7 @@
                                                  val stackTop 
                                                    = x86MLton.gcState_stackTopContentsOperand ()
                                                  val bytes 
-                                                   = x86.Operand.immediate_const_int (~ size)
+                                                   = x86.Operand.immediate_int (~ size)
                                                in
                                                  AppendList.cons
                                                  ((* stackTop += bytes *)
@@ -584,9 +585,9 @@
                                           AppendList.appends
                                           [AppendList.fromList
                                            [Assembly.pseudoop_p2align 
-                                            (Immediate.const_int 4, NONE, NONE),
+                                            (Immediate.int 4, NONE, NONE),
                                             Assembly.pseudoop_long 
-                                            [Immediate.const_int frameLayoutsIndex],
+                                            [Immediate.int frameLayoutsIndex],
                                             Assembly.label label],
                                            AppendList.fromList
                                            (ProfileLabel.toAssemblyOpt profileLabel),
@@ -624,7 +625,7 @@
                             => AppendList.appends
                                [AppendList.fromList
                                 [Assembly.pseudoop_p2align 
-                                 (Immediate.const_int 4, NONE, NONE),
+                                 (Immediate.int 4, NONE, NONE),
                                  Assembly.pseudoop_global label,
                                  Assembly.label label],
                                 AppendList.fromList
@@ -639,9 +640,9 @@
                                AppendList.appends
                                [AppendList.fromList
                                 [Assembly.pseudoop_p2align
-                                 (Immediate.const_int 4, NONE, NONE),
+                                 (Immediate.int 4, NONE, NONE),
                                  Assembly.pseudoop_long
-                                 [Immediate.const_int frameLayoutsIndex],
+                                 [Immediate.int frameLayoutsIndex],
                                  Assembly.label label],
                                 AppendList.fromList
                                 (ProfileLabel.toAssemblyOpt profileLabel),
@@ -651,7 +652,7 @@
                                      val stackTop 
                                         = x86MLton.gcState_stackTopContentsOperand ()
                                      val bytes 
-                                        = x86.Operand.immediate_const_int (~ size)
+                                        = x86.Operand.immediate_int (~ size)
                                   in
                                      AppendList.cons
                                      ((* stackTop += bytes *)
@@ -669,9 +670,9 @@
                             => AppendList.appends
                                [AppendList.fromList
                                 [Assembly.pseudoop_p2align 
-                                 (Immediate.const_int 4, NONE, NONE),
+                                 (Immediate.int 4, NONE, NONE),
                                  Assembly.pseudoop_long
-                                 [Immediate.const_int frameLayoutsIndex],
+                                 [Immediate.int frameLayoutsIndex],
                                  Assembly.label label],
                                 AppendList.fromList
                                 (ProfileLabel.toAssemblyOpt profileLabel),
@@ -681,7 +682,7 @@
                                      val stackTop 
                                         = x86MLton.gcState_stackTopContentsOperand ()
                                      val bytes 
-                                        = x86.Operand.immediate_const_int (~ size)
+                                        = x86.Operand.immediate_int (~ size)
                                   in
                                      AppendList.cons
                                      ((* stackTop += bytes *)
@@ -898,7 +899,7 @@
                                 AppendList.fromList
                                 [Assembly.instruction_cmp
                                  {src1 = test,
-                                  src2 = Operand.immediate_const_word k,
+                                  src2 = Operand.immediate_word k,
                                   size = size},
                                  Assembly.directive_saveregalloc
                                  {live = MemLocSet.add
@@ -964,7 +965,7 @@
                      val stackTopMinusWordDeref
                        = x86MLton.gcState_stackTopMinusWordDerefOperand ()
                      val bytes 
-                       = x86.Operand.immediate_const_int size
+                       = x86.Operand.immediate_int size
 
                      val liveReturn = x86Liveness.LiveInfo.getLive(liveInfo, return)
                      val liveHandler 
@@ -1143,7 +1144,7 @@
                                          [Assembly.instruction_binal
                                           {oper = Instruction.SUB,
                                            dst = c_stackP,
-                                           src = Operand.immediate_const_int 8,
+                                           src = Operand.immediate_int 8,
                                            size = pointerSize},
                                           Assembly.instruction_pfmov
                                           {src = arg,
@@ -1155,7 +1156,7 @@
                                          [Assembly.instruction_binal
                                           {oper = Instruction.SUB,
                                            dst = c_stackP,
-                                           src = Operand.immediate_const_int 4,
+                                           src = Operand.immediate_int 4,
                                            size = pointerSize},
                                           Assembly.instruction_pfmov
                                           {src = arg,
@@ -1197,7 +1198,7 @@
                                      (Assembly.instruction_binal
                                       {oper = Instruction.SUB,
                                        dst = c_stackP,
-                                       src = Operand.immediate_const_int space,
+                                       src = Operand.immediate_int space,
                                        size = pointerSize}),
                                      pushArgs),
                                     size_args + space)
@@ -1222,7 +1223,7 @@
                                     = x86MLton.gcState_stackTopMinusWordDeref ()
                                   val stackTopMinusWordDeref
                                     = x86MLton.gcState_stackTopMinusWordDerefOperand ()
-                                  val bytes = x86.Operand.immediate_const_int size
+                                  val bytes = x86.Operand.immediate_int size
 
                                   val live =
                                     x86Liveness.LiveInfo.getLive(liveInfo, return)
@@ -1379,7 +1380,7 @@
                                  (Assembly.instruction_binal
                                   {oper = Instruction.ADD,
                                    dst = c_stackP,
-                                   src = Operand.immediate_const_int size_args,
+                                   src = Operand.immediate_int size_args,
                                    size = pointerSize}))
                            else AppendList.empty
                      val continue
@@ -1427,30 +1428,36 @@
           = case transfer
               of Switch {test, cases, default}
                => let
-                     type 'a ops =
-                        {zero: 'a,
-                         even: 'a -> bool,
-                         incFn: 'a -> 'a,
-                         decFn: 'a -> 'a,
-                         halfFn: 'a -> 'a,
-                         ltFn: 'a * 'a -> bool,
-                         gtFn: 'a * 'a -> bool,
-                         min: 'a,
-                         minFn: 'a * 'a -> 'a,
-                         max: 'a,
-                         maxFn: 'a * 'a -> 'a,
-                         range: 'a * 'a -> word}
+                     val ws =
+                        case Operand.size test of
+                           SOME Size.BYTE => WordSize.word8
+                         | SOME Size.WORD => WordSize.word16
+                         | SOME Size.LONG => WordSize.word32
+                         | _ => Error.bug "x86GenerateTransfers.effectJumpTable: Switch"
 
+                     val zero = WordX.zero ws
+                     val one = WordX.one ws
+                     val two = WordX.add (one, one)
+                     fun even w = WordX.isZero (WordX.mod (w, two, {signed = false}))
+                     fun incFn w = WordX.add (w, one)
+                     fun decFn w = WordX.sub (w, one)
+                     fun halfFn w = WordX.div (w, two, {signed = false})
+                     fun ltFn (w1, w2) = WordX.lt (w1, w2, {signed = false})
+                     val min = WordX.min (ws, {signed = false})
+                     fun minFn (w1, w2) = if WordX.lt (w1, w2, {signed = false}) 
+                                             then w1
+                                          else w2
+                     val max = WordX.max (ws, {signed = false})
+                     fun maxFn (w1, w2) = if WordX.gt (w1, w2, {signed = false}) 
+                                             then w1
+                                          else w2
+                     fun range (w1, w2) = WordX.sub (w2, w1)
+
                     val Liveness.T {dead, ...}
                       = livenessTransfer {transfer = transfer,
                                           liveInfo = liveInfo}
 
-                    fun reduce(cases,
-                               {even,
-                                decFn, halfFn,
-                                min, minFn,
-                                max, maxFn,
-                                ...} : 'a ops)
+                    fun reduce(cases)
                       = let
                           fun reduce' cases
                             = let
@@ -1492,11 +1499,11 @@
 
                                          val shift' = 1 + shift''
                                          val mask' 
-                                           = Word.orb
-                                             (Word.<<(mask'', 0wx1),
+                                           = WordX.orb
+                                             (WordX.lshift(mask'', WordX.one WordSize.word32),
                                               if allOdd
-                                                then 0wx1
-                                                else 0wx0)
+                                                then WordX.one WordSize.word32
+                                                else WordX.zero WordSize.word32)
                                        in
                                          (cases'', 
                                           minK'', maxK'', length'',
@@ -1504,18 +1511,14 @@
                                        end
                                   else (cases, 
                                         minK, maxK, length,
-                                        0, 0wx0)
+                                        0, WordX.zero WordSize.word32)
                               end
                         in 
                           reduce' cases
                         end
 
                     fun doitTable(cases,
-                                  {zero,
-                                   incFn, 
-                                   ...} : ''a ops,
-                                  minK, _, rangeK, shift, mask,
-                                  constFn)
+                                  minK, _, rangeK, shift, mask)
                       = let
                           val jump_table_label
                             = Label.newString "jumpTable"
@@ -1528,7 +1531,7 @@
                           val rec filler 
                             = fn ([],_) => []
                                | (cases as (i,target)::cases',j)
-                               => if i = j
+                               => if WordX.equals (i, j)
                                     then let
                                            val target'
                                              = pushCompensationBlock
@@ -1554,14 +1557,14 @@
                           val indexTemp
                             = MemLoc.imm 
                               {base = Immediate.label (Label.fromString "indexTemp"),
-                               index = Immediate.const_int 0,
+                               index = Immediate.zero,
                                scale = Scale.Four,
                                size = Size.LONG,
                                class = MemLoc.Class.Temp}
                           val checkTemp
                             = MemLoc.imm 
                               {base = Immediate.label (Label.fromString "checkTemp"),
-                               index = Immediate.const_int 0,
+                               index = Immediate.zero,
                                scale = Scale.Four,
                                size = Size.LONG,
                                class = MemLoc.Class.Temp}
@@ -1623,16 +1626,16 @@
                                        size = Size.LONG},
                                       Assembly.instruction_binal
                                       {oper = Instruction.AND,
-                                       src = Operand.immediate_const_word 
-                                             (ones shift),
+                                       src = Operand.immediate_word 
+                                             (ones (shift, WordSize.word32)),
                                        dst = checkTemp,
                                        size = Size.LONG}],
-                                     if mask = 0wx0
+                                     if WordX.isZero mask
                                        then AppendList.empty
                                        else AppendList.single
                                             (Assembly.instruction_binal
                                              {oper = Instruction.SUB,
-                                              src = Operand.immediate_const_word mask,
+                                              src = Operand.immediate_word mask,
                                               dst = checkTemp,
                                               size = Size.LONG}),
                                      AppendList.fromList
@@ -1655,17 +1658,17 @@
                                        target = Operand.label defaultC},
                                       Assembly.instruction_sral
                                       {oper = Instruction.SAR,
-                                       count = Operand.immediate_const_int shift,
+                                       count = Operand.immediate_int shift,
                                        dst = indexTemp,
                                        size = Size.LONG}]]
                                   end
                              else AppendList.empty,
-                           if minK = zero
+                           if WordX.equals (minK, zero)
                              then AppendList.empty
                              else AppendList.single
                                   (Assembly.instruction_binal
                                    {oper = Instruction.SUB,
-                                    src = Operand.immediate (constFn minK),
+                                    src = Operand.immediate_word minK,
                                     dst = indexTemp,
                                     size = Size.LONG}),
                           AppendList.fromList
@@ -1682,7 +1685,7 @@
                                        reserve = false}]},
                            Assembly.instruction_cmp
                            {src1 = indexTemp,
-                            src2 = Operand.immediate_const_word rangeK,
+                            src2 = Operand.immediate_word rangeK,
                             size = Size.LONG},
                            Assembly.directive_saveregalloc
                            {id = idT,
@@ -1707,29 +1710,27 @@
                           AppendList.fromList
                           [Assembly.pseudoop_data (),
                            Assembly.pseudoop_p2align 
-                           (Immediate.const_int 4, NONE, NONE),
+                           (Immediate.int 4, NONE, NONE),
                            Assembly.label jump_table_label,
                            Assembly.pseudoop_long jump_table,
                            Assembly.pseudoop_text ()]]
                         end
 
-                    fun doit(cases,
-                             ops as {ltFn, 
-                                     range,
-                                     ...} : ''a ops,
-                             constFn)
+                    fun doit(cases)
                       = let
                           val (cases, 
                                minK, maxK, length,
                                shift, mask) 
-                            = reduce(cases, ops)
+                            = reduce(cases)
 
                           val rangeK 
                             = range(minK,maxK)
                         in
                           if length >= 8 
                              andalso
-                             Word.div(rangeK,0wx2) <= Word.fromInt length
+                             WordX.lt (WordX.div(rangeK,two,{signed=false}),
+                                       WordX.fromIntInf (IntInf.fromInt length, ws),
+                                       {signed = false})
                             then let
                                    val cases 
                                      = List.insertionSort
@@ -1738,10 +1739,8 @@
                                          => ltFn(k,k'))
                                  in 
                                    doitTable(cases, 
-                                             ops,
                                              minK, maxK, rangeK,
-                                             shift, mask,
-                                             constFn)
+                                             shift, mask)
                                  end
                             else effectDefault gef
                                                {label = label, 
@@ -1750,21 +1749,7 @@
                   in
                     case cases
                       of Transfer.Cases.Word cases
-                       => doit
-                          (cases,
-                           {zero = 0wx0,
-                            even = fn w => Word.mod(w,0wx2) = 0wx0,
-                            incFn = fn x => Word.+(x,0wx1),
-                            decFn = fn x => Word.-(x,0wx1),
-                            halfFn = fn x => Word.div(x,0wx2),
-                            ltFn = Word.<,
-                            gtFn = Word.>,
-                            min = 0wx0,
-                            minFn = Word.min,
-                            max = 0wxFFFFFFFF,
-                            maxFn = Word.max,
-                            range = fn (min,max) => max - min},
-                           Immediate.const_word)
+                       => doit cases
                   end
                | _ => effectDefault gef 
                                     {label = label,

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-mlton-basic.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-mlton-basic.fun	2007-05-16 15:27:33 UTC (rev 5559)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-mlton-basic.fun	2007-05-16 15:31:52 UTC (rev 5560)
@@ -150,7 +150,7 @@
     = Operand.memloc c_stackPContents
   val c_stackPDerefDouble
     = MemLoc.simple {base = c_stackPContents,
-                     index = Immediate.const_int 0,
+                     index = Immediate.zero,
                      scale = wordScale,
                      size = Size.DBLE,
                      class = Classes.CStack}
@@ -158,7 +158,7 @@
     = Operand.memloc c_stackPDerefDouble
   val c_stackPDerefFloat
     = MemLoc.simple {base = c_stackPContents,
-                     index = Immediate.const_int 0,
+                     index = Immediate.zero,
                      scale = wordScale,
                      size = Size.SNGL,
                      class = Classes.CStack}
@@ -332,12 +332,10 @@
 
   val fileLine
     = fn () => if !Control.debug
-                 then Operand.immediate (Immediate.const_int 0)
+                 then Operand.immediate (Immediate.zero)
                  else (Operand.immediate
-                       (Immediate.binexp
-                        {oper = Immediate.Addition,
-                         exp1 = Immediate.label (fileLineLabel ()),
-                         exp2 = Immediate.const_int 9}))
+                       (Immediate.labelPlusInt
+                        (fileLineLabel (), 9)))
 
   val gcState_label = Label.fromString "gcState"
 
@@ -345,10 +343,8 @@
   fun make' (offset: int, size, class) =
      let
         fun imm () =
-           Immediate.binexp
-           {oper = Immediate.Addition,
-            exp1 = Immediate.label gcState_label,
-            exp2 = Immediate.const_int offset}
+           Immediate.labelPlusInt
+           (gcState_label, offset)
         fun contents () =
            makeContents {base = imm (),
                          size = size,
@@ -360,10 +356,8 @@
   fun make (f: Field.t, size, class) =
      let
         fun imm () =
-           Immediate.binexp
-           {oper = Immediate.Addition,
-            exp1 = Immediate.label gcState_label,
-            exp2 = Immediate.const_int (Bytes.toInt (Field.offset f))}
+           Immediate.labelPlusInt
+           (gcState_label, Bytes.toInt (Field.offset f))
         fun contents () =
            makeContents {base = imm (),
                          size = size,
@@ -405,7 +399,7 @@
 
   fun gcState_stackTopMinusWordDeref () =
      MemLoc.simple {base = gcState_stackTopContents (), 
-                    index = Immediate.const_int ~1,
+                    index = Immediate.int ~1,
                     scale = wordScale,
                     size = pointerSize,
                     class = Classes.Stack}
@@ -414,7 +408,7 @@
 
   fun stackTopTempMinusWordDeref () =
      MemLoc.simple {base = stackTopTempContents (), 
-                    index = Immediate.const_int ~1,
+                    index = Immediate.int ~1,
                     scale = wordScale,
                     size = pointerSize,
                     class = Classes.Stack}

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-mlton-basic.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-mlton-basic.sig	2007-05-16 15:27:33 UTC (rev 5559)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-mlton-basic.sig	2007-05-16 15:31:52 UTC (rev 5560)
@@ -18,6 +18,8 @@
     sharing x86.ProfileLabel = Machine.ProfileLabel
     sharing x86.RepType = Machine.Type
     sharing x86.Runtime = Machine.Runtime
+    sharing x86.WordSize = Machine.WordSize
+    sharing x86.WordX = Machine.WordX
   end
 
 signature X86_MLTON_BASIC =

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-mlton.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-mlton.fun	2007-05-16 15:27:33 UTC (rev 5559)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-mlton.fun	2007-05-16 15:31:52 UTC (rev 5560)
@@ -995,7 +995,7 @@
                         check = false},
                        Assembly.instruction_test
                        {src1 = fpswTempContentsOperand,
-                        src2 = Operand.immediate_const_word 0wx4500,
+                        src2 = Operand.immediate_int' (0x4500, WordSize.word16),
                         size = Size.WORD},
                        Assembly.instruction_setcc
                        {condition = Instruction.Z,
@@ -1026,7 +1026,7 @@
                         check = false},
                        Assembly.instruction_test
                        {src1 = fpswTempContentsOperand,
-                        src2 = Operand.immediate_const_word 0wx500,
+                        src2 = Operand.immediate_int' (0x500, WordSize.word16),
                         size = Size.WORD},
                        Assembly.instruction_setcc
                        {condition = Instruction.Z,
@@ -1058,11 +1058,11 @@
                        Assembly.instruction_binal
                        {oper = Instruction.AND,
                         dst = fpswTempContentsOperand,
-                        src = Operand.immediate_const_word 0wx4500,
+                        src = Operand.immediate_int' (0x4500, WordSize.word16),
                         size = Size.WORD},
                        Assembly.instruction_cmp
                        {src1 = fpswTempContentsOperand,
-                        src2 = Operand.immediate_const_word 0wx4000,
+                        src2 = Operand.immediate_int' (0x4000, WordSize.word16),
                         size = Size.WORD},
                        Assembly.instruction_setcc
                        {condition = Instruction.E,
@@ -1093,7 +1093,7 @@
                         check = false},
                        Assembly.instruction_test
                        {src1 = fpswTempContentsOperand,
-                        src2 = Operand.immediate_const_word 0wx4400,
+                        src2 = Operand.immediate_int' (0x4400, WordSize.word16),
                         size = Size.WORD},
                        Assembly.instruction_setcc
                        {condition = Instruction.NE,
@@ -1261,7 +1261,7 @@
                                    fn (dst,dstsize) => [Assembly.instruction_binal
                                                         {dst = dst,
                                                          oper = Instruction.ADC,
-                                                         src = Operand.immediate_const_int 0,
+                                                         src = Operand.immediate_zero,
                                                          size = dstsize}]))
              | Word_notb s => 
                 (case WordSize.prim s of
@@ -1761,10 +1761,9 @@
                 | W16 => unal (x86.Instruction.NEG, x86.Instruction.O)
                 | W32 => unal (x86.Instruction.NEG, x86.Instruction.O)
                 | W64 => neg64 ())
-           | Word_subCheck (s, {signed}) =>
+           | Word_subCheck (s, sg) =>
                 let
-                   val flag =
-                      if signed then x86.Instruction.O else x86.Instruction.C
+                   val flag = flag sg
                 in
                    case WordSize.prim s of
                       W8 => binal (x86.Instruction.SUB, flag)

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-pseudo.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-pseudo.sig	2007-05-16 15:27:33 UTC (rev 5559)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-pseudo.sig	2007-05-16 15:31:52 UTC (rev 5560)
@@ -7,7 +7,6 @@
  *)
 
 type int = Int.t
-type word = Word.t
 
 signature X86_PSEUDO =
   sig
@@ -16,8 +15,11 @@
     structure Label: ID
     structure RepType: REP_TYPE
     structure Runtime: RUNTIME
+    structure WordSize: WORD_SIZE
+    structure WordX: WORD_X
     sharing CFunction = RepType.CFunction
     sharing CType = RepType.CType
+    sharing WordSize = CType.WordSize = WordX.WordSize
 
     val tracer : string -> ('a -> 'b) -> 
                  (('a -> 'b) * (unit -> unit))
@@ -41,35 +43,15 @@
 
     structure Immediate :
       sig
-        datatype const
-          = Char of char
-          | Int of int
-          | Word of word
-        datatype un
-          = Negation
-          | Complementation
-        datatype bin
-          = Multiplication
-          | Division
-          | Remainder
-          | ShiftLeft
-          | ShiftRight
-          | BitOr
-          | BitAnd
-          | BitXor
-          | BitOrNot
-          | Addition
-          | Subtraction
         type t
 
-        val const : const -> t
-        val const_char : char -> t
-        val const_int : int -> t
-        val const_word : word -> t
+        val word : WordX.t -> t
+        val int' : int * WordSize.t -> t
+        val int : int -> t
+        val zero : t
         val label : Label.t -> t
-        val binexp : {oper: bin,
-                      exp1: t,
-                      exp2: t} -> t
+        val labelPlusWord : Label.t * WordX.t -> t
+        val labelPlusInt : Label.t * int -> t
       end
 
     structure Scale :
@@ -144,9 +126,10 @@
         val toString : t -> string
 
         val immediate : Immediate.t -> t
-        val immediate_const_char : char -> t
-        val immediate_const_int : int -> t
-        val immediate_const_word : word -> t
+        val immediate_word : WordX.t -> t
+        val immediate_int' : int * WordSize.t -> t
+        val immediate_int : int -> t
+        val immediate_zero : t
         val immediate_label : Label.t -> t
         val deImmediate : t -> Immediate.t option
         val label : Label.t -> t
@@ -440,7 +423,7 @@
           sig
             type 'a t
 
-            val word : (word * 'a) list -> 'a t
+            val word : (WordX.t * 'a) list -> 'a t
           end
 
         type t
@@ -493,3 +476,6 @@
 
       end
   end
+
+functor x86PseudoCheck(structure S : X86) : X86_PSEUDO = S
+

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-simplify.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-simplify.fun	2007-05-16 15:27:33 UTC (rev 5559)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-simplify.fun	2007-05-16 15:31:52 UTC (rev 5560)
@@ -609,11 +609,11 @@
 
       local
         val getImmediate1
-          = fn Immediate.Const (Immediate.Char #"\001") => SOME false
-             | Immediate.Const (Immediate.Int 1) => SOME false
-             | Immediate.Const (Immediate.Int ~1) => SOME true
-             | Immediate.Const (Immediate.Word 0wx1) => SOME false
-             | Immediate.Const (Immediate.Word 0wxFFFFFFFF) => SOME true
+          = fn Immediate.Word w => if WordX.isOne w
+                                      then SOME false
+                                   else if WordX.isNegOne w
+                                      then SOME true
+                                   else NONE
              | _ => NONE
 
         val isInstructionADDorSUB_srcImmediate1 : statement_type -> bool
@@ -718,38 +718,29 @@
 
       local
         val rec log2'
-          = fn (0wx0, _) => NONE
-             | (w : Word32.word, i : int)
-             => if 0wx1 = Word32.andb(w, 0wx1)
-                  then case w
-                         of 0wx00000001 => SOME (i, false)
-                          | 0wxFFFFFFFF => SOME (i, true)
-                          | _ => NONE
-                  else log2' (Word32.~>>(w, 0wx1), i + 1)
+          = fn (w : WordX.t, i : int) =>
+            if WordX.isZero w then NONE
+            else if WordX.isOne (WordX.andb (w, WordX.one (WordX.size w)))
+               then if WordX.isOne w
+                       then SOME (i, false)
+                    else if WordX.isNegOne w
+                       then SOME (i, true)
+                    else NONE
+               else log2' (WordX.rshift (w, WordX.one (WordX.size w), {signed = true}), i + 1)
         fun log2 w = log2' (w, 0 : int)
         fun divTemp size
           = MemLoc.imm {base = Immediate.label (Label.fromString "divTemp"),
-                        index = Immediate.const_int 0,
+                        index = Immediate.zero,
                         scale = Scale.Four,
                         size = size,
                         class = MemLoc.Class.Temp}
 
         val isImmediatePow2
-          = fn Immediate.Const (Immediate.Char c) 
-             => isSome (log2 (Word.fromChar c))
-             | Immediate.Const (Immediate.Int i) 
-             => isSome (log2 (Word.fromInt i))
-             | Immediate.Const (Immediate.Word w) 
-             => isSome (log2 w)
+          = fn Immediate.Word w => isSome (log2 w)
              | _ => false
 
         val getImmediateLog2
-          = fn Immediate.Const (Immediate.Char c) 
-             => log2 (Word.fromChar c)
-             | Immediate.Const (Immediate.Int i) 
-             => log2 (Word.fromInt i)
-             | Immediate.Const (Immediate.Word w)
-             => log2 w
+          = fn Immediate.Word w => log2 w 
              | _ => NONE
 
         val isInstructionMULorDIV_srcImmediatePow2 : statement_type -> bool
@@ -939,7 +930,7 @@
                                   = (fn l
                                       => (Assembly.instruction_sral
                                           {oper = Instruction.SAL,
-                                           count = Operand.immediate_const_int i,
+                                           count = Operand.immediate_int i,
                                            dst = dst,
                                            size = size})::
                                          (if b
@@ -991,7 +982,7 @@
                                 val statements
                                   = (Assembly.instruction_sral
                                      {oper = Instruction.SAL,
-                                      count = Operand.immediate_const_int i,
+                                      count = Operand.immediate_int i,
                                       dst = dst,
                                       size = size})::
                                     (List.concat [comments, finish])
@@ -1071,7 +1062,7 @@
                                                   {oper = Instruction.SAR,
                                                    dst = divTemp,
                                                    count 
-                                                   = Operand.immediate_const_int 
+                                                   = Operand.immediate_int 
                                                      (i - 1),
                                                    size = size})::
                                                  l
@@ -1082,7 +1073,7 @@
                                                   {oper = Instruction.SHR,
                                                    dst = divTemp,
                                                    count 
-                                                   = Operand.immediate_const_int 
+                                                   = Operand.immediate_int 
                                                      (width - i),
                                                    size = size})::
                                                  l
@@ -1095,7 +1086,7 @@
                                             size = size})::
                                           (Assembly.instruction_sral
                                            {oper = Instruction.SAR,
-                                            count = Operand.immediate_const_int i,
+                                            count = Operand.immediate_int i,
                                             dst = dst,
                                             size = size})::
                                           l) o
@@ -1149,7 +1140,7 @@
                                 val statements
                                   = (Assembly.instruction_sral
                                      {oper = Instruction.SHR,
-                                      count = Operand.immediate_const_int i,
+                                      count = Operand.immediate_int i,
                                       dst = dst,
                                       size = size})::
                                     (List.concat [comments, finish])
@@ -1324,7 +1315,7 @@
                                   = (fn l
                                       => (Assembly.instruction_sral
                                           {oper = Instruction.SAL,
-                                           count = Operand.immediate_const_int i,
+                                           count = Operand.immediate_int i,
                                            dst = dst,
                                            size = size})::
                                          (if b
@@ -1449,11 +1440,11 @@
           = fn Assembly.Instruction (Instruction.CMP
                                      {src1 = Operand.Immediate immediate,
                                       ...})
-             => Immediate.zero immediate
+             => Immediate.isZero immediate
              | Assembly.Instruction (Instruction.CMP
                                      {src2 = Operand.Immediate immediate,
                                       ...})
-             => Immediate.zero immediate
+             => Immediate.isZero immediate
              | _ => false
 
         val isTransfer_Iff_E_NE
@@ -1493,7 +1484,7 @@
                         of (SOME _, NONE) => src2
                          | (NONE, SOME _) => src1
                          | (SOME immediate1, SOME _)
-                         => if Immediate.zero immediate1
+                         => if Immediate.isZero immediate1
                               then src2
                               else src1
                          | _ => Error.bug "x86Simplify.PeeholeBlock: elimCMP0:src"
@@ -1755,7 +1746,7 @@
                           (cases,
                            fn (w,target) 
                             => (x86JumpInfo.decNear(jumpInfo, target);
-                                w = test))
+                                WordX.equals (w, test)))
 
                       val transfer
                         = if Transfer.Cases.isEmpty cases
@@ -1837,7 +1828,7 @@
                                      = Transfer.Cases.extract
                                        (cases,
                                         fn (w,target) =>
-                                        (Immediate.const_word w, target))
+                                        (Immediate.word w, target))
                                    val size
                                      = case Operand.size test
                                          of SOME size => size

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-translate.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-translate.fun	2007-05-16 15:27:33 UTC (rev 5559)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/codegen/x86-codegen/x86-translate.fun	2007-05-16 15:31:52 UTC (rev 5560)
@@ -49,7 +49,7 @@
               val origin =
                  x86.MemLoc.imm
                  {base = base,
-                  index = x86.Immediate.const_int index,
+                  index = x86.Immediate.int index,
                   scale = x86.Scale.fromCType ty,
                   size = x86.Size.BYTE,
                   class = x86MLton.Classes.Globals}
@@ -59,7 +59,7 @@
               (sizes, 0, fn (size,offset) =>
                (((x86.Operand.memloc o x86.MemLoc.shift)
                  {origin = origin,
-                  disp = x86.Immediate.const_int offset,
+                  disp = x86.Immediate.int offset,
                   scale = x86.Scale.One,
                   size = size}, size), offset + x86.Size.toBytes size))
            end
@@ -120,7 +120,7 @@
                         then origin
                         else x86.MemLoc.shift
                              {origin = origin,
-                              disp = x86.Immediate.const_int (Bytes.toInt offset),
+                              disp = x86.Immediate.int (Bytes.toInt offset),
                               scale = x86.Scale.One,
                               size = x86.Size.BYTE}
                   val sizes = x86.Size.fromCType ty
@@ -129,7 +129,7 @@
                   (sizes, 0, fn (size,offset) =>
                    (((x86.Operand.memloc o x86.MemLoc.shift)
                      {origin = origin,
-                      disp = x86.Immediate.const_int offset,
+                      disp = x86.Immediate.int offset,
                       scale = x86.Scale.One,
                       size = size}, size), offset + x86.Size.toBytes size))
                end
@@ -146,7 +146,7 @@
                         SOME base =>
                            x86.MemLoc.simple 
                            {base = base,
-                            index = x86.Immediate.const_int 0,
+                            index = x86.Immediate.zero,
                             scale = x86.Scale.One,
                             size = x86.Size.BYTE,
                             class = x86MLton.Classes.Heap}
@@ -160,7 +160,7 @@
                   (sizes, 0, fn (size,offset) =>
                    (((x86.Operand.memloc o x86.MemLoc.shift)
                      {origin = origin,
-                      disp = x86.Immediate.const_int offset,
+                      disp = x86.Immediate.int offset,
                       scale = x86.Scale.One,
                       size = size}, size), offset + x86.Size.toBytes size))
                end
@@ -180,7 +180,7 @@
           | Line => 
                Vector.new1 (x86MLton.fileLine (), x86MLton.wordSize)
           | Null => 
-               Vector.new1 (x86.Operand.immediate_const_word 0wx0, x86MLton.wordSize)
+               Vector.new1 (x86.Operand.immediate_zero, x86MLton.wordSize)
           | Offset {base = GCState, offset, ty} =>
                let
                   val offset = Bytes.toInt offset
@@ -202,7 +202,7 @@
                      SOME base =>
                        x86.MemLoc.simple 
                        {base = base,
-                        index = x86.Immediate.const_int offset,
+                        index = x86.Immediate.int offset,
                         scale = x86.Scale.One,
                         size = x86.Size.BYTE,
                         class = x86MLton.Classes.Heap}
@@ -215,7 +215,7 @@
                   (sizes, 0, fn (size,offset) =>
                    (((x86.Operand.memloc o x86.MemLoc.shift)
                      {origin = origin,
-                      disp = x86.Immediate.const_int offset,
+                      disp = x86.Immediate.int offset,
                       scale = x86.Scale.One,
                       size = size}, size), offset + x86.Size.toBytes size))
                end
@@ -228,7 +228,7 @@
                   val origin =
                      x86.MemLoc.imm
                      {base = base,
-                      index = x86.Immediate.const_int index,
+                      index = x86.Immediate.int index,
                       scale = x86.Scale.fromCType ty,
                       size = x86.Size.BYTE,
                       class = x86MLton.Classes.Locals}
@@ -238,7 +238,7 @@
                   (sizes, 0, fn (size,offset) =>
                    (((x86.Operand.memloc o x86.MemLoc.shift)
                      {origin = origin,
-                      disp = x86.Immediate.const_int offset,
+                      disp = x86.Immediate.int offset,
                       scale = x86.Scale.One,
                       size = size}, size), offset + x86.Size.toBytes size))
                end
@@ -249,7 +249,7 @@
                   val origin =
                      x86.MemLoc.simple 
                      {base = x86MLton.gcState_stackTopContents (), 
-                      index = x86.Immediate.const_int offset,
+                      index = x86.Immediate.int offset,
                       scale = x86.Scale.One,
                       size = x86.Size.BYTE,
                       class = x86MLton.Classes.Stack}
@@ -259,7 +259,7 @@
                   (sizes, 0, fn (size,offset) =>
                    (((x86.Operand.memloc o x86.MemLoc.shift)
                      {origin = origin,
-                      disp = x86.Immediate.const_int offset,
+                      disp = x86.Immediate.int offset,
                       scale = x86.Scale.One,
                       size = size}, size), offset + x86.Size.toBytes size))
                end
@@ -272,10 +272,7 @@
           | Word w =>
                let
                   fun single size =
-                     Vector.new1
-                     (x86.Operand.immediate_const_word
-                      (Word.fromIntInf (WordX.toIntInf w)),
-                      size)
+                     Vector.new1 (x86.Operand.immediate_word w, size)
                in
                   case WordSize.prim (WordX.size w) of
                      W8 => single x86.Size.BYTE
@@ -283,13 +280,15 @@
                    | W32 => single x86.Size.LONG
                    | W64 =>
                         let
-                           val w = WordX.toIntInf w
-                           val lo = Word.fromIntInf w
-                           val hi = Word.fromIntInf (IntInf.~>> (w, 0w32))
+                           val lo = WordX.resize (w, WordSize.word32)
+                           val w = WordX.rshift (w, 
+                                                 WordX.fromIntInf (32, WordSize.word64),
+                                                 {signed = true})
+                           val hi = WordX.resize (w, WordSize.word32)
                         in
                            Vector.new2
-                           ((x86.Operand.immediate_const_word lo, x86.Size.LONG),
-                            (x86.Operand.immediate_const_word hi, x86.Size.LONG))
+                           ((x86.Operand.immediate_word lo, x86.Size.LONG),
+                            (x86.Operand.immediate_word hi, x86.Size.LONG))
                         end
                end
     end
@@ -572,12 +571,14 @@
               => Error.bug "x86Translate.Transfer.doSwitchWord"
               | ([(_,l)],       NONE) => goto l
               | ([],         



More information about the MLton-commit mailing list