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

Commit c8bd1fd

Browse files
committed
[spectext] Add extended pairwise add instructions
This was merged in #380.
1 parent a041470 commit c8bd1fd

File tree

8 files changed

+550
-487
lines changed

8 files changed

+550
-487
lines changed

document/core/appendix/gen-index-instructions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,14 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat
470470
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'),
471471
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'),
472472
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'),
473+
Instruction(r'\I16X8.\EXTADDPAIRWISE\K{\_i8x16\_s}', r'\hex{FD}~~194', r'[\V128] \to [\V128]', r'valid-simd-extaddpairwise', r'exec-simd-extaddpairwise'),
474+
Instruction(r'\I16X8.\EXTADDPAIRWISE\K{\_i8x16\_u}', r'\hex{FD}~~195', r'[\V128] \to [\V128]', r'valid-simd-extaddpairwise', r'exec-simd-extaddpairwise'),
473475
Instruction(r'\I32X4.\VABS', r'\hex{FD}~~160', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vunop', r'op-iabs'),
474476
Instruction(r'\I32X4.\VNEG', r'\hex{FD}~~161', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vunop', r'op-ineg'),
475477
Instruction(r'\I32X4.\ALLTRUE', r'\hex{FD}~~163', r'[\V128] \to [\I32]', r'valid-vitestop', r'exec-vitestop'),
476478
Instruction(r'\I32X4.\BITMASK', r'\hex{FD}~~164', r'[\V128] \to [\I32]', r'valid-simd-bitmask', r'exec-simd-bitmask'),
479+
Instruction(r'\I32X4.\EXTADDPAIRWISE\K{\_i16x8\_s}', r'\hex{FD}~~165', r'[\V128] \to [\V128]', r'valid-simd-extaddpairwise', r'exec-simd-extaddpairwise'),
480+
Instruction(r'\I32X4.\EXTADDPAIRWISE\K{\_i16x8\_u}', r'\hex{FD}~~166', r'[\V128] \to [\V128]', r'valid-simd-extaddpairwise', r'exec-simd-extaddpairwise'),
477481
Instruction(r'\I32X4.\VEXTEND\K{\_low\_i16x8\_s}', r'\hex{FD}~~167', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-simd-extend'),
478482
Instruction(r'\I32X4.\VEXTEND\K{\_high\_i16x8\_s}', r'\hex{FD}~~168', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-simd-extend'),
479483
Instruction(r'\I32X4.\VEXTEND\K{\_low\_i16x8\_u}', r'\hex{FD}~~169', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-simd-extend'),

document/core/appendix/index-instructions.rst

Lines changed: 483 additions & 479 deletions
Large diffs are not rendered by default.

document/core/binary/instructions.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,9 @@ All other SIMD instructions are plain opcodes without any immediates.
663663
\hex{FD}~~156{:}\Bu32 &\Rightarrow& \I16X8.\Q15MULRSAT\K{\_s} \\ &&|&
664664
\hex{FD}~~157{:}\Bu32 &\Rightarrow& \I16X8.\EXTMUL\K{\_high\_i8x16\_s}\\ &&|&
665665
\hex{FD}~~158{:}\Bu32 &\Rightarrow& \I16X8.\EXTMUL\K{\_low\_i8x16\_u}\\ &&|&
666-
\hex{FD}~~159{:}\Bu32 &\Rightarrow& \I16X8.\EXTMUL\K{\_high\_i8x16\_u}\\
666+
\hex{FD}~~159{:}\Bu32 &\Rightarrow& \I16X8.\EXTMUL\K{\_high\_i8x16\_u}\\ &&|&
667+
\hex{FD}~~194{:}\Bu32 &\Rightarrow& \I16X8.\EXTADDPAIRWISE\K{\_i8x16\_s}\\ &&|&
668+
\hex{FD}~~195{:}\Bu32 &\Rightarrow& \I16X8.\EXTADDPAIRWISE\K{\_i8x16\_u}\\
667669
\end{array}
668670
669671
.. math::
@@ -673,6 +675,8 @@ All other SIMD instructions are plain opcodes without any immediates.
673675
\hex{FD}~~161{:}\Bu32 &\Rightarrow& \I32X4.\VNEG \\ &&|&
674676
\hex{FD}~~163{:}\Bu32 &\Rightarrow& \I32X4.\ALLTRUE \\ &&|&
675677
\hex{FD}~~164{:}\Bu32 &\Rightarrow& \I32X4.\BITMASK \\ &&|&
678+
\hex{FD}~~165{:}\Bu32 &\Rightarrow& \I32X4.\EXTADDPAIRWISE\K{\_i16x8\_s}\\ &&|&
679+
\hex{FD}~~166{:}\Bu32 &\Rightarrow& \I32X4.\EXTADDPAIRWISE\K{\_i16x8\_u}\\ &&|&
676680
\hex{FD}~~167{:}\Bu32 &\Rightarrow& \I32X4.\VEXTEND\K{\_low\_i16x8\_s} \\ &&|&
677681
\hex{FD}~~168{:}\Bu32 &\Rightarrow& \I32X4.\VEXTEND\K{\_high\_i16x8\_s} \\ &&|&
678682
\hex{FD}~~169{:}\Bu32 &\Rightarrow& \I32X4.\VEXTEND\K{\_low\_i16x8\_u} \\ &&|&

document/core/exec/instructions.rst

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ SIMD instructions are defined in terms of generic numeric operators applied lane
674674
.. _exec-simd-extend:
675675

676676
:math:`t_2\K{x}N\K{.}\VEXTEND\_\K{low}\_t_1\K{x}M\_\sx`
677-
.....................................................
677+
.......................................................
678678

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

@@ -700,7 +700,7 @@ SIMD instructions are defined in terms of generic numeric operators applied lane
700700
701701
702702
:math:`t_2\K{x}N\K{.}\VEXTEND\_\K{high}\_t_1\K{x}M\_\sx`
703-
......................................................
703+
........................................................
704704

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

@@ -776,6 +776,37 @@ SIMD instructions are defined in terms of generic numeric operators applied lane
776776
\end{array}
777777
778778
779+
.. _exec-simd-extaddpairwise:
780+
781+
:math:`t_2\K{x}N\K{.}\EXTADDPAIRWISE\_t_1\K{x}M\_\sx`
782+
.....................................................
783+
784+
1. Assert: due to :ref:`validation <valid-vitestop>`, a value of :ref:`value type <syntax-valtype>` |V128| is on the top of the stack.
785+
786+
2. Pop the value :math:`\V128.\VCONST~c_1` from the stack.
787+
788+
3. Let :math:`(i_1~i_2)^\ast` be the sequence :math:`\extend^{\sx}_{M,N}(\lanes_{t_1\K{x}M}(c_1))`.
789+
790+
4. Let :math:`j^\ast` be the result of computing :math:`\iadd_{N}(i_1, i_2)^\ast`.
791+
792+
5. Let `c` be the result of computing :math:`\lanes^{-1}_{t_2\K{x}N}(j^\ast)`.
793+
794+
6. Push the value :math:`\V128.\VCONST~c` to the stack.
795+
796+
.. math::
797+
\begin{array}{l}
798+
\begin{array}{lcl@{\qquad}l}
799+
(\V128\K{.}\VCONST~c_1)~t_2\K{x}N\K{.}\EXTADDPAIRWISE\_t_1\K{x}M\_\sx &\stepto& (\V128\K{.}\VCONST~c) \\
800+
\end{array}
801+
\\ \qquad
802+
\begin{array}[t]{@{}r@{~}l@{}}
803+
(\iff & (i_1~i_2)^\ast = \extend^{\sx}_{M,N}(\lanes_{t_1\K{x}M}(c_1)) \\
804+
\wedge & j^\ast = \iadd_{N}(i_1, i_2)^\ast \\
805+
\wedge & c = \lanes^{-1}_{t_2\K{x}N}(j^\ast)
806+
\end{array}
807+
\end{array}
808+
809+
779810
.. index:: parametric instructions, value
780811
pair: execution; instruction
781812
single: abstract syntax; instruction

document/core/syntax/instructions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ SIMD instructions provide basic operations over :ref:`values <syntax-value>` of
266266
\K{i32x4.}\EXTMUL\K{\_high}\K{\_i16x8\_}\sx \\&&|&
267267
\K{i64x2.}\EXTMUL\K{\_low}\K{\_i32x4\_}\sx ~|~
268268
\K{i64x2.}\EXTMUL\K{\_high}\K{\_i32x4\_}\sx \\&&|&
269+
\K{i16x8.}\EXTADDPAIRWISE\K{\_i8x16\_}\sx ~|~
270+
\K{i32x4.}\EXTADDPAIRWISE\K{\_i16x8\_}\sx \\ &&|&
269271
\fshape\K{.}\vfbinop \\&&|&
270272
\K{i32x4.}\VTRUNC\K{\_sat\_f32x4\_}\sx \\ &&|&
271273
\K{f32x4.}\VCONVERT\K{\_i32x4\_}\sx \\&&|&

document/core/text/instructions.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,9 @@ SIMD const instructions have a mandatory :ref:`shape <syntax-simd-shape>` descri
696696
\text{i16x8.extmul\_low\_i8x16\_s} &\Rightarrow& \I16X8.\EXTMUL\K{\_low\_i8x16\_s}\\ &&|&
697697
\text{i16x8.extmul\_high\_i8x16\_s} &\Rightarrow& \I16X8.\EXTMUL\K{\_high\_i8x16\_s}\\ &&|&
698698
\text{i16x8.extmul\_low\_i8x16\_u} &\Rightarrow& \I16X8.\EXTMUL\K{\_low\_i8x16\_u}\\ &&|&
699-
\text{i16x8.extmul\_high\_i8x16\_u} &\Rightarrow& \I16X8.\EXTMUL\K{\_high\_i8x16\_u}\\
699+
\text{i16x8.extmul\_high\_i8x16\_u} &\Rightarrow& \I16X8.\EXTMUL\K{\_high\_i8x16\_u}\\ &&|&
700+
\text{i16x8.extadd\_pairwise\_i8x16\_s} &\Rightarrow& \I16X8.\EXTADDPAIRWISE\K{\_i8x16\_s}\\ &&|&
701+
\text{i16x8.extadd\_pairwise\_i8x16\_u} &\Rightarrow& \I16X8.\EXTADDPAIRWISE\K{\_i8x16\_u}\\
700702
\end{array}
701703
702704
.. math::
@@ -706,10 +708,11 @@ SIMD const instructions have a mandatory :ref:`shape <syntax-simd-shape>` descri
706708
\text{i32x4.neg} &\Rightarrow& \I32X4.\VNEG\\ &&|&
707709
\text{i32x4.all\_true} &\Rightarrow& \I32X4.\ALLTRUE\\ &&|&
708710
\text{i32x4.bitmask} &\Rightarrow& \I32X4.\BITMASK\\ &&|&
709-
\text{i32x4.extend\_low\_i16x8\_s} &\Rightarrow& \I32X4.\VEXTEND\K{\_low\_i16x8\_s}\\ &&|&
710-
\text{i32x4.extend\_high\_i16x8\_s} &\Rightarrow& \I32X4.\VEXTEND\K{\_high\_i16x8\_s}\\ &&|&
711-
\text{i32x4.extend\_low\_i16x8\_u} &\Rightarrow& \I32X4.\VEXTEND\K{\_low\_i16x8\_u}\\ &&|&
712-
\text{i32x4.extend\_high\_i16x8\_u} &\Rightarrow& \I32X4.\VEXTEND\K{\_high\_i16x8\_u}\\ &&|&
711+
\text{i32x4.extadd\_pairwise\_i16x8\_s} &\Rightarrow& \I32X4.\EXTADDPAIRWISE\K{\_i16x8\_s}\\ &&|&
712+
\text{i32x4.widen\_low\_i16x8\_s} &\Rightarrow& \I32X4.\WIDEN\K{\_low\_i16x8\_s}\\ &&|&
713+
\text{i32x4.widen\_high\_i16x8\_s} &\Rightarrow& \I32X4.\WIDEN\K{\_high\_i16x8\_s}\\ &&|&
714+
\text{i32x4.widen\_low\_i16x8\_u} &\Rightarrow& \I32X4.\WIDEN\K{\_low\_i16x8\_u}\\ &&|&
715+
\text{i32x4.widen\_high\_i16x8\_u} &\Rightarrow& \I32X4.\WIDEN\K{\_high\_i16x8\_u}\\ &&|&
713716
\text{i32x4.shl} &\Rightarrow& \I32X4.\VSHL\\ &&|&
714717
\text{i32x4.shr\_s} &\Rightarrow& \I32X4.\VSHR\K{\_s}\\ &&|&
715718
\text{i32x4.shr\_u} &\Rightarrow& \I32X4.\VSHR\K{\_u}\\ &&|&

document/core/util/macros.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@
429429
.. |VTRUNC| mathdef:: \xref{syntax/instructions}{syntax-instr-simd}{\K{trunc}}
430430
.. |VCONVERT| mathdef:: \xref{syntax/instructions}{syntax-instr-simd}{\K{convert}}
431431
.. |Q15MULRSAT| mathdef:: \xref{syntax/instructions}{syntax-instr-simd}{\K{q15mulr\_sat}}
432+
.. |EXTADDPAIRWISE| mathdef:: \xref{syntax/instructions}{syntax-instr-simd}{\K{extadd\_pairwise}}
432433

433434

434435
.. Instructions, non-terminals

document/core/valid/instructions.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,20 @@ We also define an auxiliary function to get number of packed numeric types in a
464464
}
465465
466466
467+
.. _valid-simd-extaddpairwise:
468+
469+
:math:`\ishape\K{.}\EXTADDPAIRWISE\K{\_}\ishape\K{\_}\sx`
470+
.........................................................
471+
472+
* The instruction is valid with type :math:`[\V128] \to [\V128]`.
473+
474+
.. math::
475+
\frac{
476+
}{
477+
C \vdashinstr \ishape\K{.}\EXTADDPAIRWISE\K{\_}\ishape\K{\_}\sx : [\V128] \to [\V128]
478+
}
479+
480+
467481
.. index:: parametric instructions, value type, polymorphism
468482
pair: validation; instruction
469483
single: abstract syntax; instruction

0 commit comments

Comments
 (0)