[project @ 2002-02-06 11:13:47 by sewardj]
authorsewardj <unknown>
Wed, 6 Feb 2002 11:13:49 +0000 (11:13 +0000)
committersewardj <unknown>
Wed, 6 Feb 2002 11:13:49 +0000 (11:13 +0000)
Clean up the AbsC -> AbsC translation of array operations.

* MachOps MO_ReadOSBI and MO_WriteOSBI, which previously did
  array indexing, are gone.  We translate now just to plain
  memory references and explicit address computations.  This
  has the happy side effect that all MachOps now return exactly
  one result (previously it was 0 or 1), cleaning up various
  bits of code.

  As a result the Abstract C structure now contains an unneccessary
  restriction, which is that the result of a MachOp can only be
  assigned to a temporary.  This made sense when MachOps had variable
  numbers of results (0, 1 or 2, originally), but is no longer needed.
  MachOps applied to args could now be allowed to appear as
  arbitrary nodes in expression trees, but so far they are not.

* Get rid of CAddrMode constructor CMem, since it is a special case of
  CVal with a RegRelative of CIndex.

AbstractC is inconsistent and non-orthogonal.  The StixStmt + StixExpr
combination expresses a large part of what AbstractC does in a cleaner
and simpler way, IMO.

ghc/compiler/absCSyn/AbsCSyn.lhs
ghc/compiler/absCSyn/AbsCUtils.lhs
ghc/compiler/absCSyn/MachOp.hs
ghc/compiler/absCSyn/PprAbsC.lhs
ghc/compiler/nativeGen/AbsCStixGen.lhs
ghc/compiler/nativeGen/Stix.lhs
ghc/compiler/nativeGen/StixPrim.lhs

index 91cf8c3..edc2bc0 100644 (file)
@@ -1,7 +1,7 @@
 %
 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
 %
-% $Id: AbsCSyn.lhs,v 1.44 2002/01/02 12:32:19 simonmar Exp $
+% $Id: AbsCSyn.lhs,v 1.45 2002/02/06 11:13:47 sewardj Exp $
 %
 \section[AbstractC]{Abstract C: the last stop before machine code}
 
@@ -122,7 +122,7 @@ stored in a mixed type location.)
   -- NEW CASES FOR EXPANDED PRIMOPS
 
   | CMachOpStmt                        -- Machine-level operation
-       (Maybe CAddrMode)       -- 0 or 1 results
+       CAddrMode               -- result
        MachOp
        [CAddrMode]             -- Arguments
         (Maybe [MagicId])      -- list of regs which need to be preserved
@@ -338,6 +338,10 @@ data CAddrMode
                        --      which gives the magic location itself
                        --      (NB: superceded by CReg)
 
+             -- JRS 2002-02-05: CAddr is really scummy and should be fixed.
+             -- The effect is that the semantics of CAddr depend on what the
+             -- contained RegRelative is; it is decidely non-orthogonal.
+
   | CReg MagicId       -- To replace (CAddr MagicId 0)
 
   | CTemp !Unique !PrimRep     -- Temporary locations
@@ -370,9 +374,6 @@ data CAddrMode
        CExprMacro      -- the macro to generate a value
        [CAddrMode]     -- and its arguments
 
-  | CMem   PrimRep     -- A value :: PrimRep, in memory, at the 
-           CAddrMode   -- specified address
-
   | CBytesPerWord      -- Word size, in bytes, on this platform
                        -- required for: half-word loads (used in fishing tags
                        -- out of info tables), and sizeofByteArray#.
index 52e1085..1e7928f 100644 (file)
@@ -177,7 +177,6 @@ getAmodeRep (CIntLike _)                = PtrRep
 getAmodeRep (CLit lit)                     = literalPrimRep lit
 getAmodeRep (CMacroExpr kind _ _)          = kind
 getAmodeRep (CJoinPoint _)                 = panic "getAmodeRep:CJoinPoint"
-getAmodeRep (CMem rep addr)                 = rep
 \end{code}
 
 @mixedTypeLocn@ tells whether an amode identifies an ``StgWord''
@@ -611,22 +610,22 @@ mkHalfWord_HIADDR res arg
      mkTemp WordRep                    `thenFlt` \ t_hw_mask1 ->
      mkTemp WordRep                    `thenFlt` \ t_hw_mask2 ->
      let a_hw_shift 
-            = CMachOpStmt (Just t_hw_shift) 
+            = CMachOpStmt t_hw_shift
                           MO_Nat_Shl [CBytesPerWord, CLit (mkMachInt 2)] Nothing
          a_hw_mask1
-            = CMachOpStmt (Just t_hw_mask1)
+            = CMachOpStmt t_hw_mask1
                           MO_Nat_Shl [CLit (mkMachWord 1), t_hw_shift] Nothing
          a_hw_mask2
-            = CMachOpStmt (Just t_hw_mask2)
+            = CMachOpStmt t_hw_mask2
                           MO_Nat_Sub [t_hw_mask1, CLit (mkMachWord 1)] Nothing
          final
 #        if WORDS_BIGENDIAN
             = CSequential [ a_hw_shift, a_hw_mask1, a_hw_mask2,
-                 CMachOpStmt (Just res) MO_Nat_And [arg, t_hw_mask2] Nothing
+                 CMachOpStmt res MO_Nat_And [arg, t_hw_mask2] Nothing
               ]
 #        else
             = CSequential [ a_hw_shift,
-                 CMachOpStmt (Just res) MO_Nat_Shr [arg, t_hw_shift] Nothing
+                 CMachOpStmt res MO_Nat_Shr [arg, t_hw_shift] Nothing
               ]
 #        endif
      in
@@ -639,17 +638,6 @@ mkTemp rep
 
 mkTemps = mapFlt mkTemp
 
-mkDerefOff :: PrimRep -> CAddrMode -> Int -> CAddrMode
-mkDerefOff rep base off
-   | off == 0  -- optimisation
-   = CMem rep base
-   | otherwise
-   = CMem rep (CAddr (CIndex base (CLit (mkMachInt (toInteger off))) rep))
-
-mkNoDerefOff :: PrimRep -> CAddrMode -> Int -> CAddrMode
-mkNoDerefOff rep base off
-   = CAddr (CIndex base (CLit (mkMachInt (toInteger off))) rep)
-
 -- Sigh.  This is done in 3 seperate places.  Should be
 -- commoned up (here, in pprAbsC of COpStmt, and presumably
 -- somewhere in the NCG).
@@ -660,6 +648,28 @@ non_void_amode amode
 
 -- Helpers for translating various minor variants of array indexing.
 
+mkDerefOff :: PrimRep -> CAddrMode -> Int -> CAddrMode
+mkDerefOff rep base off
+   = CVal (CIndex base (CLit (mkMachInt (toInteger off))) rep) rep
+
+mkNoDerefOff :: PrimRep -> CAddrMode -> Int -> CAddrMode
+mkNoDerefOff rep base off
+   = CAddr (CIndex base (CLit (mkMachInt (toInteger off))) rep)
+
+
+-- Generates an address as follows
+--    base + sizeof(machine_word)*offw + sizeof(rep)*idx
+mk_OSBI_addr :: Int -> PrimRep -> CAddrMode -> CAddrMode -> RegRelative
+mk_OSBI_addr offw rep base idx
+   = CIndex (CAddr (CIndex base idx rep)) 
+            (CLit (mkMachWord (fromIntegral offw))) 
+            PtrRep
+
+mk_OSBI_ref :: Int -> PrimRep -> CAddrMode -> CAddrMode -> CAddrMode
+mk_OSBI_ref offw rep base idx
+   = CVal (mk_OSBI_addr offw rep base idx) rep
+
+
 doIndexOffForeignObjOp maybe_post_read_cast rep res addr idx
    = mkBasicIndexedRead fixedHdrSize maybe_post_read_cast rep res addr idx
 
@@ -686,24 +696,24 @@ doWritePtrArrayOp addr idx val
 
 mkBasicIndexedRead offw Nothing read_rep res base idx
    = returnFlt (
-        CMachOpStmt (Just res) (MO_ReadOSBI offw read_rep) [base,idx] Nothing
+        CAssign res (mk_OSBI_ref offw read_rep base idx)
      )
 mkBasicIndexedRead offw (Just cast_to_mop) read_rep res base idx
    = mkTemp read_rep                   `thenFlt` \ tmp ->
      (returnFlt . CSequential) [
-        CMachOpStmt (Just tmp) (MO_ReadOSBI offw read_rep) [base,idx] Nothing,
-        CMachOpStmt (Just res) cast_to_mop [tmp] Nothing
+        CAssign tmp (mk_OSBI_ref offw read_rep base idx),
+        CMachOpStmt res cast_to_mop [tmp] Nothing
      ]
 
 mkBasicIndexedWrite offw Nothing write_rep base idx val
    = returnFlt (
-        CMachOpStmt Nothing (MO_WriteOSBI offw write_rep) [base,idx,val] Nothing
+        CAssign (mk_OSBI_ref offw write_rep base idx) val
      )
 mkBasicIndexedWrite offw (Just cast_to_mop) write_rep base idx val
    = mkTemp write_rep                  `thenFlt` \ tmp ->
      (returnFlt . CSequential) [
-        CMachOpStmt (Just tmp) cast_to_mop [val] Nothing,
-        CMachOpStmt Nothing (MO_WriteOSBI offw write_rep) [base,idx,tmp] Nothing
+        CMachOpStmt tmp cast_to_mop [val] Nothing,
+        CAssign (mk_OSBI_ref offw write_rep base idx) tmp
      ]
 
 
