[Git][ghc/ghc][wip/buggymcbugfix/array-prim] WIP: arrayOf1#

Vilem-Benjamin Liepelt gitlab at gitlab.haskell.org
Fri Jun 12 07:17:27 UTC 2020



Vilem-Benjamin Liepelt pushed to branch wip/buggymcbugfix/array-prim at Glasgow Haskell Compiler / GHC


Commits:
5a01c266 by buggymcbugfix at 2020-06-11T19:23:46+01:00
WIP: arrayOf1#

- - - - -


2 changed files:

- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/StgToCmm/Prim.hs


Changes:

=====================================
compiler/GHC/Builtin/primops.txt.pp
=====================================
@@ -1076,6 +1076,13 @@ primop ArrayOf2Op "arrayOf2#" GenPrimOp
    out_of_line      = True
    has_side_effects = True
 
+primop ArrayOf1Op "arrayOf1#" GenPrimOp
+   a -> Array# a
+   {Create a new immutable array with one element.}
+   with
+   out_of_line      = True
+   has_side_effects = True
+
 primop  SameMutableArrayOp "sameMutableArray#" GenPrimOp
    MutableArray# s a -> MutableArray# s a -> Int#
 
@@ -1254,6 +1261,13 @@ primop  NewSmallArrayOp "newSmallArray#" GenPrimOp
    out_of_line = True
    has_side_effects = True
 
+primop SmallArrayOf1Op "smallArrayOf1#" GenPrimOp
+   a -> SmallArray# a
+   {Create a new immutable array with one element.}
+   with
+   out_of_line      = True
+   has_side_effects = True
+
 primop SmallArrayOf2Op "smallArrayOf2#" GenPrimOp
    a -> a -> SmallArray# a
    {Create a new immutable array with two elements.}


=====================================
compiler/GHC/StgToCmm/Prim.hs
=====================================
@@ -186,6 +186,18 @@ emitPrimOp dflags = \case
         (replicate (fromIntegral n) init)
     _ -> PrimopCmmEmit_External
 
+  ArrayOf1Op -> \elems -> opAllDone $ \[res] ->
+    let n = length elems
+      in doNewArrayOp
+          res
+          (arrPtrsRep dflags (fromIntegral n))
+          mkMAP_FROZEN_DIRTY_infoLabel
+          [ ( mkIntExpr platform n
+            , fixedHdrSize dflags + oFFSET_StgMutArrPtrs_ptrs dflags )
+          , ( mkIntExpr platform (nonHdrSizeW (arrPtrsRep dflags (fromIntegral n)))
+            , fixedHdrSize dflags + oFFSET_StgMutArrPtrs_size dflags ) ]
+          elems
+
   ArrayOf2Op -> \elems -> opAllDone $ \[res] ->
     let n = length elems
       in doNewArrayOp
@@ -253,6 +265,16 @@ emitPrimOp dflags = \case
         (replicate (fromIntegral n) init)
     _ -> PrimopCmmEmit_External
 
+  SmallArrayOf1Op -> \elems -> opAllDone $ \[res] ->
+    let n = length elems
+      in doNewArrayOp
+          res
+          (smallArrPtrsRep (fromIntegral n))
+          mkSMAP_FROZEN_DIRTY_infoLabel
+          [ ( mkIntExpr platform n
+            , fixedHdrSize dflags + oFFSET_StgSmallMutArrPtrs_ptrs dflags ) ]
+          elems
+
   SmallArrayOf2Op -> \elems -> opAllDone $ \[res] ->
     let n = length elems
       in doNewArrayOp



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a01c26626c03986a094e07ebcdcf78f8ae927bf

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a01c26626c03986a094e07ebcdcf78f8ae927bf
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200612/09aa81fb/attachment-0001.html>


More information about the ghc-commits mailing list