Skip to content

Commit

Permalink
Add spec text for extend operators (WebAssembly#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
binji authored Jul 28, 2017
1 parent b90c101 commit a4cb852
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1 deletion.
11 changes: 11 additions & 0 deletions document/core/binary/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,17 @@ All other numeric instructions are plain opcodes without any immediates.
\end{array}
.. math::
\begin{array}{llclll}
\phantom{\production{instruction}} & \phantom{\Binstr} &\phantom{::=}& \phantom{\dots} && \phantom{thisshouldbeenough} \\[-2ex] &&|&
\hex{C0} &\Rightarrow& \I32.\EXTEND\K{8\_s} \\ &&|&
\hex{C1} &\Rightarrow& \I32.\EXTEND\K{16\_s} \\ &&|&
\hex{C2} &\Rightarrow& \I64.\EXTEND\K{8\_s} \\ &&|&
\hex{C3} &\Rightarrow& \I64.\EXTEND\K{16\_s} \\ &&|&
\hex{C4} &\Rightarrow& \I64.\EXTEND\K{32\_s} \\
\end{array}
.. index:: expression
pair: binary format; expression
single: expression; constant
Expand Down
13 changes: 13 additions & 0 deletions document/core/exec/numerics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,19 @@ The integer result of predicates -- i.e., tests and relational operators -- is d
\end{array}
.. _op-iextend_s:

:math:`\iextends_N(i)`
......................

* Return :math:`\extends_{M,N}(i)`.

.. math::
\begin{array}{lll@{\qquad}l}
\iextends_{N}(i) &=& \extends_{M,N}(i) \\
\end{array}
Floating-Point Operations
~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
5 changes: 5 additions & 0 deletions document/core/syntax/instrindex.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,9 @@ Instruction Opcode Type
:math:`\I64.\REINTERPRET\K{/}\F64` :math:`\hex{BD}` :math:`[\F64] \to [\I64]` :ref:`validation <valid-cvtop>`
:math:`\F32.\REINTERPRET\K{/}\I32` :math:`\hex{BE}` :math:`[\I32] \to [\F32]` :ref:`validation <valid-cvtop>`
:math:`\F64.\REINTERPRET\K{/}\I64` :math:`\hex{BF}` :math:`[\I64] \to [\F64]` :ref:`validation <valid-cvtop>`
:math:`\I32.\EXTEND\K{8\_s}` :math:`\hex{C0}` :math:`[\I32] \to [\I32]` :ref:`validation <valid-unop>`
:math:`\I32.\EXTEND\K{16\_s}` :math:`\hex{C1}` :math:`[\I32] \to [\I32]` :ref:`validation <valid-unop>`
:math:`\I64.\EXTEND\K{8\_s}` :math:`\hex{C2}` :math:`[\I64] \to [\I64]` :ref:`validation <valid-unop>`
:math:`\I64.\EXTEND\K{16\_s}` :math:`\hex{C3}` :math:`[\I64] \to [\I64]` :ref:`validation <valid-unop>`
:math:`\I64.\EXTEND\K{32\_s}` :math:`\hex{C4}` :math:`[\I64] \to [\I64]` :ref:`validation <valid-unop>`
=================================== ================ ========================================== ======================================== ================
8 changes: 7 additions & 1 deletion document/core/syntax/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ These operations closely match respective operations available in hardware.
\K{i}\X{nn}\K{.}\itestop ~|~ \\&&&
\K{i}\X{nn}\K{.}\irelop ~|~
\K{f}\X{nn}\K{.}\frelop ~|~ \\&&&
\K{i}\X{nn}\K{.}\EXTEND\K{8\_s} ~|~
\K{i}\X{nn}\K{.}\EXTEND\K{16\_s} ~|~
\K{i64.}\EXTEND\K{32\_s} ~|~ \\&&&
\K{i32.}\WRAP\K{/i64} ~|~
\K{i64.}\EXTEND\K{\_}\sx/\K{i32} ~|~
\K{i}\X{nn}\K{.}\TRUNC\K{\_}\sx/\K{f}\X{mm} ~|~ \\&&&
Expand Down Expand Up @@ -151,7 +154,10 @@ Occasionally, it is convenient to group operators together according to the foll

.. math::
\begin{array}{llll}
\production{unary operator} & \unop &::=& \iunop ~|~ \funop \\
\production{unary operator} & \unop &::=&
\iunop ~|~
\funop ~|~
\EXTEND{N}\K{\_s} ~|~ \\
\production{binary operator} & \binop &::=& \ibinop ~|~ \fbinop \\
\production{test operator} & \testop &::=& \itestop \\
\production{relational operator} & \relop &::=& \irelop ~|~ \frelop \\
Expand Down
10 changes: 10 additions & 0 deletions document/core/text/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,16 @@ Numeric Instructions
\text{f64.reinterpret/i64} &\Rightarrow& \F64.\REINTERPRET\K{/}\I64 \\
\end{array}
.. math::
\begin{array}{llclll}
\phantom{\production{instruction}} & \phantom{\Tplaininstr_I} &\phantom{::=}& \phantom{thisisenough} && \phantom{thisshouldbeenough} \\[-2ex] &&|&
\text{i32.extend8\_s} &\Rightarrow& \I32.\EXTEND\K{8\_s} \\ &&|&
\text{i32.extend16\_s} &\Rightarrow& \I32.\EXTEND\K{16\_s} \\ &&|&
\text{i64.extend8\_s} &\Rightarrow& \I64.\EXTEND\K{8\_s} \\ &&|&
\text{i64.extend16\_s} &\Rightarrow& \I64.\EXTEND\K{16\_s} \\ &&|&
\text{i64.extend32\_s} &\Rightarrow& \I64.\EXTEND\K{32\_s} \\
\end{array}
.. index:: ! folded instruction, S-expression
.. _text-foldedinstr:
Expand Down
1 change: 1 addition & 0 deletions document/core/util/math.def
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@
.. |iles| mathdef:: \xref{exec/numerics}{op-ile_s}{\F{ile\_s}}
.. |igeu| mathdef:: \xref{exec/numerics}{op-ige_u}{\F{ige\_u}}
.. |iges| mathdef:: \xref{exec/numerics}{op-ige_s}{\F{ige\_s}}
.. |iextends| mathdef:: \xref{exec/numerics}{op-iextend_s}{\F{iextend{M}\_s}}

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

0 comments on commit a4cb852

Please # to comment.