[project @ 2002-01-08 10:36:24 by sewardj]
[ghc-hetmet.git] / ghc / compiler / nativeGen / StixPrim.lhs
index a94209c..c70a237 100644 (file)
@@ -17,9 +17,10 @@ import AbsCUtils     ( getAmodeRep, mixedTypeLocn )
 import SMRep           ( fixedHdrSize )
 import Literal         ( Literal(..), word2IntLit )
 import MachOp          ( MachOp(..) )
-import PrimRep         ( PrimRep(..), getPrimRepSizeInBytes )
+import PrimRep         ( PrimRep(..), getPrimRepArrayElemSize )
 import UniqSupply      ( returnUs, thenUs, getUniqueUs, UniqSM )
-import Constants       ( mIN_INTLIKE, mIN_CHARLIKE, uF_UPDATEE, bLOCK_SIZE,
+import Constants       ( wORD_SIZE,
+                         mIN_INTLIKE, mIN_CHARLIKE, uF_UPDATEE, bLOCK_SIZE,
                          rESERVED_STACK_WORDS )
 import CLabel          ( mkIntlikeClosureLabel, mkCharlikeClosureLabel,
                          mkMAP_FROZEN_infoLabel, mkEMPTY_MVAR_infoLabel,
@@ -103,6 +104,8 @@ foreignCallCode lhs (CCall (CCallSpec (StaticTarget fn) cconv safety)) rhs
               pk   = case getAmodeRep lhs of
                         FloatRep  -> FloatRep
                         DoubleRep -> DoubleRep
+                        Int64Rep  -> Int64Rep
+                        Word64Rep -> Word64Rep
                         other     -> IntRep
 
 foreignCallCode lhs call rhs
@@ -135,6 +138,9 @@ amodeToStix am@(CVal rr CharRep)
 
 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))
@@ -229,8 +235,8 @@ cHARLIKE_closure = StCLbl mkCharlikeClosureLabel
 mutArrPtrsFrozen_info = StCLbl mkMAP_FROZEN_infoLabel
 
 -- these are the sizes of charLike and intLike closures, in _bytes_.
-charLikeSize = (fixedHdrSize + 1) * (sizeOf PtrRep)
-intLikeSize  = (fixedHdrSize + 1) * (sizeOf PtrRep)
+charLikeSize = (fixedHdrSize + 1) * (getPrimRepArrayElemSize PtrRep)
+intLikeSize  = (fixedHdrSize + 1) * (getPrimRepArrayElemSize PtrRep)
 \end{code}
 
 
@@ -289,13 +295,25 @@ load_thread_state
                       ]) 
         : StAssignReg PtrRep 
              stgHpLim
-            (StMachOp MO_Nat_Add 
-                       [StInd PtrRep 
-                              (StMachOp MO_Nat_Add
-                                       [StReg stgCurrentNursery, 
-                                        StInt (toInteger (BDESCR_START * BYTES_PER_WORD))]),
-                       StInt (toInteger (bLOCK_SIZE - (1 * BYTES_PER_WORD)))
-                      ]) 
+             (StIndex Word8Rep 
+                (StInd PtrRep 
+                       (StIndex PtrRep (StReg stgCurrentNursery)
+                                       (StInt (toInteger BDESCR_START))
+                       )
+                )
+                (StMachOp MO_Nat_Sub
+                   [StMachOp MO_NatU_Mul
+                      [StInd WordRep 
+                             (StIndex PtrRep (StReg stgCurrentNursery)
+                                             (StInt (toInteger BDESCR_BLOCKS))),
+                       StInt (toInteger bLOCK_SIZE{-in bytes-})
+                      ],
+                      StInt (1 * BYTES_PER_WORD)
+                   ]
+                )
+
+             ) 
+
         : xs
      )
 \end{code}