diff options
author | buggymcbugfix <4444-buggymcbugfix@users.noreply.gitlab.haskell.org> | 2020-06-11 19:23:46 +0100 |
---|---|---|
committer | buggymcbugfix <4444-buggymcbugfix@users.noreply.gitlab.haskell.org> | 2020-06-11 19:23:46 +0100 |
commit | 5a01c26626c03986a094e07ebcdcf78f8ae927bf (patch) | |
tree | ad31f4ea142d206c49569874dcce6328deb47754 | |
parent | 410db7a5f4abbded93ff56580423c4489eca886b (diff) | |
download | haskell-wip/buggymcbugfix/array-prim.tar.gz |
WIP: arrayOf1#wip/buggymcbugfix/array-prim
-rw-r--r-- | compiler/GHC/Builtin/primops.txt.pp | 14 | ||||
-rw-r--r-- | compiler/GHC/StgToCmm/Prim.hs | 22 |
2 files changed, 36 insertions, 0 deletions
diff --git a/compiler/GHC/Builtin/primops.txt.pp b/compiler/GHC/Builtin/primops.txt.pp index c335b5873d..b24e28a8b4 100644 --- a/compiler/GHC/Builtin/primops.txt.pp +++ b/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.} diff --git a/compiler/GHC/StgToCmm/Prim.hs b/compiler/GHC/StgToCmm/Prim.hs index 214a261a57..2fa839b680 100644 --- a/compiler/GHC/StgToCmm/Prim.hs +++ b/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 |