diff --git a/document/core/valid/instructions.rst b/document/core/valid/instructions.rst index a822dd149..a8a5ec691 100644 --- a/document/core/valid/instructions.rst +++ b/document/core/valid/instructions.rst @@ -598,6 +598,131 @@ Aggregate Reference Instructions } +.. _valid-array.fill: + +:math:`\ARRAYFILL~x` +.................... + +* The :ref:`defined type ` :math:`C.\CTYPES[x]` must exist. + +* The :ref:`expansion ` of :math:`C.\CTYPES[x]` must be an :ref:`array type ` :math:`\TARRAY~\fieldtype`. + +* Let the :ref:`field type ` :math:`\mut~\storagetype` be :math:`\fieldtype`. + +* The prefix :math:`\mut` must be :math:`\MVAR`. + +* Let :math:`t` be the :ref:`value type ` :math:`\unpacktype(\storagetype)`. + +* Then the instruction is valid with type :math:`[(\REF~\NULL~x)~\I32~t~\I32] \to []`. + +.. math:: + \frac{ + \expanddt(C.\CTYPES[x]) = \TARRAY~(\MVAR~\X{st}) + }{ + C \vdashinstr \ARRAYFILL~x : [(\REF~\NULL~x)~\I32~\unpacktype(\X{st})~\I32] \to [] + } + + +.. _valid-array.copy: + +:math:`\ARRAYCOPY~x~y` +...................... + +* The :ref:`defined type ` :math:`C.\CTYPES[x]` must exist. + +* The :ref:`expansion ` of :math:`C.\CTYPES[x]` must be an :ref:`array type ` :math:`\TARRAY~\fieldtype_1`. + +* Let the :ref:`field type ` :math:`\mut_1~\storagetype_1` be :math:`\fieldtype_1`. + +* The prefix :math:`\mut_1` must be :math:`\MVAR`. + +* The :ref:`defined type ` :math:`C.\CTYPES[y]` must exist. + +* The :ref:`expansion ` of :math:`C.\CTYPES[y]` must be an :ref:`array type ` :math:`\TARRAY~\fieldtype_2`. + +* Let the :ref:`field type ` :math:`\mut_2~\storagetype_2` be :math:`\fieldtype_2`. + +* The :ref:`storage type ` :math:`\storagetype_2` must :ref:`match ` :math:`\storagetype_1`. + +* Then the instruction is valid with type :math:`[(\REF~\NULL~x)~\I32~(\REF~\NULL~y)~\I32~\I32] \to []`. + +.. math:: + \frac{ + \expanddt(C.\CTYPES[x]) = \TARRAY~(\MVAR~\X{st_1}) + \qquad + \expanddt(C.\CTYPES[y]) = \TARRAY~(\mut~\X{st_2}) + \qquad + C \vdashstoragetypematch \X{st_2} \matchesstoragetype \X{st_1} + }{ + C \vdashinstr \ARRAYCOPY~x~y : [(\REF~\NULL~x)~\I32~(\REF~\NULL~y)~\I32~\I32] \to [] + } + + +.. _valid-array.init_data: + +:math:`\ARRAYINITDATA~x~y` +.......................... + +* The :ref:`defined type ` :math:`C.\CTYPES[x]` must exist. + +* The :ref:`expansion ` of :math:`C.\CTYPES[x]` must be an :ref:`array type ` :math:`\TARRAY~\fieldtype`. + +* Let the :ref:`field type ` :math:`\mut~\storagetype` be :math:`\fieldtype`. + +* The prefix :math:`\mut` must be :math:`\MVAR`. + +* Let :math:`t` be the :ref:`value type ` :math:`\unpacktype(\storagetype)`. + +* The :ref:`value type ` :math:`t` must be a :ref:`numeric type ` or a :ref:`vector type `. + +* The :ref:`data segment ` :math:`C.\CDATAS[y]` must exist. + +* Then the instruction is valid with type :math:`[(\REF~\NULL~x)~\I32~\I32~\I32] \to []`. + +.. math:: + \frac{ + \expanddt(C.\CTYPES[x]) = \TARRAY~(\MVAR~\X{st}) + \qquad + \unpacktype(\X{st}) = \numtype \lor \unpacktype(\X{st}) = \vectype + \qquad + C.\CDATAS[y] = {\ok} + }{ + C \vdashinstr \ARRAYINITDATA~x~y : [(\REF~\NULL~x)~\I32~\I32~\I32] \to [] + } + + +.. _valid-array.init_elem: + +:math:`\ARRAYINITELEM~x~y` +.......................... + +* The :ref:`defined type ` :math:`C.\CTYPES[x]` must exist. + +* The :ref:`expansion ` of :math:`C.\CTYPES[x]` must be an :ref:`array type ` :math:`\TARRAY~\fieldtype`. + +* Let the :ref:`field type ` :math:`\mut~\storagetype` be :math:`\fieldtype`. + +* The prefix :math:`\mut` must be :math:`\MVAR`. + +* The :ref:`storage type ` :math:`\storagetype` must be a :ref:`reference type ` :math:`\X{rt}`. + +* The :ref:`element segment ` :math:`C.\CELEMS[y]` must exist. + +* Let :math:`\X{rt}'` be the :ref:`reference type ` :math:`C.\CELEMS[y]`. + +* The :ref:`reference type ` :math:`\X{rt}'` must :ref:`match ` :math:`\X{rt}`. + +* Then the instruction is valid with type :math:`[(\REF~\NULL~x)~\I32~\I32~\I32] \to []`. + +.. math:: + \frac{ + \expanddt(C.\CTYPES[x]) = \TARRAY~(\MVAR~\X{rt}) + \qquad + C \vdashreftypematch C.\CELEMS[y] \matchesreftype \X{rt} + }{ + C \vdashinstr \ARRAYINITELEM~x~y : [(\REF~\NULL~x)~\I32~\I32~\I32] \to [] + } + .. index:: scalar reference