Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Commit 98915d5

Browse files
committed
Add semantics for v128.load32_zero v128.load64_zero
1 parent b638fe3 commit 98915d5

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed

document/core/binary/instructions.rst

+2
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ SIMD loads and stores are followed by the encoding of their |memarg| immediate.
429429
\hex{FD}~~8{:}\Bu32~~m{:}\Bmemarg &\Rightarrow& \V128.\LOAD\K{16\_splat}~m \\ &&|&
430430
\hex{FD}~~9{:}\Bu32~~m{:}\Bmemarg &\Rightarrow& \V128.\LOAD\K{32\_splat}~m \\ &&|&
431431
\hex{FD}~~10{:}\Bu32~~m{:}\Bmemarg &\Rightarrow& \V128.\LOAD\K{64\_splat}~m \\ &&|&
432+
\hex{FD}~~252{:}\Bu32~~m{:}\Bmemarg &\Rightarrow& \V128.\LOAD\K{\_zero}~m \\ &&|&
433+
\hex{FD}~~253{:}\Bu32~~m{:}\Bmemarg &\Rightarrow& \V128.\LOAD\K{\_zero}~m \\ &&|&
432434
\hex{FD}~~11{:}\Bu32~~m{:}\Bmemarg &\Rightarrow& \V128.\STORE~m \\
433435
\end{array}
434436

document/core/exec/instructions.rst

+55
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,61 @@ Memory Instructions
11251125
\end{array}
11261126
11271127
1128+
.. _exec-load-zero:
1129+
1130+
:math:`\V128\K{.}\LOAD{N}\K{\_zero}~\memarg`
1131+
.............................................
1132+
1133+
1. Let :math:`F` be the :ref:`current <exec-notation-textual>` :ref:`frame <syntax-frame>`.
1134+
1135+
2. Assert: due to :ref:`validation <valid-load-extend>`, :math:`F.\AMODULE.\MIMEMS[0]` exists.
1136+
1137+
3. Let :math:`a` be the :ref:`memory address <syntax-memaddr>` :math:`F.\AMODULE.\MIMEMS[0]`.
1138+
1139+
4. Assert: due to :ref:`validation <valid-load-extend>`, :math:`S.\SMEMS[a]` exists.
1140+
1141+
5. Let :math:`\X{mem}` be the :ref:`memory instance <syntax-meminst>` :math:`S.\SMEMS[a]`.
1142+
1143+
6. Assert: due to :ref:`validation <valid-load-extend>`, a value of :ref:`value type <syntax-valtype>` |I32| is on the top of the stack.
1144+
1145+
7. Pop the value :math:`\I32.\CONST~i` from the stack.
1146+
1147+
8. Let :math:`\X{ea}` be the integer :math:`i + \memarg.\OFFSET`.
1148+
1149+
9. If :math:`\X{ea} + N/8` is larger than the length of :math:`\X{mem}.\MIDATA`, then:
1150+
1151+
a. Trap.
1152+
1153+
10. Let :math:`b^\ast` be the byte sequence :math:`\X{mem}.\MIDATA[\X{ea} \slice N/8]`.
1154+
1155+
11. Let :math:`n` be the integer for which :math:`\bytes_{\iN}(n) = b^\ast`.
1156+
1157+
12. Let :math:`c` be the result of :math:`\extendu_{N,128}(n)`.
1158+
1159+
13. Push the value :math:`\V128.\CONST~c` to the stack.
1160+
1161+
.. math::
1162+
~\\[-1ex]
1163+
\begin{array}{l}
1164+
\begin{array}{lcl@{\qquad}l}
1165+
S; F; (\I32.\CONST~i)~(\V128\K{.}\LOAD{N}\K{\_zero}~\memarg) &\stepto& S; F; (\V128.\CONST~c)
1166+
\end{array}
1167+
\\ \qquad
1168+
\begin{array}[t]{@{}r@{~}l@{}}
1169+
(\iff & \X{ea} = i + \memarg.\OFFSET \\
1170+
\wedge & \X{ea} + N/8 \leq |S.\SMEMS[F.\AMODULE.\MIMEMS[0]].\MIDATA| \\
1171+
\wedge & \bytes_{\iN}(n) = S.\SMEMS[F.\AMODULE.\MIMEMS[0]].\MIDATA[\X{ea} \slice N/8]) \\
1172+
\wedge & c = \extendu_{N,128}(n)
1173+
\end{array}
1174+
\\[1ex]
1175+
\begin{array}{lcl@{\qquad}l}
1176+
S; F; (\I32.\CONST~k)~(\V128.\LOAD{N}\K{\_zero}~\memarg) &\stepto& S; F; \TRAP
1177+
\end{array}
1178+
\\ \qquad
1179+
(\otherwise) \\
1180+
\end{array}
1181+
1182+
11281183
.. _exec-store:
11291184
.. _exec-storen:
11301185

