diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2019-11-01 18:22:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-01 18:22:05 -0700 |
commit | 0a5925a52cc0888fb61bc7b55c78666add5025cd (patch) | |
tree | d21ff1cc88829dcacbc33b4ddd23e2d467fd8cb1 /src/wasm/literal.cpp | |
parent | 90297e84007031ec884d829f973556d49c9b9467 (diff) | |
download | binaryen-0a5925a52cc0888fb61bc7b55c78666add5025cd.tar.gz binaryen-0a5925a52cc0888fb61bc7b55c78666add5025cd.tar.bz2 binaryen-0a5925a52cc0888fb61bc7b55c78666add5025cd.zip |
Add SIMD integer min and max instructions (#2416)
As proposed in https://github.com/WebAssembly/simd/pull/27.
Diffstat (limited to 'src/wasm/literal.cpp')
-rw-r--r-- | src/wasm/literal.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index 7f0c9fa6b..f4ddf69cc 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -847,6 +847,19 @@ Literal Literal::remU(const Literal& other) const { } } +Literal Literal::minInt(const Literal& other) const { + return geti32() < other.geti32() ? *this : other; +} +Literal Literal::maxInt(const Literal& other) const { + return geti32() > other.geti32() ? *this : other; +} +Literal Literal::minUInt(const Literal& other) const { + return uint32_t(geti32()) < uint32_t(other.geti32()) ? *this : other; +} +Literal Literal::maxUInt(const Literal& other) const { + return uint32_t(geti32()) > uint32_t(other.geti32()) ? *this : other; +} + Literal Literal::and_(const Literal& other) const { switch (type) { case Type::i32: @@ -1703,6 +1716,18 @@ Literal Literal::subSaturateUI8x16(const Literal& other) const { Literal Literal::mulI8x16(const Literal& other) const { return binary<16, &Literal::getLanesUI8x16, &Literal::mul>(*this, other); } +Literal Literal::minSI8x16(const Literal& other) const { + return binary<16, &Literal::getLanesSI8x16, &Literal::minInt>(*this, other); +} +Literal Literal::minUI8x16(const Literal& other) const { + return binary<16, &Literal::getLanesUI8x16, &Literal::minInt>(*this, other); +} +Literal Literal::maxSI8x16(const Literal& other) const { + return binary<16, &Literal::getLanesSI8x16, &Literal::maxInt>(*this, other); +} +Literal Literal::maxUI8x16(const Literal& other) const { + return binary<16, &Literal::getLanesUI8x16, &Literal::maxInt>(*this, other); +} Literal Literal::addI16x8(const Literal& other) const { return binary<8, &Literal::getLanesUI16x8, &Literal::add>(*this, other); } @@ -1728,6 +1753,18 @@ Literal Literal::subSaturateUI16x8(const Literal& other) const { Literal Literal::mulI16x8(const Literal& other) const { return binary<8, &Literal::getLanesUI16x8, &Literal::mul>(*this, other); } +Literal Literal::minSI16x8(const Literal& other) const { + return binary<8, &Literal::getLanesSI16x8, &Literal::minInt>(*this, other); +} +Literal Literal::minUI16x8(const Literal& other) const { + return binary<8, &Literal::getLanesUI16x8, &Literal::minInt>(*this, other); +} +Literal Literal::maxSI16x8(const Literal& other) const { + return binary<8, &Literal::getLanesSI16x8, &Literal::maxInt>(*this, other); +} +Literal Literal::maxUI16x8(const Literal& other) const { + return binary<8, &Literal::getLanesUI16x8, &Literal::maxInt>(*this, other); +} Literal Literal::addI32x4(const Literal& other) const { return binary<4, &Literal::getLanesI32x4, &Literal::add>(*this, other); } @@ -1737,6 +1774,18 @@ Literal Literal::subI32x4(const Literal& other) const { Literal Literal::mulI32x4(const Literal& other) const { return binary<4, &Literal::getLanesI32x4, &Literal::mul>(*this, other); } +Literal Literal::minSI32x4(const Literal& other) const { + return binary<4, &Literal::getLanesI32x4, &Literal::minInt>(*this, other); +} +Literal Literal::minUI32x4(const Literal& other) const { + return binary<4, &Literal::getLanesI32x4, &Literal::minUInt>(*this, other); +} +Literal Literal::maxSI32x4(const Literal& other) const { + return binary<4, &Literal::getLanesI32x4, &Literal::maxInt>(*this, other); +} +Literal Literal::maxUI32x4(const Literal& other) const { + return binary<4, &Literal::getLanesI32x4, &Literal::maxUInt>(*this, other); +} Literal Literal::addI64x2(const Literal& other) const { return binary<2, &Literal::getLanesI64x2, &Literal::add>(*this, other); } |