Add saturating subtraction with a SIMD encoding

This includes the new instructions `ssub_sat` and `usub_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-subtraction).
This commit is contained in:
Andrew Brown
2019-09-18 16:28:13 -07:00
parent 21144068d4
commit 90c49a2f7c
5 changed files with 102 additions and 4 deletions

View File

@@ -1736,6 +1736,36 @@ pub(crate) fn define(
.operands_out(vec![a]),
);
ig.push(
Inst::new(
"usub_sat",
r#"
Subtract with unsigned saturation.
This is similar to `isub` but the operands are interpreted as unsigned integers and their
difference, instead of wrapping, will be saturated to the lowest unsigned integer for
the controlling type (e.g. `0x00` for i8).
"#,
)
.operands_in(vec![x, y])
.operands_out(vec![a]),
);
ig.push(
Inst::new(
"ssub_sat",
r#"
Subtract with signed saturation.
This is similar to `isub` but the operands are interpreted as signed integers and their
difference, instead of wrapping, will be saturated to the lowest or highest
signed integer for the controlling type (e.g. `0x80` or `0x7F` for i8).
"#,
)
.operands_in(vec![x, y])
.operands_out(vec![a]),
);
ig.push(
Inst::new(
"ineg",