doNewByteArrayOp :: CmmFormal -> ByteOff -> FCode ()
doNewByteArrayOp res_r n = do
    dflags <- getDynFlags

    let info_ptr = mkLblExpr mkArrWords_infoLabel
        rep = arrWordsRep dflags n

    tickyAllocPrim (mkIntExpr dflags (arrWordsHdrSize dflags))
        (mkIntExpr dflags (nonHdrSize dflags rep))
        (zeroExpr dflags)

    let hdr_size = fixedHdrSize dflags

    base <- allocHeapClosure rep info_ptr curCCS
                     [ (mkIntExpr dflags n,
                        hdr_size + oFFSET_StgArrWords_bytes dflags)
                     ]

    emit $ mkAssign (CmmLocal res_r) base

-- ----------------------------------------------------------------------------
-- Copying byte arrays

-- | Takes a source 'ByteArray#', an offset in the source array, a
-- destination 'MutableByteArray#', an offset into the destination
-- array, and the number of bytes to copy.  Copies the given number of
-- bytes from the source array to the destination array.
doNewByteArrayOp :: CmmFormal -> ByteOff -> FCode ()
doNewByteArrayOp res_r n = do
    dflags <- getDynFlags

    let info_ptr = mkLblExpr mkArrWords_infoLabel
        rep = arrWordsRep dflags n

    tickyAllocPrim (mkIntExpr dflags (arrWordsHdrSize dflags))
        (mkIntExpr dflags (nonHdrSize dflags rep))
        (zeroExpr dflags)

    let hdr_size = fixedHdrSize dflags

    base <- allocHeapClosure rep info_ptr curCCS
                     [ (mkIntExpr dflags n,
                        hdr_size + oFFSET_StgArrWords_bytes dflags)
                     ]

    emit $ mkAssign (CmmLocal res_r) base

-- ----------------------------------------------------------------------------
-- Copying byte arrays

-- | Takes a source 'ByteArray#', an offset in the source array, a
-- destination 'MutableByteArray#', an offset into the destination
-- array, and the number of bytes to copy.  Copies the given number of
-- bytes from the source array to the destination array.
doNewByteArrayOp res_r n = do
    dflags <- getDynFlags

    let info_ptr = mkLblExpr mkArrWords_infoLabel
        rep = arrWordsRep dflags n

    tickyAllocPrim (mkIntExpr dflags (arrWordsHdrSize dflags))
        (mkIntExpr dflags (nonHdrSize dflags rep))
        (zeroExpr dflags)

    let hdr_size = fixedHdrSize dflags

    base <- allocHeapClosure rep info_ptr curCCS
                     [ (mkIntExpr dflags n,
                        hdr_size + oFFSET_StgArrWords_bytes dflags)
                     ]

    emit $ mkAssign (CmmLocal res_r) base

-- ----------------------------------------------------------------------------
-- Copying byte arrays

-- | Takes a source 'ByteArray#', an offset in the source array, a
-- destination 'MutableByteArray#', an offset into the destination
-- array, and the number of bytes to copy.  Copies the given number of
-- bytes from the source array to the destination array.