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

[spectext] Add extended pairwise add instructions #476

Merged
merged 2 commits into from
Feb 24, 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
4 changes: 4 additions & 0 deletions document/core/appendix/gen-index-instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,14 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat
Instruction(r'\I16X8.\EXTMUL\K{\_high\_i8x16\_s}', r'\hex{FD}~~157', r'[\V128~\V128] \to [\V128]', r'valid-simd-vextmul', r'exec-simd-vextmul'),
Instruction(r'\I16X8.\EXTMUL\K{\_low\_i8x16\_u}', r'\hex{FD}~~158', r'[\V128~\V128] \to [\V128]', r'valid-simd-vextmul', r'exec-simd-vextmul'),
Instruction(r'\I16X8.\EXTMUL\K{\_high\_i8x16\_u}', r'\hex{FD}~~159', r'[\V128~\V128] \to [\V128]', r'valid-simd-vextmul', r'exec-simd-vextmul'),
Instruction(r'\I16X8.\EXTADDPAIRWISE\K{\_i8x16\_s}', r'\hex{FD}~~194', r'[\V128] \to [\V128]', r'valid-simd-extaddpairwise', r'exec-simd-extaddpairwise'),
Instruction(r'\I16X8.\EXTADDPAIRWISE\K{\_i8x16\_u}', r'\hex{FD}~~195', r'[\V128] \to [\V128]', r'valid-simd-extaddpairwise', r'exec-simd-extaddpairwise'),
Instruction(r'\I32X4.\VABS', r'\hex{FD}~~160', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vunop', r'op-iabs'),
Instruction(r'\I32X4.\VNEG', r'\hex{FD}~~161', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vunop', r'op-ineg'),
Instruction(r'\I32X4.\ALLTRUE', r'\hex{FD}~~163', r'[\V128] \to [\I32]', r'valid-vitestop', r'exec-vitestop'),
Instruction(r'\I32X4.\BITMASK', r'\hex{FD}~~164', r'[\V128] \to [\I32]', r'valid-simd-bitmask', r'exec-simd-bitmask'),
Instruction(r'\I32X4.\EXTADDPAIRWISE\K{\_i16x8\_s}', r'\hex{FD}~~165', r'[\V128] \to [\V128]', r'valid-simd-extaddpairwise', r'exec-simd-extaddpairwise'),
Instruction(r'\I32X4.\EXTADDPAIRWISE\K{\_i16x8\_u}', r'\hex{FD}~~166', r'[\V128] \to [\V128]', r'valid-simd-extaddpairwise', r'exec-simd-extaddpairwise'),
Instruction(r'\I32X4.\VEXTEND\K{\_low\_i16x8\_s}', r'\hex{FD}~~167', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-simd-extend'),
Instruction(r'\I32X4.\VEXTEND\K{\_high\_i16x8\_s}', r'\hex{FD}~~168', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-simd-extend'),
Instruction(r'\I32X4.\VEXTEND\K{\_low\_i16x8\_u}', r'\hex{FD}~~169', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-simd-extend'),
Expand Down
6 changes: 5 additions & 1 deletion document/core/binary/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,9 @@ All other SIMD instructions are plain opcodes without any immediates.
\hex{FD}~~156{:}\Bu32 &\Rightarrow& \I16X8.\Q15MULRSAT\K{\_s} \\ &&|&
\hex{FD}~~157{:}\Bu32 &\Rightarrow& \I16X8.\EXTMUL\K{\_high\_i8x16\_s}\\ &&|&
\hex{FD}~~158{:}\Bu32 &\Rightarrow& \I16X8.\EXTMUL\K{\_low\_i8x16\_u}\\ &&|&
\hex{FD}~~159{:}\Bu32 &\Rightarrow& \I16X8.\EXTMUL\K{\_high\_i8x16\_u}\\
\hex{FD}~~159{:}\Bu32 &\Rightarrow& \I16X8.\EXTMUL\K{\_high\_i8x16\_u}\\ &&|&
\hex{FD}~~194{:}\Bu32 &\Rightarrow& \I16X8.\EXTADDPAIRWISE\K{\_i8x16\_s}\\ &&|&
\hex{FD}~~195{:}\Bu32 &\Rightarrow& \I16X8.\EXTADDPAIRWISE\K{\_i8x16\_u}\\
\end{array}

.. math::
Expand All @@ -673,6 +675,8 @@ All other SIMD instructions are plain opcodes without any immediates.
\hex{FD}~~161{:}\Bu32 &\Rightarrow& \I32X4.\VNEG \\ &&|&
\hex{FD}~~163{:}\Bu32 &\Rightarrow& \I32X4.\ALLTRUE \\ &&|&
\hex{FD}~~164{:}\Bu32 &\Rightarrow& \I32X4.\BITMASK \\ &&|&
\hex{FD}~~165{:}\Bu32 &\Rightarrow& \I32X4.\EXTADDPAIRWISE\K{\_i16x8\_s}\\ &&|&
\hex{FD}~~166{:}\Bu32 &\Rightarrow& \I32X4.\EXTADDPAIRWISE\K{\_i16x8\_u}\\ &&|&
\hex{FD}~~167{:}\Bu32 &\Rightarrow& \I32X4.\VEXTEND\K{\_low\_i16x8\_s} \\ &&|&
\hex{FD}~~168{:}\Bu32 &\Rightarrow& \I32X4.\VEXTEND\K{\_high\_i16x8\_s} \\ &&|&
\hex{FD}~~169{:}\Bu32 &\Rightarrow& \I32X4.\VEXTEND\K{\_low\_i16x8\_u} \\ &&|&
Expand Down
35 changes: 33 additions & 2 deletions document/core/exec/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ SIMD instructions are defined in terms of generic numeric operators applied lane
.. _exec-simd-extend:

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

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

Expand All @@ -700,7 +700,7 @@ SIMD instructions are defined in terms of generic numeric operators applied lane


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

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

Expand Down Expand Up @@ -809,6 +809,37 @@ SIMD instructions are defined in terms of generic numeric operators applied lane
\end{array}


.. _exec-simd-extaddpairwise:

:math:`t_2\K{x}N\K{.}\EXTADDPAIRWISE\_t_1\K{x}M\_\sx`
.....................................................

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

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

3. Let :math:`(i_1~i_2)^\ast` be the sequence :math:`\extend^{\sx}_{M,N}(\lanes_{t_1\K{x}M}(c_1))`.

4. Let :math:`j^\ast` be the result of computing :math:`\iadd_{N}(i_1, i_2)^\ast`.

5. Let `c` be the result of computing :math:`\lanes^{-1}_{t_2\K{x}N}(j^\ast)`.

6. Push the value :math:`\V128.\VCONST~c` to the stack.

.. math::
\begin{array}{l}
\begin{array}{lcl@{\qquad}l}
(\V128\K{.}\VCONST~c_1)~t_2\K{x}N\K{.}\EXTADDPAIRWISE\_t_1\K{x}M\_\sx &\stepto& (\V128\K{.}\VCONST~c) \\
\end{array}
\\ \qquad
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & (i_1~i_2)^\ast = \extend^{\sx}_{M,N}(\lanes_{t_1\K{x}M}(c_1)) \\
\wedge & j^\ast = \iadd_{N}(i_1, i_2)^\ast \\
\wedge & c = \lanes^{-1}_{t_2\K{x}N}(j^\ast)
\end{array}
\end{array}


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

Conventions
...........
Expand Down
5 changes: 4 additions & 1 deletion document/core/text/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,9 @@ SIMD const instructions have a mandatory :ref:`shape <syntax-simd-shape>` descri
\text{i16x8.extmul\_low\_i8x16\_s} &\Rightarrow& \I16X8.\EXTMUL\K{\_low\_i8x16\_s}\\ &&|&
\text{i16x8.extmul\_high\_i8x16\_s} &\Rightarrow& \I16X8.\EXTMUL\K{\_high\_i8x16\_s}\\ &&|&
\text{i16x8.extmul\_low\_i8x16\_u} &\Rightarrow& \I16X8.\EXTMUL\K{\_low\_i8x16\_u}\\ &&|&
\text{i16x8.extmul\_high\_i8x16\_u} &\Rightarrow& \I16X8.\EXTMUL\K{\_high\_i8x16\_u}\\
\text{i16x8.extmul\_high\_i8x16\_u} &\Rightarrow& \I16X8.\EXTMUL\K{\_high\_i8x16\_u}\\ &&|&
\text{i16x8.extadd\_pairwise\_i8x16\_s} &\Rightarrow& \I16X8.\EXTADDPAIRWISE\K{\_i8x16\_s}\\ &&|&
\text{i16x8.extadd\_pairwise\_i8x16\_u} &\Rightarrow& \I16X8.\EXTADDPAIRWISE\K{\_i8x16\_u}\\
\end{array}

.. math::
Expand All @@ -706,6 +708,7 @@ SIMD const instructions have a mandatory :ref:`shape <syntax-simd-shape>` descri
\text{i32x4.neg} &\Rightarrow& \I32X4.\VNEG\\ &&|&
\text{i32x4.all\_true} &\Rightarrow& \I32X4.\ALLTRUE\\ &&|&
\text{i32x4.bitmask} &\Rightarrow& \I32X4.\BITMASK\\ &&|&
\text{i32x4.extadd\_pairwise\_i16x8\_s} &\Rightarrow& \I32X4.\EXTADDPAIRWISE\K{\_i16x8\_s}\\ &&|&
\text{i32x4.extend\_low\_i16x8\_s} &\Rightarrow& \I32X4.\VEXTEND\K{\_low\_i16x8\_s}\\ &&|&
\text{i32x4.extend\_high\_i16x8\_s} &\Rightarrow& \I32X4.\VEXTEND\K{\_high\_i16x8\_s}\\ &&|&
\text{i32x4.extend\_low\_i16x8\_u} &\Rightarrow& \I32X4.\VEXTEND\K{\_low\_i16x8\_u}\\ &&|&
Expand Down
1 change: 1 addition & 0 deletions document/core/util/macros.def
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@
.. |VTRUNC| mathdef:: \xref{syntax/instructions}{syntax-instr-simd}{\K{trunc}}
.. |VCONVERT| mathdef:: \xref{syntax/instructions}{syntax-instr-simd}{\K{convert}}
.. |Q15MULRSAT| mathdef:: \xref{syntax/instructions}{syntax-instr-simd}{\K{q15mulr\_sat}}
.. |EXTADDPAIRWISE| mathdef:: \xref{syntax/instructions}{syntax-instr-simd}{\K{extadd\_pairwise}}


.. Instructions, non-terminals
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 @@ -478,6 +478,20 @@ We also define an auxiliary function to get number of packed numeric types in a
}


.. _valid-simd-extaddpairwise:

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

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

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


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