@@ -713,7 +723,7 @@ translateOp_dyadic_cast1 mop res cast_arg1_to arg1 arg2 vols
    = mkTemp cast_arg1_to               `thenFlt` \ arg1casted ->
      (returnFlt . CSequential) [
         CAssign arg1casted arg1,
-        CMachOpStmt (Just res) mop [arg1casted,arg2]
+        CMachOpStmt res mop [arg1casted,arg2]
            (if isDefinitelyInlineMachOp mop then Nothing else Just vols)
      ]
 
@@ -722,9 +732,9 @@ getBitsPerWordMinus1
    = mkTemps [IntRep, IntRep]          `thenFlt` \ [t1,t2] ->
      returnFlt (
         CSequential [
-           CMachOpStmt (Just t1) MO_Nat_Shl 
+           CMachOpStmt t1 MO_Nat_Shl 
                        [CBytesPerWord, CLit (mkMachInt 3)] Nothing,
-           CMachOpStmt (Just t2) MO_Nat_Sub
+           CMachOpStmt t2 MO_Nat_Sub
                        [t1, CLit (mkMachInt 1)] Nothing
         ],
         t2
@@ -775,13 +785,13 @@ dscCOpStmt [res_r,res_c] IntAddCOp [aa,bb] vols
    = mkTemps [IntRep,IntRep,IntRep,IntRep]     `thenFlt` \ [t1,t2,t3,t4] ->
      getBitsPerWordMinus1                      `thenFlt` \ (bpw1_code,bpw1_t) ->
      (returnFlt . CSequential) [
-        CMachOpStmt (Just res_r) MO_Nat_Add [aa,bb] Nothing,
-        CMachOpStmt (Just t1) MO_Nat_Xor [aa,bb] Nothing,
-        CMachOpStmt (Just t2) MO_Nat_Not [t1] Nothing,
-        CMachOpStmt (Just t3) MO_Nat_Xor [aa,res_r] Nothing,
-        CMachOpStmt (Just t4) MO_Nat_And [t2,t3] Nothing,
+        CMachOpStmt res_r MO_Nat_Add [aa,bb] Nothing,
+        CMachOpStmt t1 MO_Nat_Xor [aa,bb] Nothing,
+        CMachOpStmt t2 MO_Nat_Not [t1] Nothing,
+        CMachOpStmt t3 MO_Nat_Xor [aa,res_r] Nothing,
+        CMachOpStmt t4 MO_Nat_And [t2,t3] Nothing,
         bpw1_code,
-        CMachOpStmt (Just res_c) MO_Nat_Shr [t4, bpw1_t] Nothing
+        CMachOpStmt res_c MO_Nat_Shr [t4, bpw1_t] Nothing
      ]
 
 
@@ -803,12 +813,12 @@ dscCOpStmt [res_r,res_c] IntSubCOp [aa,bb] vols
    = mkTemps [IntRep,IntRep,IntRep]            `thenFlt` \ [t1,t2,t3] ->
      getBitsPerWordMinus1                      `thenFlt` \ (bpw1_code,bpw1_t) ->
      (returnFlt . CSequential) [
-        CMachOpStmt (Just res_r) MO_Nat_Sub [aa,bb] Nothing,
-        CMachOpStmt (Just t1) MO_Nat_Xor [aa,bb] Nothing,
-        CMachOpStmt (Just t2) MO_Nat_Xor [aa,res_r] Nothing,
-        CMachOpStmt (Just t3) MO_Nat_And [t1,t2] Nothing,
+        CMachOpStmt res_r MO_Nat_Sub [aa,bb] Nothing,
+        CMachOpStmt t1 MO_Nat_Xor [aa,bb] Nothing,
+        CMachOpStmt t2 MO_Nat_Xor [aa,res_r] Nothing,
+        CMachOpStmt t3 MO_Nat_And [t1,t2] Nothing,
         bpw1_code,
-        CMachOpStmt (Just res_c) MO_Nat_Shr [t3, bpw1_t] Nothing
+        CMachOpStmt res_c MO_Nat_Shr [t3, bpw1_t] Nothing
      ]
 
 
@@ -847,8 +857,7 @@ dscCOpStmt [res] SizeofByteArrayOp [arg] vols
    = mkTemp WordRep                    `thenFlt` \ w ->
      (returnFlt . CSequential) [
         CAssign w (mkDerefOff WordRep arg fixedHdrSize),
-        CMachOpStmt (Just w) 
-           MO_NatU_Mul [w, CBytesPerWord] (Just vols),
+        CMachOpStmt w MO_NatU_Mul [w, CBytesPerWord] (Just vols),
         CAssign res w
      ]
 
@@ -866,7 +875,7 @@ dscCOpStmt [] TouchOp [arg] vols
 dscCOpStmt [res] ByteArrayContents_Char [arg] vols
    = mkTemp PtrRep                     `thenFlt` \ ptr ->
      (returnFlt . CSequential) [
-         CMachOpStmt (Just ptr) MO_NatU_to_NatP [arg] Nothing,
+         CMachOpStmt ptr MO_NatU_to_NatP [arg] Nothing,
          CAssign ptr (mkNoDerefOff WordRep ptr arrWordsHdrSize),
          CAssign res ptr
      ]
@@ -883,7 +892,7 @@ dscCOpStmt [res] EqStableNameOp [arg1,arg2] vols
      (returnFlt . CSequential) [
         CAssign sn1 (mkDerefOff WordRep arg1 fixedHdrSize),
         CAssign sn2 (mkDerefOff WordRep arg2 fixedHdrSize),
-        CMachOpStmt (Just res) MO_Nat_Eq [sn1,sn2] Nothing
+        CMachOpStmt res MO_Nat_Eq [sn1,sn2] Nothing
      ]
 
 -- #define addrToHValuezh(r,a) r=(P_)a
@@ -928,8 +937,8 @@ dscCOpStmt [res] UnsafeFreezeByteArrayOp [arg] vols
 dscCOpStmt [r] AddrRemOp [a1,a2] vols 
    = mkTemp WordRep                    `thenFlt` \ a1casted ->
      (returnFlt . CSequential) [
-        CMachOpStmt (Just a1casted) MO_NatP_to_NatU [a1] Nothing,
-        CMachOpStmt (Just r) MO_NatU_Rem [a1casted,a2] Nothing
+        CMachOpStmt a1casted MO_NatP_to_NatU [a1] Nothing,
+        CMachOpStmt r MO_NatU_Rem [a1casted,a2] Nothing
      ]
 
 -- not handled by translateOp because they need casts
@@ -1113,158 +1122,158 @@ dscCOpStmt ress op args vols
 
 -- Native word signless ops
 
-translateOp [r] IntAddOp       [a1,a2] = Just (Just r, MO_Nat_Add,        [a1,a2])
-translateOp [r] IntSubOp       [a1,a2] = Just (Just r, MO_Nat_Sub,        [a1,a2])
-translateOp [r] WordAddOp      [a1,a2] = Just (Just r, MO_Nat_Add,        [a1,a2])
-translateOp [r] WordSubOp      [a1,a2] = Just (Just r, MO_Nat_Sub,        [a1,a2])
-translateOp [r] AddrAddOp      [a1,a2] = Just (Just r, MO_Nat_Add,        [a1,a2])
-translateOp [r] AddrSubOp      [a1,a2] = Just (Just r, MO_Nat_Sub,        [a1,a2])
-
-translateOp [r] IntEqOp        [a1,a2] = Just (Just r, MO_Nat_Eq,         [a1,a2])
-translateOp [r] IntNeOp        [a1,a2] = Just (Just r, MO_Nat_Ne,         [a1,a2])
-translateOp [r] WordEqOp       [a1,a2] = Just (Just r, MO_Nat_Eq,         [a1,a2])
-translateOp [r] WordNeOp       [a1,a2] = Just (Just r, MO_Nat_Ne,         [a1,a2])
-translateOp [r] AddrEqOp       [a1,a2] = Just (Just r, MO_Nat_Eq,         [a1,a2])
-translateOp [r] AddrNeOp       [a1,a2] = Just (Just r, MO_Nat_Ne,         [a1,a2])
-
-translateOp [r] AndOp          [a1,a2] = Just (Just r, MO_Nat_And,        [a1,a2])
-translateOp [r] OrOp           [a1,a2] = Just (Just r, MO_Nat_Or,         [a1,a2])
-translateOp [r] XorOp          [a1,a2] = Just (Just r, MO_Nat_Xor,        [a1,a2])
-translateOp [r] NotOp          [a1]    = Just (Just r, MO_Nat_Not,        [a1])
+translateOp [r] IntAddOp       [a1,a2] = Just (r, MO_Nat_Add,        [a1,a2])
+translateOp [r] IntSubOp       [a1,a2] = Just (r, MO_Nat_Sub,        [a1,a2])
+translateOp [r] WordAddOp      [a1,a2] = Just (r, MO_Nat_Add,        [a1,a2])
+translateOp [r] WordSubOp      [a1,a2] = Just (r, MO_Nat_Sub,        [a1,a2])
+translateOp [r] AddrAddOp      [a1,a2] = Just (r, MO_Nat_Add,        [a1,a2])
+translateOp [r] AddrSubOp      [a1,a2] = Just (r, MO_Nat_Sub,        [a1,a2])
+
+translateOp [r] IntEqOp        [a1,a2] = Just (r, MO_Nat_Eq,         [a1,a2])
+translateOp [r] IntNeOp        [a1,a2] = Just (r, MO_Nat_Ne,         [a1,a2])
+translateOp [r] WordEqOp       [a1,a2] = Just (r, MO_Nat_Eq,         [a1,a2])
+translateOp [r] WordNeOp       [a1,a2] = Just (r, MO_Nat_Ne,         [a1,a2])
+translateOp [r] AddrEqOp       [a1,a2] = Just (r, MO_Nat_Eq,         [a1,a2])
+translateOp [r] AddrNeOp       [a1,a2] = Just (r, MO_Nat_Ne,         [a1,a2])
+
+translateOp [r] AndOp          [a1,a2] = Just (r, MO_Nat_And,        [a1,a2])
+translateOp [r] OrOp           [a1,a2] = Just (r, MO_Nat_Or,         [a1,a2])
+translateOp [r] XorOp          [a1,a2] = Just (r, MO_Nat_Xor,        [a1,a2])
+translateOp [r] NotOp          [a1]    = Just (r, MO_Nat_Not,        [a1])
 
 -- Native word signed ops
 
-translateOp [r] IntMulOp       [a1,a2] = Just (Just r, MO_NatS_Mul,       [a1,a2])
-translateOp [r] IntMulMayOfloOp [a1,a2] = Just (Just r, MO_NatS_MulMayOflo, [a1,a2])
-translateOp [r] IntQuotOp      [a1,a2] = Just (Just r, MO_NatS_Quot,      [a1,a2])
-translateOp [r] IntRemOp       [a1,a2] = Just (Just r, MO_NatS_Rem,       [a1,a2])
-translateOp [r] IntNegOp       [a1]    = Just (Just r, MO_NatS_Neg,       [a1])
+translateOp [r] IntMulOp       [a1,a2] = Just (r, MO_NatS_Mul,       [a1,a2])
+translateOp [r] IntMulMayOfloOp [a1,a2] = Just (r, MO_NatS_MulMayOflo, [a1,a2])
+translateOp [r] IntQuotOp      [a1,a2] = Just (r, MO_NatS_Quot,      [a1,a2])
+translateOp [r] IntRemOp       [a1,a2] = Just (r, MO_NatS_Rem,       [a1,a2])
+translateOp [r] IntNegOp       [a1]    = Just (r, MO_NatS_Neg,       [a1])
 
-translateOp [r] IntGeOp        [a1,a2] = Just (Just r, MO_NatS_Ge,        [a1,a2])
-translateOp [r] IntLeOp        [a1,a2] = Just (Just r, MO_NatS_Le,        [a1,a2])
-translateOp [r] IntGtOp        [a1,a2] = Just (Just r, MO_NatS_Gt,        [a1,a2])
-translateOp [r] IntLtOp        [a1,a2] = Just (Just r, MO_NatS_Lt,        [a1,a2])
+translateOp [r] IntGeOp        [a1,a2] = Just (r, MO_NatS_Ge,        [a1,a2])
+translateOp [r] IntLeOp        [a1,a2] = Just (r, MO_NatS_Le,        [a1,a2])
+translateOp [r] IntGtOp        [a1,a2] = Just (r, MO_NatS_Gt,        [a1,a2])
+translateOp [r] IntLtOp        [a1,a2] = Just (r, MO_NatS_Lt,        [a1,a2])
 
 
 -- Native word unsigned ops
 
-translateOp [r] WordGeOp       [a1,a2] = Just (Just r, MO_NatU_Ge,        [a1,a2])
-translateOp [r] WordLeOp       [a1,a2] = Just (Just r, MO_NatU_Le,        [a1,a2])
-translateOp [r] WordGtOp       [a1,a2] = Just (Just r, MO_NatU_Gt,        [a1,a2])
-translateOp [r] WordLtOp       [a1,a2] = Just (Just r, MO_NatU_Lt,        [a1,a2])
+translateOp [r] WordGeOp       [a1,a2] = Just (r, MO_NatU_Ge,        [a1,a2])
+translateOp [r] WordLeOp       [a1,a2] = Just (r, MO_NatU_Le,        [a1,a2])
+translateOp [r] WordGtOp       [a1,a2] = Just (r, MO_NatU_Gt,        [a1,a2])
+translateOp [r] WordLtOp       [a1,a2] = Just (r, MO_NatU_Lt,        [a1,a2])
 
-translateOp [r] WordMulOp      [a1,a2] = Just (Just r, MO_NatU_Mul,       [a1,a2])
-translateOp [r] WordQuotOp     [a1,a2] = Just (Just r, MO_NatU_Quot,      [a1,a2])
-translateOp [r] WordRemOp      [a1,a2] = Just (Just r, MO_NatU_Rem,       [a1,a2])
+translateOp [r] WordMulOp      [a1,a2] = Just (r, MO_NatU_Mul,       [a1,a2])
+translateOp [r] WordQuotOp     [a1,a2] = Just (r, MO_NatU_Quot,      [a1,a2])
+translateOp [r] WordRemOp      [a1,a2] = Just (r, MO_NatU_Rem,       [a1,a2])
 
-translateOp [r] AddrGeOp       [a1,a2] = Just (Just r, MO_NatU_Ge,        [a1,a2])
-translateOp [r] AddrLeOp       [a1,a2] = Just (Just r, MO_NatU_Le,        [a1,a2])
-translateOp [r] AddrGtOp       [a1,a2] = Just (Just r, MO_NatU_Gt,        [a1,a2])
-translateOp [r] AddrLtOp       [a1,a2] = Just (Just r, MO_NatU_Lt,        [a1,a2])
+translateOp [r] AddrGeOp       [a1,a2] = Just (r, MO_NatU_Ge,        [a1,a2])
+translateOp [r] AddrLeOp       [a1,a2] = Just (r, MO_NatU_Le,        [a1,a2])
+translateOp [r] AddrGtOp       [a1,a2] = Just (r, MO_NatU_Gt,        [a1,a2])
+translateOp [r] AddrLtOp       [a1,a2] = Just (r, MO_NatU_Lt,        [a1,a2])
 
 -- 32-bit unsigned ops
 
-translateOp [r] CharEqOp       [a1,a2] = Just (Just r, MO_32U_Eq,        [a1,a2])
-translateOp [r] CharNeOp       [a1,a2] = Just (Just r, MO_32U_Ne,        [a1,a2])
-translateOp [r] CharGeOp       [a1,a2] = Just (Just r, MO_32U_Ge,        [a1,a2])
-translateOp [r] CharLeOp       [a1,a2] = Just (Just r, MO_32U_Le,        [a1,a2])
-translateOp [r] CharGtOp       [a1,a2] = Just (Just r, MO_32U_Gt,        [a1,a2])
-translateOp [r] CharLtOp       [a1,a2] = Just (Just r, MO_32U_Lt,        [a1,a2])
+translateOp [r] CharEqOp       [a1,a2] = Just (r, MO_32U_Eq,        [a1,a2])
+translateOp [r] CharNeOp       [a1,a2] = Just (r, MO_32U_Ne,        [a1,a2])
+translateOp [r] CharGeOp       [a1,a2] = Just (r, MO_32U_Ge,        [a1,a2])
+translateOp [r] CharLeOp       [a1,a2] = Just (r, MO_32U_Le,        [a1,a2])
+translateOp [r] CharGtOp       [a1,a2] = Just (r, MO_32U_Gt,        [a1,a2])
+translateOp [r] CharLtOp       [a1,a2] = Just (r, MO_32U_Lt,        [a1,a2])
 
 -- Double ops
 
-translateOp [r] DoubleEqOp     [a1,a2] = Just (Just r, MO_Dbl_Eq,      [a1,a2])
-translateOp [r] DoubleNeOp     [a1,a2] = Just (Just r, MO_Dbl_Ne,      [a1,a2])
-translateOp [r] DoubleGeOp     [a1,a2] = Just (Just r, MO_Dbl_Ge,      [a1,a2])
-translateOp [r] DoubleLeOp     [a1,a2] = Just (Just r, MO_Dbl_Le,      [a1,a2])
-translateOp [r] DoubleGtOp     [a1,a2] = Just (Just r, MO_Dbl_Gt,      [a1,a2])
-translateOp [r] DoubleLtOp     [a1,a2] = Just (Just r, MO_Dbl_Lt,      [a1,a2])
-
-translateOp [r] DoubleAddOp    [a1,a2] = Just (Just r, MO_Dbl_Add,    [a1,a2])
-translateOp [r] DoubleSubOp    [a1,a2] = Just (Just r, MO_Dbl_Sub,    [a1,a2])
-translateOp [r] DoubleMulOp    [a1,a2] = Just (Just r, MO_Dbl_Mul,    [a1,a2])
-translateOp [r] DoubleDivOp    [a1,a2] = Just (Just r, MO_Dbl_Div,    [a1,a2])
-translateOp [r] DoublePowerOp  [a1,a2] = Just (Just r, MO_Dbl_Pwr,    [a1,a2])
-
-translateOp [r] DoubleSinOp    [a1]    = Just (Just r, MO_Dbl_Sin,    [a1])
-translateOp [r] DoubleCosOp    [a1]    = Just (Just r, MO_Dbl_Cos,    [a1])
-translateOp [r] DoubleTanOp    [a1]    = Just (Just r, MO_Dbl_Tan,    [a1])
-translateOp [r] DoubleSinhOp   [a1]    = Just (Just r, MO_Dbl_Sinh,   [a1])
-translateOp [r] DoubleCoshOp   [a1]    = Just (Just r, MO_Dbl_Cosh,   [a1])
-translateOp [r] DoubleTanhOp   [a1]    = Just (Just r, MO_Dbl_Tanh,   [a1])
-translateOp [r] DoubleAsinOp   [a1]    = Just (Just r, MO_Dbl_Asin,    [a1])
-translateOp [r] DoubleAcosOp   [a1]    = Just (Just r, MO_Dbl_Acos,    [a1])
-translateOp [r] DoubleAtanOp   [a1]    = Just (Just r, MO_Dbl_Atan,    [a1])
-translateOp [r] DoubleLogOp    [a1]    = Just (Just r, MO_Dbl_Log,    [a1])
-translateOp [r] DoubleExpOp    [a1]    = Just (Just r, MO_Dbl_Exp,    [a1])
-translateOp [r] DoubleSqrtOp   [a1]    = Just (Just r, MO_Dbl_Sqrt,    [a1])
-translateOp [r] DoubleNegOp    [a1]    = Just (Just r, MO_Dbl_Neg,    [a1])
+translateOp [r] DoubleEqOp     [a1,a2] = Just (r, MO_Dbl_Eq,      [a1,a2])
+translateOp [r] DoubleNeOp     [a1,a2] = Just (r, MO_Dbl_Ne,      [a1,a2])
+translateOp [r] DoubleGeOp     [a1,a2] = Just (r, MO_Dbl_Ge,      [a1,a2])
+translateOp [r] DoubleLeOp     [a1,a2] = Just (r, MO_Dbl_Le,      [a1,a2])
+translateOp [r] DoubleGtOp     [a1,a2] = Just (r, MO_Dbl_Gt,      [a1,a2])
+translateOp [r] DoubleLtOp     [a1,a2] = Just (r, MO_Dbl_Lt,      [a1,a2])
+
+translateOp [r] DoubleAddOp    [a1,a2] = Just (r, MO_Dbl_Add,    [a1,a2])
+translateOp [r] DoubleSubOp    [a1,a2] = Just (r, MO_Dbl_Sub,    [a1,a2])
+translateOp [r] DoubleMulOp    [a1,a2] = Just (r, MO_Dbl_Mul,    [a1,a2])
+translateOp [r] DoubleDivOp    [a1,a2] = Just (r, MO_Dbl_Div,    [a1,a2])
+translateOp [r] DoublePowerOp  [a1,a2] = Just (r, MO_Dbl_Pwr,    [a1,a2])
+
+translateOp [r] DoubleSinOp    [a1]    = Just (r, MO_Dbl_Sin,    [a1])
+translateOp [r] DoubleCosOp    [a1]    = Just (r, MO_Dbl_Cos,    [a1])
+translateOp [r] DoubleTanOp    [a1]    = Just (r, MO_Dbl_Tan,    [a1])
+translateOp [r] DoubleSinhOp   [a1]    = Just (r, MO_Dbl_Sinh,   [a1])
+translateOp [r] DoubleCoshOp   [a1]    = Just (r, MO_Dbl_Cosh,   [a1])
+translateOp [r] DoubleTanhOp   [a1]    = Just (r, MO_Dbl_Tanh,   [a1])
+translateOp [r] DoubleAsinOp   [a1]    = Just (r, MO_Dbl_Asin,    [a1])
+translateOp [r] DoubleAcosOp   [a1]    = Just (r, MO_Dbl_Acos,    [a1])
+translateOp [r] DoubleAtanOp   [a1]    = Just (r, MO_Dbl_Atan,    [a1])
+translateOp [r] DoubleLogOp    [a1]    = Just (r, MO_Dbl_Log,    [a1])
+translateOp [r] DoubleExpOp    [a1]    = Just (r, MO_Dbl_Exp,    [a1])
+translateOp [r] DoubleSqrtOp   [a1]    = Just (r, MO_Dbl_Sqrt,    [a1])
+translateOp [r] DoubleNegOp    [a1]    = Just (r, MO_Dbl_Neg,    [a1])
 
 -- Float ops
 
-translateOp [r] FloatEqOp     [a1,a2] = Just (Just r, MO_Flt_Eq,      [a1,a2])
-translateOp [r] FloatNeOp     [a1,a2] = Just (Just r, MO_Flt_Ne,      [a1,a2])
-translateOp [r] FloatGeOp     [a1,a2] = Just (Just r, MO_Flt_Ge,      [a1,a2])
-translateOp [r] FloatLeOp     [a1,a2] = Just (Just r, MO_Flt_Le,      [a1,a2])
-translateOp [r] FloatGtOp     [a1,a2] = Just (Just r, MO_Flt_Gt,      [a1,a2])
-translateOp [r] FloatLtOp     [a1,a2] = Just (Just r, MO_Flt_Lt,      [a1,a2])
-
-translateOp [r] FloatAddOp    [a1,a2] = Just (Just r, MO_Flt_Add,    [a1,a2])
-translateOp [r] FloatSubOp    [a1,a2] = Just (Just r, MO_Flt_Sub,    [a1,a2])
-translateOp [r] FloatMulOp    [a1,a2] = Just (Just r, MO_Flt_Mul,    [a1,a2])
-translateOp [r] FloatDivOp    [a1,a2] = Just (Just r, MO_Flt_Div,    [a1,a2])
-translateOp [r] FloatPowerOp  [a1,a2] = Just (Just r, MO_Flt_Pwr,    [a1,a2])
-
-translateOp [r] FloatSinOp    [a1]    = Just (Just r, MO_Flt_Sin,    [a1])
-translateOp [r] FloatCosOp    [a1]    = Just (Just r, MO_Flt_Cos,    [a1])
-translateOp [r] FloatTanOp    [a1]    = Just (Just r, MO_Flt_Tan,    [a1])
-translateOp [r] FloatSinhOp   [a1]    = Just (Just r, MO_Flt_Sinh,   [a1])
-translateOp [r] FloatCoshOp   [a1]    = Just (Just r, MO_Flt_Cosh,   [a1])
-translateOp [r] FloatTanhOp   [a1]    = Just (Just r, MO_Flt_Tanh,   [a1])
-translateOp [r] FloatAsinOp   [a1]    = Just (Just r, MO_Flt_Asin,    [a1])
-translateOp [r] FloatAcosOp   [a1]    = Just (Just r, MO_Flt_Acos,    [a1])
-translateOp [r] FloatAtanOp   [a1]    = Just (Just r, MO_Flt_Atan,    [a1])
-translateOp [r] FloatLogOp    [a1]    = Just (Just r, MO_Flt_Log,    [a1])
-translateOp [r] FloatExpOp    [a1]    = Just (Just r, MO_Flt_Exp,    [a1])
-translateOp [r] FloatSqrtOp   [a1]    = Just (Just r, MO_Flt_Sqrt,    [a1])
-translateOp [r] FloatNegOp    [a1]    = Just (Just r, MO_Flt_Neg,    [a1])
+translateOp [r] FloatEqOp     [a1,a2] = Just (r, MO_Flt_Eq,      [a1,a2])
+translateOp [r] FloatNeOp     [a1,a2] = Just (r, MO_Flt_Ne,      [a1,a2])
+translateOp [r] FloatGeOp     [a1,a2] = Just (r, MO_Flt_Ge,      [a1,a2])
+translateOp [r] FloatLeOp     [a1,a2] = Just (r, MO_Flt_Le,      [a1,a2])
+translateOp [r] FloatGtOp     [a1,a2] = Just (r, MO_Flt_Gt,      [a1,a2])
+translateOp [r] FloatLtOp     [a1,a2] = Just (r, MO_Flt_Lt,      [a1,a2])
+
+translateOp [r] FloatAddOp    [a1,a2] = Just (r, MO_Flt_Add,    [a1,a2])
+translateOp [r] FloatSubOp    [a1,a2] = Just (r, MO_Flt_Sub,    [a1,a2])
+translateOp [r] FloatMulOp    [a1,a2] = Just (r, MO_Flt_Mul,    [a1,a2])
+translateOp [r] FloatDivOp    [a1,a2] = Just (r, MO_Flt_Div,    [a1,a2])
+translateOp [r] FloatPowerOp  [a1,a2] = Just (r, MO_Flt_Pwr,    [a1,a2])
+
+translateOp [r] FloatSinOp    [a1]    = Just (r, MO_Flt_Sin,    [a1])
+translateOp [r] FloatCosOp    [a1]    = Just (r, MO_Flt_Cos,    [a1])
+translateOp [r] FloatTanOp    [a1]    = Just (r, MO_Flt_Tan,    [a1])
+translateOp [r] FloatSinhOp   [a1]    = Just (r, MO_Flt_Sinh,   [a1])
+translateOp [r] FloatCoshOp   [a1]    = Just (r, MO_Flt_Cosh,   [a1])
+translateOp [r] FloatTanhOp   [a1]    = Just (r, MO_Flt_Tanh,   [a1])
+translateOp [r] FloatAsinOp   [a1]    = Just (r, MO_Flt_Asin,    [a1])
+translateOp [r] FloatAcosOp   [a1]    = Just (r, MO_Flt_Acos,    [a1])
+translateOp [r] FloatAtanOp   [a1]    = Just (r, MO_Flt_Atan,    [a1])
+translateOp [r] FloatLogOp    [a1]    = Just (r, MO_Flt_Log,    [a1])
+translateOp [r] FloatExpOp    [a1]    = Just (r, MO_Flt_Exp,    [a1])
+translateOp [r] FloatSqrtOp   [a1]    = Just (r, MO_Flt_Sqrt,    [a1])
+translateOp [r] FloatNegOp    [a1]    = Just (r, MO_Flt_Neg,    [a1])
 
 -- Conversions
 
-translateOp [r] Int2DoubleOp   [a1]   = Just (Just r, MO_NatS_to_Dbl,   [a1])
-translateOp [r] Double2IntOp   [a1]   = Just (Just r, MO_Dbl_to_NatS,   [a1])
+translateOp [r] Int2DoubleOp   [a1]   = Just (r, MO_NatS_to_Dbl,   [a1])
+translateOp [r] Double2IntOp   [a1]   = Just (r, MO_Dbl_to_NatS,   [a1])
 
-translateOp [r] Int2FloatOp    [a1]   = Just (Just r, MO_NatS_to_Flt,   [a1])
-translateOp [r] Float2IntOp    [a1]   = Just (Just r, MO_Flt_to_NatS,   [a1])
+translateOp [r] Int2FloatOp    [a1]   = Just (r, MO_NatS_to_Flt,   [a1])
+translateOp [r] Float2IntOp    [a1]   = Just (r, MO_Flt_to_NatS,   [a1])
 
-translateOp [r] Float2DoubleOp [a1]   = Just (Just r, MO_Flt_to_Dbl,    [a1])
-translateOp [r] Double2FloatOp [a1]   = Just (Just r, MO_Dbl_to_Flt,    [a1])
+translateOp [r] Float2DoubleOp [a1]   = Just (r, MO_Flt_to_Dbl,    [a1])
+translateOp [r] Double2FloatOp [a1]   = Just (r, MO_Dbl_to_Flt,    [a1])
 
-translateOp [r] Int2WordOp     [a1]   = Just (Just r, MO_NatS_to_NatU,  [a1])
-translateOp [r] Word2IntOp     [a1]   = Just (Just r, MO_NatU_to_NatS,  [a1])
+translateOp [r] Int2WordOp     [a1]   = Just (r, MO_NatS_to_NatU,  [a1])
+translateOp [r] Word2IntOp     [a1]   = Just (r, MO_NatU_to_NatS,  [a1])
 
-translateOp [r] Int2AddrOp     [a1]   = Just (Just r, MO_NatS_to_NatP,  [a1])
-translateOp [r] Addr2IntOp     [a1]   = Just (Just r, MO_NatP_to_NatS,  [a1])
+translateOp [r] Int2AddrOp     [a1]   = Just (r, MO_NatS_to_NatP,  [a1])
+translateOp [r] Addr2IntOp     [a1]   = Just (r, MO_NatP_to_NatS,  [a1])
 
-translateOp [r] OrdOp          [a1]   = Just (Just r, MO_32U_to_NatS,   [a1])
-translateOp [r] ChrOp          [a1]   = Just (Just r, MO_NatS_to_32U,   [a1])
+translateOp [r] OrdOp          [a1]   = Just (r, MO_32U_to_NatS,   [a1])
+translateOp [r] ChrOp          [a1]   = Just (r, MO_NatS_to_32U,   [a1])
 
-translateOp [r] Narrow8IntOp   [a1]   = Just (Just r, MO_8S_to_NatS,    [a1])
-translateOp [r] Narrow16IntOp  [a1]   = Just (Just r, MO_16S_to_NatS,   [a1])
-translateOp [r] Narrow32IntOp  [a1]   = Just (Just r, MO_32S_to_NatS,   [a1])
+translateOp [r] Narrow8IntOp   [a1]   = Just (r, MO_8S_to_NatS,    [a1])
+translateOp [r] Narrow16IntOp  [a1]   = Just (r, MO_16S_to_NatS,   [a1])
+translateOp [r] Narrow32IntOp  [a1]   = Just (r, MO_32S_to_NatS,   [a1])
 
-translateOp [r] Narrow8WordOp   [a1]  = Just (Just r, MO_8U_to_NatU,    [a1])
-translateOp [r] Narrow16WordOp  [a1]  = Just (Just r, MO_16U_to_NatU,   [a1])
-translateOp [r] Narrow32WordOp  [a1]  = Just (Just r, MO_32U_to_NatU,   [a1])
+translateOp [r] Narrow8WordOp   [a1]  = Just (r, MO_8U_to_NatU,    [a1])
+translateOp [r] Narrow16WordOp  [a1]  = Just (r, MO_16U_to_NatU,   [a1])
+translateOp [r] Narrow32WordOp  [a1]  = Just (r, MO_32U_to_NatU,   [a1])
 
 -- Word comparisons masquerading as more exotic things.
 
-translateOp [r] SameMutVarOp   [a1,a2]  = Just (Just r, MO_Nat_Eq,    [a1,a2])
-translateOp [r] SameMVarOp     [a1,a2]  = Just (Just r, MO_Nat_Eq,    [a1,a2])
-translateOp [r] SameMutableArrayOp  [a1,a2]  = Just (Just r, MO_Nat_Eq,    [a1,a2])
-translateOp [r] SameMutableByteArrayOp [a1,a2]  = Just (Just r, MO_Nat_Eq,    [a1,a2])
-translateOp [r] EqForeignObj [a1,a2]  = Just (Just r, MO_Nat_Eq,    [a1,a2])
-translateOp [r] EqStablePtrOp [a1,a2]  = Just (Just r, MO_Nat_Eq,    [a1,a2])
+translateOp [r] SameMutVarOp   [a1,a2]  = Just (r, MO_Nat_Eq,    [a1,a2])
+translateOp [r] SameMVarOp     [a1,a2]  = Just (r, MO_Nat_Eq,    [a1,a2])
+translateOp [r] SameMutableArrayOp  [a1,a2]  = Just (r, MO_Nat_Eq,    [a1,a2])
+translateOp [r] SameMutableByteArrayOp [a1,a2]  = Just (r, MO_Nat_Eq,    [a1,a2])
+translateOp [r] EqForeignObj [a1,a2]  = Just (r, MO_Nat_Eq,    [a1,a2])
+translateOp [r] EqStablePtrOp [a1,a2]  = Just (r, MO_Nat_Eq,    [a1,a2])
 
 translateOp _ _ _ = Nothing
 
index 4ac6e8e..087a403 100644 (file)
@@ -3,7 +3,7 @@ module MachOp   ( MachOp(..), pprMachOp,
                  isDefinitelyInlineMachOp, 
                  isCommutableMachOp,
                  isComparisonMachOp,
-                  resultRepsOfMachOp
+                  resultRepOfMachOp
                  )
 where
 
@@ -162,12 +162,6 @@ data MachOp
   | MO_8U_to_32U       -- zero extend
   | MO_32U_to_8U       -- mask out all but lowest byte
 
-  -- Reading/writing arrays
-  | MO_ReadOSBI Int PrimRep   -- args: [base_ptr, index_value]
-  | MO_WriteOSBI Int PrimRep  -- args: [base_ptr, index_value, value_to_write]
-    -- Read/write a value :: the PrimRep
-    -- at byte address 
-    --    sizeof(machine_word)*Int + base_ptr + sizeof(PrimRep)*index_value
     deriving Eq
 
 
@@ -300,11 +294,6 @@ pprMachOp MO_32U_to_NatU   = text "MO_32U_to_NatU"
 pprMachOp MO_8U_to_32U     = text "MO_8U_to_32U"
 pprMachOp MO_32U_to_8U     = text "MO_32U_to_8U"
 
-pprMachOp (MO_ReadOSBI offset rep)
-   = text "MO_ReadOSBI" <> parens (int offset <> comma <> ppr rep)
-pprMachOp (MO_WriteOSBI offset rep)
-   = text "MO_WriteOSBI" <> parens (int offset <> comma <> ppr rep)
-
 
 
 -- Non-exported helper enumeration:
@@ -338,137 +327,134 @@ isCommutableMachOp mop = comm `elem` snd (machOpProps mop)
 isComparisonMachOp :: MachOp -> Bool
 isComparisonMachOp mop = comp `elem` snd (machOpProps mop)
 
--- Find the PrimReps for the returned value(s) of the MachOp.
-resultRepsOfMachOp :: MachOp -> Maybe PrimRep
-resultRepsOfMachOp mop = fst (machOpProps mop)
+-- Find the PrimRep for the returned value of the MachOp.
+resultRepOfMachOp :: MachOp -> PrimRep
+resultRepOfMachOp mop = fst (machOpProps mop)
 
 -- This bit does the real work.
-machOpProps :: MachOp -> (Maybe PrimRep, [MO_Prop])
-
-machOpProps MO_Nat_Add       = (Just IntRep, [inline, comm])
-machOpProps MO_Nat_Sub       = (Just IntRep, [inline])
-machOpProps MO_Nat_Eq        = (Just IntRep, [inline, comp, comm])
-machOpProps MO_Nat_Ne        = (Just IntRep, [inline, comp, comm])
-
-machOpProps MO_NatS_Ge       = (Just IntRep, [inline, comp])
-machOpProps MO_NatS_Le       = (Just IntRep, [inline, comp])
-machOpProps MO_NatS_Gt       = (Just IntRep, [inline, comp])
-machOpProps MO_NatS_Lt       = (Just IntRep, [inline, comp])
-
-machOpProps MO_NatU_Ge       = (Just IntRep, [inline, comp])
-machOpProps MO_NatU_Le       = (Just IntRep, [inline, comp])
-machOpProps MO_NatU_Gt       = (Just IntRep, [inline, comp])
-machOpProps MO_NatU_Lt       = (Just IntRep, [inline, comp])
-
-machOpProps MO_NatS_Mul      = (Just IntRep, [inline, comm])
-machOpProps MO_NatS_MulMayOflo = (Just IntRep, [inline, comm])
-machOpProps MO_NatS_Quot     = (Just IntRep, [inline])
-machOpProps MO_NatS_Rem      = (Just IntRep, [inline])
-machOpProps MO_NatS_Neg      = (Just IntRep, [inline])
-
-machOpProps MO_NatU_Mul      = (Just WordRep, [inline, comm])
-machOpProps MO_NatU_Quot     = (Just WordRep, [inline])
-machOpProps MO_NatU_Rem      = (Just WordRep, [inline])
-
-machOpProps MO_Nat_And       = (Just IntRep, [inline, comm])
-machOpProps MO_Nat_Or        = (Just IntRep, [inline, comm])
-machOpProps MO_Nat_Xor       = (Just IntRep, [inline, comm])
-machOpProps MO_Nat_Not       = (Just IntRep, [inline])
-machOpProps MO_Nat_Shl       = (Just IntRep, [inline])
-machOpProps MO_Nat_Shr       = (Just IntRep, [inline])
-machOpProps MO_Nat_Sar       = (Just IntRep, [inline])
-
-machOpProps MO_32U_Eq        = (Just IntRep, [inline, comp, comm])
-machOpProps MO_32U_Ne        = (Just IntRep, [inline, comp, comm])
-machOpProps MO_32U_Ge        = (Just IntRep, [inline, comp])
-machOpProps MO_32U_Le        = (Just IntRep, [inline, comp])
-machOpProps MO_32U_Gt        = (Just IntRep, [inline, comp])
-machOpProps MO_32U_Lt        = (Just IntRep, [inline, comp])
-
-machOpProps MO_Dbl_Eq        = (Just IntRep, [inline, comp, comm])
-machOpProps MO_Dbl_Ne        = (Just IntRep, [inline, comp, comm])
-machOpProps MO_Dbl_Ge        = (Just IntRep, [inline, comp])
-machOpProps MO_Dbl_Le        = (Just IntRep, [inline, comp])
-machOpProps MO_Dbl_Gt        = (Just IntRep, [inline, comp])
-machOpProps MO_Dbl_Lt        = (Just IntRep, [inline, comp])
-
-machOpProps MO_Dbl_Add       = (Just DoubleRep, [inline, comm])
-machOpProps MO_Dbl_Sub       = (Just DoubleRep, [inline])
-machOpProps MO_Dbl_Mul       = (Just DoubleRep, [inline, comm])
-machOpProps MO_Dbl_Div       = (Just DoubleRep, [inline])
-machOpProps MO_Dbl_Pwr       = (Just DoubleRep, [])
-
-machOpProps MO_Dbl_Sin       = (Just DoubleRep, [])
-machOpProps MO_Dbl_Cos       = (Just DoubleRep, [])
-machOpProps MO_Dbl_Tan       = (Just DoubleRep, [])
-machOpProps MO_Dbl_Sinh      = (Just DoubleRep, [])
-machOpProps MO_Dbl_Cosh      = (Just DoubleRep, [])
-machOpProps MO_Dbl_Tanh      = (Just DoubleRep, [])
-machOpProps MO_Dbl_Asin      = (Just DoubleRep, [])
-machOpProps MO_Dbl_Acos      = (Just DoubleRep, [])
-machOpProps MO_Dbl_Atan      = (Just DoubleRep, [])
-machOpProps MO_Dbl_Log       = (Just DoubleRep, [])
-machOpProps MO_Dbl_Exp       = (Just DoubleRep, [])
-machOpProps MO_Dbl_Sqrt      = (Just DoubleRep, [])
-machOpProps MO_Dbl_Neg       = (Just DoubleRep, [inline])
-
-machOpProps MO_Flt_Add       = (Just FloatRep, [inline, comm])
-machOpProps MO_Flt_Sub       = (Just FloatRep, [inline])
-machOpProps MO_Flt_Mul       = (Just FloatRep, [inline, comm])
-machOpProps MO_Flt_Div       = (Just FloatRep, [inline])
-machOpProps MO_Flt_Pwr       = (Just FloatRep, [])
-
-machOpProps MO_Flt_Eq        = (Just IntRep, [inline, comp, comm])
-machOpProps MO_Flt_Ne        = (Just IntRep, [inline, comp, comm])
-machOpProps MO_Flt_Ge        = (Just IntRep, [inline, comp])
-machOpProps MO_Flt_Le        = (Just IntRep, [inline, comp])
-machOpProps MO_Flt_Gt        = (Just IntRep, [inline, comp])
-machOpProps MO_Flt_Lt        = (Just IntRep, [inline, comp])
-
-machOpProps MO_Flt_Sin       = (Just FloatRep, [])
-machOpProps MO_Flt_Cos       = (Just FloatRep, [])
-machOpProps MO_Flt_Tan       = (Just FloatRep, [])
-machOpProps MO_Flt_Sinh      = (Just FloatRep, [])
-machOpProps MO_Flt_Cosh      = (Just FloatRep, [])
-machOpProps MO_Flt_Tanh      = (Just FloatRep, [])
-machOpProps MO_Flt_Asin      = (Just FloatRep, [])
-machOpProps MO_Flt_Acos      = (Just FloatRep, [])
-machOpProps MO_Flt_Atan      = (Just FloatRep, [])
-machOpProps MO_Flt_Log       = (Just FloatRep, [])
-machOpProps MO_Flt_Exp       = (Just FloatRep, [])
-machOpProps MO_Flt_Sqrt      = (Just FloatRep, [])
-machOpProps MO_Flt_Neg       = (Just FloatRep, [inline])
-
-machOpProps MO_32U_to_NatS   = (Just IntRep, [inline])
-machOpProps MO_NatS_to_32U   = (Just Word32Rep, [inline])
-
-machOpProps MO_NatS_to_Dbl   = (Just DoubleRep, [inline])
-machOpProps MO_Dbl_to_NatS   = (Just IntRep, [inline])
-
-machOpProps MO_NatS_to_Flt   = (Just FloatRep, [inline])
-machOpProps MO_Flt_to_NatS   = (Just IntRep, [inline])
-
-machOpProps MO_NatS_to_NatU  = (Just WordRep, [inline])
-machOpProps MO_NatU_to_NatS  = (Just IntRep, [inline])
-
-machOpProps MO_NatS_to_NatP  = (Just PtrRep, [inline])
-machOpProps MO_NatP_to_NatS  = (Just IntRep, [inline])
-machOpProps MO_NatU_to_NatP  = (Just PtrRep, [inline])
-machOpProps MO_NatP_to_NatU  = (Just WordRep, [inline])
-
-machOpProps MO_Dbl_to_Flt    = (Just FloatRep, [inline])
-machOpProps MO_Flt_to_Dbl    = (Just DoubleRep, [inline])
-
-machOpProps MO_8S_to_NatS    = (Just IntRep, [inline])
-machOpProps MO_16S_to_NatS   = (Just IntRep, [inline])
-machOpProps MO_32S_to_NatS   = (Just IntRep, [inline])
-
-machOpProps MO_8U_to_NatU    = (Just WordRep, [inline])
-machOpProps MO_16U_to_NatU   = (Just WordRep, [inline])
-machOpProps MO_32U_to_NatU   = (Just WordRep, [inline])
-
-machOpProps MO_8U_to_32U     = (Just Word32Rep, [inline])
-machOpProps MO_32U_to_8U     = (Just Word8Rep, [inline])
-
-machOpProps (MO_ReadOSBI offset rep)  = (Just rep, [inline])
-machOpProps (MO_WriteOSBI offset rep) = (Nothing, [inline])
+machOpProps :: MachOp -> (PrimRep, [MO_Prop])
+
+machOpProps MO_Nat_Add       = (IntRep, [inline, comm])
+machOpProps MO_Nat_Sub       = (IntRep, [inline])
+machOpProps MO_Nat_Eq        = (IntRep, [inline, comp, comm])
+machOpProps MO_Nat_Ne        = (IntRep, [inline, comp, comm])
+
+machOpProps MO_NatS_Ge       = (IntRep, [inline, comp])
+machOpProps MO_NatS_Le       = (IntRep, [inline, comp])
+machOpProps MO_NatS_Gt       = (IntRep, [inline, comp])
+machOpProps MO_NatS_Lt       = (IntRep, [inline, comp])
+
+machOpProps MO_NatU_Ge       = (IntRep, [inline, comp])
+machOpProps MO_NatU_Le       = (IntRep, [inline, comp])
+machOpProps MO_NatU_Gt       = (IntRep, [inline, comp])
+machOpProps MO_NatU_Lt       = (IntRep, [inline, comp])
+
+machOpProps MO_NatS_Mul      = (IntRep, [inline, comm])
+machOpProps MO_NatS_MulMayOflo = (IntRep, [inline, comm])
+machOpProps MO_NatS_Quot     = (IntRep, [inline])
+machOpProps MO_NatS_Rem      = (IntRep, [inline])
+machOpProps MO_NatS_Neg      = (IntRep, [inline])
+
+machOpProps MO_NatU_Mul      = (WordRep, [inline, comm])
+machOpProps MO_NatU_Quot     = (WordRep, [inline])
+machOpProps MO_NatU_Rem      = (WordRep, [inline])
+
+machOpProps MO_Nat_And       = (IntRep, [inline, comm])
+machOpProps MO_Nat_Or        = (IntRep, [inline, comm])
+machOpProps MO_Nat_Xor       = (IntRep, [inline, comm])
+machOpProps MO_Nat_Not       = (IntRep, [inline])
+machOpProps MO_Nat_Shl       = (IntRep, [inline])
+machOpProps MO_Nat_Shr       = (IntRep, [inline])
+machOpProps MO_Nat_Sar       = (IntRep, [inline])
+
+machOpProps MO_32U_Eq        = (IntRep, [inline, comp, comm])
+machOpProps MO_32U_Ne        = (IntRep, [inline, comp, comm])
+machOpProps MO_32U_Ge        = (IntRep, [inline, comp])
+machOpProps MO_32U_Le        = (IntRep, [inline, comp])
+machOpProps MO_32U_Gt        = (IntRep, [inline, comp])
+machOpProps MO_32U_Lt        = (IntRep, [inline, comp])
+
+machOpProps MO_Dbl_Eq        = (IntRep, [inline, comp, comm])
+machOpProps MO_Dbl_Ne        = (IntRep, [inline, comp, comm])
+machOpProps MO_Dbl_Ge        = (IntRep, [inline, comp])
+machOpProps MO_Dbl_Le        = (IntRep, [inline, comp])
+machOpProps MO_Dbl_Gt        = (IntRep, [inline, comp])
+machOpProps MO_Dbl_Lt        = (IntRep, [inline, comp])
+
+machOpProps MO_Dbl_Add       = (DoubleRep, [inline, comm])
+machOpProps MO_Dbl_Sub       = (DoubleRep, [inline])
+machOpProps MO_Dbl_Mul       = (DoubleRep, [inline, comm])
+machOpProps MO_Dbl_Div       = (DoubleRep, [inline])
+machOpProps MO_Dbl_Pwr       = (DoubleRep, [])
+
+machOpProps MO_Dbl_Sin       = (DoubleRep, [])
+machOpProps MO_Dbl_Cos       = (DoubleRep, [])
+machOpProps MO_Dbl_Tan       = (DoubleRep, [])
+machOpProps MO_Dbl_Sinh      = (DoubleRep, [])
+machOpProps MO_Dbl_Cosh      = (DoubleRep, [])
+machOpProps MO_Dbl_Tanh      = (DoubleRep, [])
+machOpProps MO_Dbl_Asin      = (DoubleRep, [])
+machOpProps MO_Dbl_Acos      = (DoubleRep, [])
+machOpProps MO_Dbl_Atan      = (DoubleRep, [])
+machOpProps MO_Dbl_Log       = (DoubleRep, [])
+machOpProps MO_Dbl_Exp       = (DoubleRep, [])
+machOpProps MO_Dbl_Sqrt      = (DoubleRep, [])
+machOpProps MO_Dbl_Neg       = (DoubleRep, [inline])
+
+machOpProps MO_Flt_Add       = (FloatRep, [inline, comm])
+machOpProps MO_Flt_Sub       = (FloatRep, [inline])
+machOpProps MO_Flt_Mul       = (FloatRep, [inline, comm])
+machOpProps MO_Flt_Div       = (FloatRep, [inline])
+machOpProps MO_Flt_Pwr       = (FloatRep, [])
+
+machOpProps MO_Flt_Eq        = (IntRep, [inline, comp, comm])
+machOpProps MO_Flt_Ne        = (IntRep, [inline, comp, comm])
+machOpProps MO_Flt_Ge        = (IntRep, [inline, comp])
+machOpProps MO_Flt_Le        = (IntRep, [inline, comp])
+machOpProps MO_Flt_Gt        = (IntRep, [inline, comp])
+machOpProps MO_Flt_Lt        = (IntRep, [inline, comp])
+
+machOpProps MO_Flt_Sin       = (FloatRep, [])
+machOpProps MO_Flt_Cos       = (FloatRep, [])
+machOpProps MO_Flt_Tan       = (FloatRep, [])
+machOpProps MO_Flt_Sinh      = (FloatRep, [])
+machOpProps MO_Flt_Cosh      = (FloatRep, [])
+machOpProps MO_Flt_Tanh      = (FloatRep, [])
+machOpProps MO_Flt_Asin      = (FloatRep, [])
+machOpProps MO_Flt_Acos      = (FloatRep, [])
+machOpProps MO_Flt_Atan      = (FloatRep, [])
+machOpProps MO_Flt_Log       = (FloatRep, [])
+machOpProps MO_Flt_Exp       = (FloatRep, [])
+machOpProps MO_Flt_Sqrt      = (FloatRep, [])
+machOpProps MO_Flt_Neg       = (FloatRep, [inline])
+
+machOpProps MO_32U_to_NatS   = (IntRep, [inline])
+machOpProps MO_NatS_to_32U   = (Word32Rep, [inline])
+
+machOpProps MO_NatS_to_Dbl   = (DoubleRep, [inline])
+machOpProps MO_Dbl_to_NatS   = (IntRep, [inline])
+
+machOpProps MO_NatS_to_Flt   = (FloatRep, [inline])
+machOpProps MO_Flt_to_NatS   = (IntRep, [inline])
+
+machOpProps MO_NatS_to_NatU  = (WordRep, [inline])
+machOpProps MO_NatU_to_NatS  = (IntRep, [inline])
+
+machOpProps MO_NatS_to_NatP  = (PtrRep, [inline])
+machOpProps MO_NatP_to_NatS  = (IntRep, [inline])
+machOpProps MO_NatU_to_NatP  = (PtrRep, [inline])
+machOpProps MO_NatP_to_NatU  = (WordRep, [inline])
+
+machOpProps MO_Dbl_to_Flt    = (FloatRep, [inline])
+machOpProps MO_Flt_to_Dbl    = (DoubleRep, [inline])
+
+machOpProps MO_8S_to_NatS    = (IntRep, [inline])
+machOpProps MO_16S_to_NatS   = (IntRep, [inline])
+machOpProps MO_32S_to_NatS   = (IntRep, [inline])
+
+machOpProps MO_8U_to_NatU    = (WordRep, [inline])
+machOpProps MO_16U_to_NatU   = (WordRep, [inline])
+machOpProps MO_32U_to_NatU   = (WordRep, [inline])
+
+machOpProps MO_8U_to_32U     = (Word32Rep, [inline])
+machOpProps MO_32U_to_8U     = (Word8Rep, [inline])
index ce22e15..64f8048 100644 (file)
@@ -253,32 +253,7 @@ pprAbsC stmt@(COpStmt results (StgPrimOp op) args vol_regs) _
 
 -- NEW CASES FOR EXPANDED PRIMOPS
 
--- We have to deal with some of these specially
-pprAbsC (CMachOpStmt (Just res) (MO_ReadOSBI offw scaleRep)
-                     [baseAmode, indexAmode] maybe_vols) 
-        _
-  | isNothing maybe_vols
-  = hcat [ -- text " /* ReadOSBI */ ",
-           ppr_amode res, equals, 
-           ppr_array_expression offw scaleRep baseAmode indexAmode, 
-           semi ]
-  | otherwise
-  = panic "pprAbsC:MO_ReadOSBI -- out-of-line array indexing ?!?!"
-
-pprAbsC (CMachOpStmt Nothing (MO_WriteOSBI offw scaleRep)
-                     [baseAmode, indexAmode, vAmode] maybe_vols)
-        _
-  | isNothing maybe_vols
-  = hcat [ -- text " /* WriteOSBI */ ",
-           ppr_array_expression offw scaleRep baseAmode indexAmode, 
-           equals, pprAmode vAmode,
-           semi ]
-  | otherwise
-  = panic "pprAbsC:MO_WriteOSBI -- out-of-line array indexing ?!?!"
-
--- The rest generically.
-
-pprAbsC stmt@(CMachOpStmt (Just res) mop [arg1,arg2] maybe_vols) _
+pprAbsC stmt@(CMachOpStmt res mop [arg1,arg2] maybe_vols) _
   = let prefix_fn = mop `elem` [MO_Dbl_Pwr, MO_Flt_Pwr, MO_NatS_MulMayOflo]
     in
     case ppr_maybe_vol_regs maybe_vols of {(saves,restores) ->
@@ -293,7 +268,7 @@ pprAbsC stmt@(CMachOpStmt (Just res) mop [arg1,arg2] maybe_vols) _
     $$ restores
     }
 
-pprAbsC stmt@(CMachOpStmt (Just res) mop [arg1] maybe_vols) _
+pprAbsC stmt@(CMachOpStmt res mop [arg1] maybe_vols) _
   = case ppr_maybe_vol_regs maybe_vols of {(saves,restores) ->
     saves $$
     hcat [ppr_amode res, equals, 
@@ -754,24 +729,6 @@ pprMachOp_for_C MO_32U_to_NatU   = text "(StgWord32)(StgWord)"
 pprMachOp_for_C MO_8U_to_32U     = text "(StgWord32)"
 pprMachOp_for_C MO_32U_to_8U     = text "(StgWord8)"
 
-pprMachOp_for_C (MO_ReadOSBI _ _)  = panic "pprMachOp_for_C:MO_ReadOSBI"
-pprMachOp_for_C (MO_WriteOSBI _ _) = panic "pprMachOp_for_C:MO_WriteOSBI"
-
-
--- Helper for printing array expressions.
-ppr_array_expression offw scaleRep baseAmode indexAmode
-   -- create:
-   -- * (scaleRep*) (
-   --      ((char*)baseAmode) + offw*bytes_per_word + indexAmode*bytes_per_scaleRep
-   --   )
-   = let offb  = parens (int offw <> char '*' <> text "sizeof(void*)")
-         indb  = parens (parens (pprAmode indexAmode) 
-                         <> char '*' <> int (getPrimRepArrayElemSize scaleRep))
-         baseb = text "(char*)" <> parens (pprAmode baseAmode)
-         addr  = parens baseb <+> char '+' <+> offb <+> char '+' <+> indb
-     in
-         char '*' <> parens (ppr scaleRep <> char '*') <> parens addr
-
 
 ppLocalness lbl
   = if (externallyVisibleCLabel lbl) 
@@ -1178,15 +1135,15 @@ Special treatment for floats and doubles, to avoid unwanted conversions.
 
 \begin{code}
 pprAssign FloatRep dest@(CVal reg_rel _) src
-  = hcat [ ptext SLIT("ASSIGN_FLT"),char '(', ppr_amode (CAddr reg_rel), comma, pprAmode src, pp_paren_semi ]
+  = hcat [ ptext SLIT("ASSIGN_FLT((W_*)"), parens (ppr_amode (CAddr reg_rel)), comma, pprAmode src, pp_paren_semi ]
 
 pprAssign DoubleRep dest@(CVal reg_rel _) src
-  = hcat [ ptext SLIT("ASSIGN_DBL"),char '(', ppr_amode (CAddr reg_rel), comma, pprAmode src, pp_paren_semi ]
+  = hcat [ ptext SLIT("ASSIGN_DBL((W_*)"), parens (ppr_amode (CAddr reg_rel)), comma, pprAmode src, pp_paren_semi ]
 
 pprAssign Int64Rep dest@(CVal reg_rel _) src
-  = hcat [ ptext SLIT("ASSIGN_Int64"),char '(', ppr_amode (CAddr reg_rel), comma, pprAmode src, pp_paren_semi ]
+  = hcat [ ptext SLIT("ASSIGN_Int64((W_*)"), parens (ppr_amode (CAddr reg_rel)), comma, pprAmode src, pp_paren_semi ]
 pprAssign Word64Rep dest@(CVal reg_rel _) src
-  = hcat [ ptext SLIT("ASSIGN_Word64"),char '(', ppr_amode (CAddr reg_rel), comma, pprAmode src, pp_paren_semi ]
+  = hcat [ ptext SLIT("ASSIGN_Word64((W_*)"), parens (ppr_amode (CAddr reg_rel)), comma, pprAmode src, pp_paren_semi ]
 \end{code}
 
 Lastly, the question is: will the C compiler think the types of the
@@ -1255,13 +1212,13 @@ question.)
 
 \begin{code}
 pprAmode (CVal reg_rel FloatRep)
-  = hcat [ text "PK_FLT(", ppr_amode (CAddr reg_rel), rparen ]
+  = hcat [ text "PK_FLT((W_*)", parens (ppr_amode (CAddr reg_rel)), rparen ]
 pprAmode (CVal reg_rel DoubleRep)
-  = hcat [ text "PK_DBL(", ppr_amode (CAddr reg_rel), rparen ]
+  = hcat [ text "PK_DBL((W_*)", parens (ppr_amode (CAddr reg_rel)), rparen ]
 pprAmode (CVal reg_rel Int64Rep)
-  = hcat [ text "PK_Int64(", ppr_amode (CAddr reg_rel), rparen ]
+  = hcat [ text "PK_Int64((W_*)", parens (ppr_amode (CAddr reg_rel)), rparen ]
 pprAmode (CVal reg_rel Word64Rep)
-  = hcat [ text "PK_Word64(", ppr_amode (CAddr reg_rel), rparen ]
+  = hcat [ text "PK_Word64((W_*)", parens (ppr_amode (CAddr reg_rel)), rparen ]
 \end{code}
 
 Next comes the case where there is some other cast need, and the
@@ -1294,10 +1251,6 @@ amode has kind2.
 ppr_amode CBytesPerWord
   = text "(sizeof(void*))"
 
-ppr_amode (CMem rep addr)
-  = let txt_rep = pprPrimKind rep
-    in  hcat [ char '*', parens (txt_rep <> char '*'), parens (ppr_amode addr) ]
-
 ppr_amode (CVal reg_rel@(CIndex _ _ _) kind)
   = case (pprRegRelative False{-no sign wanted-} reg_rel) of
        (pp_reg, Nothing)     -> panic "ppr_amode: CIndex"
@@ -1701,7 +1654,7 @@ ppr_decls_AbsC (CInitHdr cl_info reg_rel cost_centre _)
   where
     info_lbl = infoTableLabelFromCI cl_info
 
-ppr_decls_AbsC (CMachOpStmt res        _ args _) = ppr_decls_Amodes (maybeToList res ++ args)
+ppr_decls_AbsC (CMachOpStmt res        _ args _) = ppr_decls_Amodes (res : args)
 ppr_decls_AbsC (COpStmt        results _ args _) = ppr_decls_Amodes (results ++ args)
 
 ppr_decls_AbsC (CSimultaneous abc)       = ppr_decls_AbsC abc
index 888d129..b3ac35b 100644 (file)
@@ -31,7 +31,7 @@ import ClosureInfo    ( infoTableLabelFromCI, entryLabelFromCI,
 import Literal         ( Literal(..), word2IntLit )
 import Maybes          ( maybeToBool )
 import StgSyn          ( StgOp(..) )
-import MachOp          ( MachOp(..), resultRepsOfMachOp )
+import MachOp          ( MachOp(..), resultRepOfMachOp )
 import PrimRep         ( isFloatingRep, is64BitRep, 
                          PrimRep(..), getPrimRepArrayElemSize )
 import StixInfo                ( genCodeInfoTable, genBitmapInfoTable,
@@ -392,39 +392,10 @@ Now the PrimOps, some of which may need caller-saves register wrappers.
  gencode (COpStmt results (StgPrimOp op) args vols)
   = panic "AbsCStixGen.gencode: un-translated PrimOp"
 
- -- Translate out array indexing primops right here, so that
- -- individual targets don't have to deal with them
-
- gencode (CMachOpStmt (Just r1) (MO_ReadOSBI off_w rep) [base,index] vols) 
-  = returnUs (\xs ->
-       mkStAssign 
-          rep 
-          (a2stix r1) 
-          (StInd rep (StMachOp MO_Nat_Add 
-                               [StIndex rep (a2stix base) (a2stix index), 
-                                StInt (toInteger (off_w * wORD_SIZE))]))
-       : xs
-    )
-
- -- Ordinary MachOps are passed through unchanged.
- gencode (CMachOpStmt Nothing (MO_WriteOSBI off_w rep) [base,index,val] vols) 
-  = returnUs (\xs ->
-       StAssignMem 
-          rep 
-          (StMachOp MO_Nat_Add 
-                    [StIndex rep (a2stix base) (a2stix index), 
-                     StInt (toInteger (off_w * wORD_SIZE))])
-          (a2stix val)
-       : xs
-    )
-
- gencode (CMachOpStmt (Just r1) mop args vols)
-  = case resultRepsOfMachOp mop of
-       Just rep 
-          -> returnUs (\xs ->
-                mkStAssign rep (a2stix r1) 
-                               (StMachOp mop (map a2stix args))
-                : xs
+ gencode (CMachOpStmt res mop args vols)
+  = returnUs (\xs -> mkStAssign (resultRepOfMachOp mop) (a2stix res) 
+                                (StMachOp mop (map a2stix args))
+                     : xs
              )
 \end{code}
 
index 199087d..95c54f1 100644 (file)
@@ -41,7 +41,7 @@ import AbsCUtils      ( magicIdPrimRep )
 import ForeignCall     ( CCallConv )
 import CLabel          ( mkAsmTempLabel, CLabel, pprCLabel )
 import PrimRep          ( PrimRep(..) )
-import MachOp          ( MachOp(..), pprMachOp, resultRepsOfMachOp )
+import MachOp          ( MachOp(..), pprMachOp, resultRepOfMachOp )
 import Unique           ( Unique )
 import SMRep           ( fixedHdrSize, arrWordsHdrSize, arrPtrsHdrSize )
 import UniqSupply      ( UniqSupply, splitUniqSupply, uniqFromSupply,
@@ -165,10 +165,7 @@ repOfStixExpr (StReg reg)     = repOfStixReg reg
 repOfStixExpr (StIndex _ _ _) = PtrRep
 repOfStixExpr (StInd rep _)   = rep
 repOfStixExpr (StCall target conv retrep args) = retrep
-repOfStixExpr (StMachOp mop args) 
-   = case resultRepsOfMachOp mop of
-        Just rep -> rep
-        Nothing  -> pprPanic "repOfStixExpr:StMachOp" (pprMachOp mop)
+repOfStixExpr (StMachOp mop args) = resultRepOfMachOp mop
 
 
 -- used by insnFuture in RegAllocInfo.lhs
index 6d6db58..5bac1b5 100644 (file)
@@ -147,8 +147,6 @@ amodeToStix (CVal rr pk) = StInd pk (amodeToStix (CAddr rr))
 amodeToStix CBytesPerWord
   = StInt (toInteger wORD_SIZE)
 
-amodeToStix (CMem pk addr) = StInd pk (amodeToStix addr)
-
 amodeToStix (CAddr (SpRel off))
   = StIndex PtrRep (StReg stgSp) (StInt (toInteger (iBox off)))