Add saturating addition with a SIMD encoding

This includes the new instructions `sadd_sat` and `uadd_sat` and only encodes the i8x16 and i16x8 types; these are what is needed for implementing the SIMD spec (see https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#saturating-integer-addition).
This commit is contained in:
Andrew Brown
2019-09-18 15:56:15 -07:00
parent 630cb3ee62
commit 21144068d4
5 changed files with 98 additions and 4 deletions

View File

@@ -1690,6 +1690,38 @@ pub(crate) fn define(
.operands_out(vec![a]),
);
ig.push(
Inst::new(
"uadd_sat",
r#"
Add with unsigned saturation.
This is similar to `iadd` but the operands are interpreted as unsigned integers and their
summed result, instead of wrapping, will be saturated to the highest unsigned integer for
the controlling type (e.g. `0xFF` for i8).
"#,
)
.operands_in(vec![x, y])
.operands_out(vec![a]),
);
ig.push(
Inst::new(
"sadd_sat",
r#"
Add with signed saturation.
This is similar to `iadd` but the operands are interpreted as signed integers and their
summed result, instead of wrapping, will be saturated to the lowest or highest
signed integer for the controlling type (e.g. `0x80` or `0x7F` for i8). For example,
since an `iadd_ssat.i8` of `0x70` and `0x70` is greater than `0x7F`, the result will be
clamped to `0x7F`.
"#,
)
.operands_in(vec![x, y])
.operands_out(vec![a]),
);
ig.push(
Inst::new(
"isub",