Skip to content

Commit a4cb852

Browse files
authored
Add spec text for extend operators (WebAssembly#54)
1 parent b90c101 commit a4cb852

File tree

6 files changed

+47
-1
lines changed

6 files changed

+47
-1
lines changed

document/core/binary/instructions.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,17 @@ All other numeric instructions are plain opcodes without any immediates.
361361
\end{array}
362362
363363
364+
.. math::
365+
\begin{array}{llclll}
366+
\phantom{\production{instruction}} & \phantom{\Binstr} &\phantom{::=}& \phantom{\dots} && \phantom{thisshouldbeenough} \\[-2ex] &&|&
367+
\hex{C0} &\Rightarrow& \I32.\EXTEND\K{8\_s} \\ &&|&
368+
\hex{C1} &\Rightarrow& \I32.\EXTEND\K{16\_s} \\ &&|&
369+
\hex{C2} &\Rightarrow& \I64.\EXTEND\K{8\_s} \\ &&|&
370+
\hex{C3} &\Rightarrow& \I64.\EXTEND\K{16\_s} \\ &&|&
371+
\hex{C4} &\Rightarrow& \I64.\EXTEND\K{32\_s} \\
372+
\end{array}
373+
374+
364375
.. index:: expression
365376
pair: binary format; expression
366377
single: expression; constant

document/core/exec/numerics.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,19 @@ The integer result of predicates -- i.e., tests and relational operators -- is d
587587
\end{array}
588588
589589
590+
.. _op-iextend_s:
591+
592+
:math:`\iextends_N(i)`
593+
......................
594+
595+
* Return :math:`\extends_{M,N}(i)`.
596+
597+
.. math::
598+
\begin{array}{lll@{\qquad}l}
599+
\iextends_{N}(i) &=& \extends_{M,N}(i) \\
600+
\end{array}
601+
602+
590603
Floating-Point Operations
591604
~~~~~~~~~~~~~~~~~~~~~~~~~
592605

document/core/syntax/instrindex.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,9 @@ Instruction Opcode Type
198198
:math:`\I64.\REINTERPRET\K{/}\F64` :math:`\hex{BD}` :math:`[\F64] \to [\I64]` :ref:`validation <valid-cvtop>`
199199
:math:`\F32.\REINTERPRET\K{/}\I32` :math:`\hex{BE}` :math:`[\I32] \to [\F32]` :ref:`validation <valid-cvtop>`
200200
:math:`\F64.\REINTERPRET\K{/}\I64` :math:`\hex{BF}` :math:`[\I64] \to [\F64]` :ref:`validation <valid-cvtop>`
201+
:math:`\I32.\EXTEND\K{8\_s}` :math:`\hex{C0}` :math:`[\I32] \to [\I32]` :ref:`validation <valid-unop>`
202+
:math:`\I32.\EXTEND\K{16\_s}` :math:`\hex{C1}` :math:`[\I32] \to [\I32]` :ref:`validation <valid-unop>`
203+
:math:`\I64.\EXTEND\K{8\_s}` :math:`\hex{C2}` :math:`[\I64] \to [\I64]` :ref:`validation <valid-unop>`
204+
:math:`\I64.\EXTEND\K{16\_s}` :math:`\hex{C3}` :math:`[\I64] \to [\I64]` :ref:`validation <valid-unop>`
205+
:math:`\I64.\EXTEND\K{32\_s}` :math:`\hex{C4}` :math:`[\I64] \to [\I64]` :ref:`validation <valid-unop>`
201206
=================================== ================ ========================================== ======================================== ================

document/core/syntax/instructions.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ These operations closely match respective operations available in hardware.
6464
\K{i}\X{nn}\K{.}\itestop ~|~ \\&&&
6565
\K{i}\X{nn}\K{.}\irelop ~|~
6666
\K{f}\X{nn}\K{.}\frelop ~|~ \\&&&
67+
\K{i}\X{nn}\K{.}\EXTEND\K{8\_s} ~|~
68+
\K{i}\X{nn}\K{.}\EXTEND\K{16\_s} ~|~
69+
\K{i64.}\EXTEND\K{32\_s} ~|~ \\&&&
6770
\K{i32.}\WRAP\K{/i64} ~|~
6871
\K{i64.}\EXTEND\K{\_}\sx/\K{i32} ~|~
6972
\K{i}\X{nn}\K{.}\TRUNC\K{\_}\sx/\K{f}\X{mm} ~|~ \\&&&
@@ -151,7 +154,10 @@ Occasionally, it is convenient to group operators together according to the foll
151154

152155
.. math::
153156
\begin{array}{llll}
154-
\production{unary operator} & \unop &::=& \iunop ~|~ \funop \\
157+
\production{unary operator} & \unop &::=&
158+
\iunop ~|~
159+
\funop ~|~
160+
\EXTEND{N}\K{\_s} ~|~ \\
155161
\production{binary operator} & \binop &::=& \ibinop ~|~ \fbinop \\
156162
\production{test operator} & \testop &::=& \itestop \\
157163
\production{relational operator} & \relop &::=& \irelop ~|~ \frelop \\

document/core/text/instructions.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,16 @@ Numeric Instructions
408408
\text{f64.reinterpret/i64} &\Rightarrow& \F64.\REINTERPRET\K{/}\I64 \\
409409
\end{array}
410410
411+
.. math::
412+
\begin{array}{llclll}
413+
\phantom{\production{instruction}} & \phantom{\Tplaininstr_I} &\phantom{::=}& \phantom{thisisenough} && \phantom{thisshouldbeenough} \\[-2ex] &&|&
414+
\text{i32.extend8\_s} &\Rightarrow& \I32.\EXTEND\K{8\_s} \\ &&|&
415+
\text{i32.extend16\_s} &\Rightarrow& \I32.\EXTEND\K{16\_s} \\ &&|&
416+
\text{i64.extend8\_s} &\Rightarrow& \I64.\EXTEND\K{8\_s} \\ &&|&
417+
\text{i64.extend16\_s} &\Rightarrow& \I64.\EXTEND\K{16\_s} \\ &&|&
418+
\text{i64.extend32\_s} &\Rightarrow& \I64.\EXTEND\K{32\_s} \\
419+
\end{array}
420+
411421
412422
.. index:: ! folded instruction, S-expression
413423
.. _text-foldedinstr:

document/core/util/math.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@
710710
.. |iles| mathdef:: \xref{exec/numerics}{op-ile_s}{\F{ile\_s}}
711711
.. |igeu| mathdef:: \xref{exec/numerics}{op-ige_u}{\F{ige\_u}}
712712
.. |iges| mathdef:: \xref{exec/numerics}{op-ige_s}{\F{ige\_s}}
713+
.. |iextends| mathdef:: \xref{exec/numerics}{op-iextend_s}{\F{iextend{M}\_s}}
713714

714715
.. |fadd| mathdef:: \xref{exec/numerics}{op-fadd}{\F{fadd}}
715716
.. |fsub| mathdef:: \xref{exec/numerics}{op-fsub}{\F{fsub}}

0 commit comments

Comments
 (0)