Commit 971160ab authored by pumpkin's avatar pumpkin

Add sizeof(Mutable)Array# primitives

parent 98ad599b
......@@ -211,6 +211,11 @@ emitPrimOp [r] ReadArrayOp [obj,ix] _ = doReadPtrArrayOp r obj ix
emitPrimOp [r] IndexArrayOp [obj,ix] _ = doReadPtrArrayOp r obj ix
emitPrimOp [] WriteArrayOp [obj,ix,v] _ = doWritePtrArrayOp obj ix v
emitPrimOp [res] SizeofArrayOp [arg] _
= stmtC $ CmmAssign (CmmLocal res) (cmmLoadIndexW arg fixedHdrSize bWord)
emitPrimOp [res] SizeofMutableArrayOp [arg] live
= emitPrimOp [res] SizeofArrayOp [arg] live
-- IndexXXXoffAddr
emitPrimOp res IndexOffAddrOp_Char args _ = doIndexOffAddrOp (Just mo_u_8ToWord) b8 res args
......
......@@ -287,6 +287,11 @@ emitPrimOp [r] ReadArrayOp [obj,ix] = doReadPtrArrayOp r obj ix
emitPrimOp [r] IndexArrayOp [obj,ix] = doReadPtrArrayOp r obj ix
emitPrimOp [] WriteArrayOp [obj,ix,v] = doWritePtrArrayOp obj ix v
emitPrimOp [res] SizeofArrayOp [arg]
= emit $ mkAssign (CmmLocal res) (cmmLoadIndexW arg fixedHdrSize bWord)
emitPrimOp [res] SizeofMutableArrayOp [arg]
= emitPrimOp [res] SizeofArrayOp [arg]
-- IndexXXXoffAddr
emitPrimOp res IndexOffAddrOp_Char args = doIndexOffAddrOp (Just mo_u_8ToWord) b8 res args
......
......@@ -600,6 +600,14 @@ primop WriteArrayOp "writeArray#" GenPrimOp
with
has_side_effects = True
primop SizeofArrayOp "sizeofArray#" GenPrimOp
Array# a -> Int#
{Return the number of elements in the array.}
primop SizeofMutableArrayOp "sizeofMutableArray#" GenPrimOp
MutableArray# s a -> Int#
{Return the number of elements in the array.}
primop IndexArrayOp "indexArray#" GenPrimOp
Array# a -> Int# -> (# a #)
{Read from specified index of immutable array. Result is packaged into
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment