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

[spectext] Add ext mul instructions #453

Merged
merged 1 commit into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions document/core/exec/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,57 @@ SIMD instructions are defined in terms of generic numeric operators applied lane
\end{array}


.. _exec-simd-extmul:

:math:`t_2\K{x}N\K{.}\EXTMUL\_\K{low}\_t_1\K{x}M\_\sx` and :math:`t_2\K{x}N\K{.}\EXTMUL\_\K{high}\_t_1\K{x}M\_\sx`
..................................................................................................................

1. Assert: due to :ref:`validation <valid-vitestop>`, two values of :ref:`value type <syntax-valtype>` |V128| is on the top of the stack.

2. Pop the value :math:`\V128.\VCONST~c_2` from the stack.

3. Pop the value :math:`\V128.\VCONST~c_1` from the stack.

4. If :math:`\K{low}` is part of the instruction, then:

a. Let :math:`i^\ast` be the sequence :math:`\lanes_{t_1\K{x}M}(c_1)[0 \slice N]`.

b. Let :math:`j^\ast` be the sequence :math:`\lanes_{t_1\K{x}M}(c_2)[0 \slice N]`.

5. Else:

a. Let :math:`i^\ast` be the sequence :math:`\lanes_{t_1\K{x}M}(c_1)[N \slice N]`.

b. Let :math:`j^\ast` be the sequence :math:`\lanes_{t_1\K{x}M}(c_2)[N \slice N]`.

6. Let :math:`c` be the result of computing :math:`\lanes^{-1}_{t_2\K{x}N}(\imul_{t_2\K{x}N}(\extend^{\sx}_{M,N}(i^\ast), \extend^{\sx}_{M,N}(j^\ast)))`

8. Push the value :math:`\V128.\VCONST~c` onto the stack.

.. math::
\begin{array}{l}
\begin{array}{lcl@{\qquad}l}
(\V128\K{.}\VCONST~c_1)~(\V128\K{.}\VCONST~c_2)~t_2\K{x}N\K{.}\EXTMUL\_\K{low}\_t_1\K{x}M\_\sx &\stepto& (\V128\K{.}\VCONST~c) \\
\end{array}
\\ \qquad
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & i^\ast = \lanes_{t_1\K{x}M}(c_1)[0 \slice N] \\
\wedge & j^\ast = \lanes_{t_1\K{x}M}(c_2)[0 \slice N] \\
\wedge & c = \lanes^{-1}_{t_2\K{x}N}(\imul_{t_2\K{x}N}(\extend^{\sx}_{M,N}(i^\ast), \extend^{\sx}_{M,N}(j^\ast)))
\end{array}
\\[1ex]
\begin{array}{lcl@{\qquad}l}
(\V128\K{.}\VCONST~c_1)~(\V128\K{.}\VCONST~c_2)~t_2\K{x}N\K{.}\EXTMUL\_\K{high}\_t_1\K{x}M\_\sx &\stepto& (\V128\K{.}\VCONST~c) \\
\end{array}
\\ \qquad
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & i^\ast = \lanes_{t_1\K{x}M}(c_1)[N \slice N] \\
\wedge & j^\ast = \lanes_{t_1\K{x}M}(c_2)[N \slice N] \\
\wedge & c = \lanes^{-1}_{t_2\K{x}N}(\imul_{t_2\K{x}N}(\extend^{\sx}_{M,N}(i^\ast), \extend^{\sx}_{M,N}(j^\ast)))
\end{array}
\end{array}