document/core/syntax/instructions.rst

+2
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,8 @@ Instructions in this group are concerned with linear :ref:`memory <syntax-mem>`.
470470
\K{v128.}\LOAD\K{16\_splat}~\memarg \\&&|&
471471
\K{v128.}\LOAD\K{32\_splat}~\memarg ~|~
472472
\K{v128.}\LOAD\K{64\_splat}~\memarg \\&&|&
473+
\K{v128.}\LOAD\K{32\_zero}~\memarg ~|~
474+
\K{v128.}\LOAD\K{64\_zero}~\memarg \\&&|&
473475
\MEMORYSIZE \\&&|&
474476
\MEMORYGROW \\
475477
\end{array}

document/core/text/instructions.rst

+2
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,8 @@ SIMD memory instructions have optional offset and alignment immediates, like the
470470
\text{v128.load16\_splat}~~m{:}\Tmemarg_2 &\Rightarrow& \V128.\LOAD\K{16\_splat}~m \\ &&|&
471471
\text{v128.load32\_splat}~~m{:}\Tmemarg_4 &\Rightarrow& \V128.\LOAD\K{32\_splat}~m \\ &&|&
472472
\text{v128.load64\_splat}~~m{:}\Tmemarg_8 &\Rightarrow& \V128.\LOAD\K{64\_splat}~m \\ &&|&
473+
\text{v128.load32\_zero}~~m{:}\Tmemarg_4 &\Rightarrow& \V128.\LOAD\K{32\_zero}~m \\ &&|&
474+
\text{v128.load64\_zero}~~m{:}\Tmemarg_8 &\Rightarrow& \V128.\LOAD\K{64\_zero}~m \\ &&|&
473475
\text{v128.store}~~m{:}\Tmemarg_{16} &\Rightarrow& \V128.\STORE~m \\
474476
\end{array}
475477

document/core/valid/instructions.rst

+21
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,27 @@ Memory Instructions
727727
}
728728
729729
730+
.. _valid-load-zero:
731+
732+
:math:`\K{v128.}\LOAD{N}\K{\_zero}~\memarg`
733+
...............................................
734+
735+
* The memory :math:`C.\CMEMS[0]` must be defined in the context.
736+
737+
* The alignment :math:`2^{\memarg.\ALIGN}` must not be larger than :math:`N/8`.
738+
739+
* Then the instruction is valid with type :math:`[\I32] \to [\V128]`.
740+
741+
.. math::
742+
\frac{
743+
C.\CMEMS[0] = \memtype
744+
\qquad
745+
2^{\memarg.\ALIGN} \leq N/8
746+
}{
747+
C \vdashinstr \K{v128.}\LOAD{N}\K{\_zero}~\memarg : [\I32] \to [\V128]
748+
}
749+
750+
730751
.. _valid-memory.size:
731752

732753
:math:`\MEMORYSIZE`

0 commit comments

Comments
 (0)