From 042cded121eadc62bfb4d925ce655ed010fcba69 Mon Sep 17 00:00:00 2001 From: sof <unknown> Date: Thu, 30 Apr 1998 19:24:21 +0000 Subject: [PATCH] [project @ 1998-04-30 19:24:21 by sof] NCG support sizeof(Mutable)ByteArray# primops --- ghc/compiler/nativeGen/StixPrim.lhs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ghc/compiler/nativeGen/StixPrim.lhs b/ghc/compiler/nativeGen/StixPrim.lhs index 6b992e3fe734..2b28c64a5e5b 100644 --- a/ghc/compiler/nativeGen/StixPrim.lhs +++ b/ghc/compiler/nativeGen/StixPrim.lhs @@ -212,6 +212,30 @@ primCode [lhs] UnsafeFreezeByteArrayOp [rhs] = simpleCoercion PtrRep lhs rhs \end{code} +Returning the size of (mutable) byte arrays is just +an indexing operation. + +\begin{code} +primCode [lhs] SizeofByteArrayOp [rhs] + = let + lhs' = amodeToStix lhs + rhs' = amodeToStix rhs + sz = StIndex IntRep rhs' fixedHS + assign = StAssign IntRep lhs' (StInd IntRep sz) + in + returnUs (\xs -> assign : xs) + +primCode [lhs] SizeofMutableByteArrayOp [rhs] + = let + lhs' = amodeToStix lhs + rhs' = amodeToStix rhs + sz = StIndex IntRep rhs' fixedHS + assign = StAssign IntRep lhs' (StInd IntRep sz) + in + returnUs (\xs -> assign : xs) + +\end{code} + Most other array primitives translate to simple indexing. \begin{code} -- GitLab