.. index:: parametric instructions, value
pair: execution; instruction
single: abstract syntax; instruction
Expand Down
10 changes: 10 additions & 0 deletions document/core/syntax/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ SIMD instructions provide basic operations over :ref:`values <syntax-value>` of
\K{i64x2.}\K{mul} \\&&|&
\K{i8x16.}\AVGR\K{\_u} ~|~
\K{i16x8.}\AVGR\K{\_u} \\&&|&
\K{i16x8.}\EXTMUL\K{\_low}\K{\_i8x16\_}\sx ~|~
\K{i16x8.}\EXTMUL\K{\_high}\K{\_i8x16\_}\sx \\&&|&
\K{i32x4.}\EXTMUL\K{\_low}\K{\_i16x8\_}\sx ~|~
\K{i32x4.}\EXTMUL\K{\_high}\K{\_i16x8\_}\sx \\&&|&
\K{i64x2.}\EXTMUL\K{\_low}\K{\_i32x4\_}\sx ~|~
\K{i64x2.}\EXTMUL\K{\_high}\K{\_i32x4\_}\sx \\&&|&
\fshape\K{.}\vfbinop \\&&|&
\K{i32x4.}\VTRUNC\K{\_sat\_f32x4\_}\sx \\ &&|&
\K{f32x4.}\VCONVERT\K{\_i32x4\_}\sx \\&&|&
Expand Down Expand Up @@ -354,6 +360,7 @@ For the other SIMD instructions, the use of two's complement for the signed inte
.. _syntax-vunop:
.. _syntax-vbinop:
.. _syntax-vwiden:
.. _syntax-vextmul:

Conventions
...........
Expand All @@ -379,6 +386,9 @@ Occasionally, it is convenient to group operators together according to the foll
\production{widen operator} & \vwiden &::=&
\WIDEN\K{\_low\_}\shape\K{\_}\sx ~|~
\WIDEN\K{\_high\_}\shape\K{\_}\sx \\
\production{extmul operator} & \vextmul &::=&
\EXTMUL\K{\_low\_}\ishape\K{\_}\sx ~|~
\EXTMUL\K{\_high\_}\ishape\K{\_}\sx \\
\end{array}


Expand Down
2 changes: 2 additions & 0 deletions document/core/util/macros.def
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@
.. |NARROW| mathdef:: \xref{syntax/instructions}{syntax-instr-simd}{\K{narrow}}
.. |WIDEN| mathdef:: \xref{syntax/instructions}{syntax-instr-simd}{\K{widen}}
.. |AVGR| mathdef:: \xref{syntax/instructions}{syntax-instr-simd}{\K{avgr}}
.. |EXTMUL| mathdef:: \xref{syntax/instructions}{syntax-instr-simd}{\K{extmul}}
.. |VTRUNC| mathdef:: \xref{syntax/instructions}{syntax-instr-simd}{\K{trunc}}
.. |VCONVERT| mathdef:: \xref{syntax/instructions}{syntax-instr-simd}{\K{convert}}

Expand Down Expand Up @@ -453,6 +454,7 @@
.. |vternop| mathdef:: \xref{syntax/instructions}{syntax-vternop}{\X{vternop}}
.. |vwiden| mathdef:: \xref{syntax/instructions}{syntax-vwiden}{\X{vwiden}}
.. |vcvtop| mathdef:: \xref{syntax/instructions}{syntax-vcvtop}{\X{vcvtop}}
.. |vextmul| mathdef:: \xref{syntax/instructions}{syntax-vextmul}{\X{vextmul}}

.. |laneidx| mathdef:: \xref{syntax/instructions}{syntax-laneidx}{\X{laneidx}}
.. |vsunop| mathdef:: \xref{syntax/instructions}{syntax-vsunop}{\X{vsunop}}
Expand Down
14 changes: 14 additions & 0 deletions document/core/valid/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,20 @@ We also define an auxiliary function to get number of packed numeric types in a
}


.. _valid-simd-vextmul:

:math:`\ishape\K{.}\vextmul\K{\_}\ishape\K{\_}\sx`
..................................................

* The instruction is valid with type :math:`[\V128~\V128] \to [\V128]`.

.. math::
\frac{
}{
C \vdashinstr \ishape\K{.}\EXTMUL\K{\_}\ishape\K{\_}\sx : [\V128~\V128] \to [\V128]
}


.. index:: parametric instructions, value type, polymorphism
pair: validation; instruction
single: abstract syntax; instruction
Expand Down