diff options
author | Ian Lynagh <igloo@earth.li> | 2012-05-28 10:55:28 +0100 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2012-05-28 10:55:28 +0100 |
commit | 8c705e997879068b51b15761fe80c1d7f27766b0 (patch) | |
tree | ade07a289c2d20fa4c5cf514140d5b191b8640a3 /compiler/codeGen/StgCmmPrim.hs | |
parent | e5191c953bb24a20321e8422317e017f39a10857 (diff) | |
download | haskell-8c705e997879068b51b15761fe80c1d7f27766b0.tar.gz |
Add a setByteArray# primop
Essentially, this is a wrapper around memset
Diffstat (limited to 'compiler/codeGen/StgCmmPrim.hs')
-rw-r--r-- | compiler/codeGen/StgCmmPrim.hs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs index 6518c5b5b0..331d4f529e 100644 --- a/compiler/codeGen/StgCmmPrim.hs +++ b/compiler/codeGen/StgCmmPrim.hs @@ -478,11 +478,13 @@ emitPrimOp res WriteByteArrayOp_Word16 args = doWriteByteArrayOp (Just mo_Wor emitPrimOp res WriteByteArrayOp_Word32 args = doWriteByteArrayOp (Just mo_WordTo32) res args emitPrimOp res WriteByteArrayOp_Word64 args = doWriteByteArrayOp Nothing res args --- Copying byte arrays +-- Copying and setting byte arrays emitPrimOp [] CopyByteArrayOp [src,src_off,dst,dst_off,n] = doCopyByteArrayOp src src_off dst dst_off n emitPrimOp [] CopyMutableByteArrayOp [src,src_off,dst,dst_off,n] = doCopyMutableByteArrayOp src src_off dst dst_off n +emitPrimOp [] SetByteArrayOp [ba,off,len,c] = + doSetByteArrayOp ba off len c -- Population count emitPrimOp [res] PopCnt8Op [w] = emitPopCntCall res w W8 @@ -814,6 +816,18 @@ emitCopyByteArray copy src src_off dst dst_off n = do copy src dst dst_p src_p n -- ---------------------------------------------------------------------------- +-- Setting byte arrays + +-- | Takes a 'MutableByteArray#', an offset into the array, a length, +-- and a byte, and sets each of the selected bytes in the array to the +-- character. +doSetByteArrayOp :: CmmExpr -> CmmExpr -> CmmExpr -> CmmExpr + -> FCode () +doSetByteArrayOp ba off len c + = do p <- assignTempE $ cmmOffsetExpr (cmmOffsetB ba arrWordsHdrSize) off + emitMemsetCall p c len (CmmLit (mkIntCLit 1)) + +-- ---------------------------------------------------------------------------- -- Copying pointer arrays -- EZY: This code has an unusually high amount of assignTemp calls, seen |