Commit 39ff4a29 authored by nagayama15's avatar nagayama15

Update Binaryen

1.38.32 -> 1.39.1
parent 3b144f8b
ExternalProject_Add( ExternalProject_Add(
binaryen binaryen
URL https://github.com/WebAssembly/binaryen/archive/1.38.32.tar.gz URL https://github.com/WebAssembly/binaryen/archive/1.39.1.tar.gz
PREFIX binaryen PREFIX binaryen
INSTALL_COMMAND "" INSTALL_COMMAND ""
TEST_COMMAND "" TEST_COMMAND ""
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace kyut { namespace kyut {
[[nodiscard]] [[nodiscard]]
inline boost::optional<wasm::BinaryOp> getSwappedPredicate(wasm::BinaryOp op) { inline boost::optional<wasm::BinaryOp> getSwappedPredicate(wasm::BinaryOp op) {
static_assert(wasm::InvalidBinary == 152); static_assert(wasm::InvalidBinary == 158);
switch (op) { switch (op) {
// Commutative instructions // Commutative instructions
......
...@@ -24,7 +24,8 @@ namespace wasm { ...@@ -24,7 +24,8 @@ namespace wasm {
return a.getf64() < b.getf64(); return a.getf64() < b.getf64();
case v128: case v128:
return a.getv128() < b.getv128(); return a.getv128() < b.getv128();
case except_ref: case anyref:
case exnref:
return false; return false;
case unreachable: case unreachable:
return false; return false;
...@@ -34,7 +35,7 @@ namespace wasm { ...@@ -34,7 +35,7 @@ namespace wasm {
} }
[[nodiscard]] inline bool operator<(const Expression &a, const Expression &b) { [[nodiscard]] inline bool operator<(const Expression &a, const Expression &b) {
static_assert(Expression::NumExpressionIds == 36); static_assert(Expression::NumExpressionIds == 44);
constexpr auto opt = [](const Expression *p) -> boost::optional<const Expression &> { constexpr auto opt = [](const Expression *p) -> boost::optional<const Expression &> {
if (p == nullptr) { if (p == nullptr) {
...@@ -94,27 +95,27 @@ namespace wasm { ...@@ -94,27 +95,27 @@ namespace wasm {
return std::forward_as_tuple(x.operands, *x.target) < std::forward_as_tuple(y.operands, *y.target); return std::forward_as_tuple(x.operands, *x.target) < std::forward_as_tuple(y.operands, *y.target);
} }
case Expression::GetLocalId: { case Expression::LocalGetId: {
const auto &x = *a.cast<GetLocal>(); const auto &x = *a.cast<LocalGet>();
const auto &y = *b.cast<GetLocal>(); const auto &y = *b.cast<LocalGet>();
return x.index < y.index; return x.index < y.index;
} }
case Expression::SetLocalId: { case Expression::LocalSetId: {
const auto &x = *a.cast<SetLocal>(); const auto &x = *a.cast<LocalSet>();
const auto &y = *b.cast<SetLocal>(); const auto &y = *b.cast<LocalSet>();
return std::tie(x.index, *x.value) < std::tie(y.index, *y.value); return std::tie(x.index, *x.value) < std::tie(y.index, *y.value);
} }
case Expression::GetGlobalId: { case Expression::GlobalGetId: {
const auto &x = *a.cast<GetGlobal>(); const auto &x = *a.cast<GlobalGet>();
const auto &y = *b.cast<GetGlobal>(); const auto &y = *b.cast<GlobalGet>();
return x.name < y.name; return x.name < y.name;
} }
case Expression::SetGlobalId: { case Expression::GlobalSetId: {
const auto &x = *a.cast<SetGlobal>(); const auto &x = *a.cast<GlobalSet>();
const auto &y = *b.cast<SetGlobal>(); const auto &y = *b.cast<GlobalSet>();
return std::tie(*x.value, x.name) < std::tie(*y.value, y.name); return std::tie(*x.value, x.name) < std::tie(*y.value, y.name);
} }
...@@ -221,6 +222,12 @@ namespace wasm { ...@@ -221,6 +222,12 @@ namespace wasm {
return std::tie(x.offset.addr, *x.ptr, *x.notifyCount) < std::tie(y.offset.addr, *y.ptr, *y.notifyCount); return std::tie(x.offset.addr, *x.ptr, *x.notifyCount) < std::tie(y.offset.addr, *y.ptr, *y.notifyCount);
} }
case Expression::AtomicFenceId: {
[[maybe_unused]] const auto &x = *a.cast<AtomicFence>();
[[maybe_unused]] const auto &y = *b.cast<AtomicFence>();
return false;
}
case Expression::SIMDExtractId: { case Expression::SIMDExtractId: {
const auto &x = *a.cast<SIMDExtract>(); const auto &x = *a.cast<SIMDExtract>();
const auto &y = *b.cast<SIMDExtract>(); const auto &y = *b.cast<SIMDExtract>();
...@@ -239,11 +246,11 @@ namespace wasm { ...@@ -239,11 +246,11 @@ namespace wasm {
return std::tie(*x.left, *x.right, x.mask) < std::tie(*y.left, *y.right, y.mask); return std::tie(*x.left, *x.right, x.mask) < std::tie(*y.left, *y.right, y.mask);
} }
case Expression::SIMDBitselectId: { case Expression::SIMDTernaryId: {
const auto &x = *a.cast<SIMDBitselect>(); const auto &x = *a.cast<SIMDTernary>();
const auto &y = *b.cast<SIMDBitselect>(); const auto &y = *b.cast<SIMDTernary>();
return std::tie(*x.left, *x.right, *x.cond) < std::tie(*y.left, *y.right, *y.cond); return std::tie(*x.a, *x.b, *x.c) < std::tie(*y.a, *y.b, *y.c);
} }
case Expression::SIMDShiftId: { case Expression::SIMDShiftId: {
const auto &x = *a.cast<SIMDShift>(); const auto &x = *a.cast<SIMDShift>();
...@@ -251,6 +258,12 @@ namespace wasm { ...@@ -251,6 +258,12 @@ namespace wasm {
return std::tie(x.op, *x.vec, *x.shift) < std::tie(y.op, *y.vec, *y.shift); return std::tie(x.op, *x.vec, *x.shift) < std::tie(y.op, *y.vec, *y.shift);
} }
case Expression::SIMDLoadId: {
const auto &x = *a.cast<SIMDLoad>();
const auto &y = *b.cast<SIMDLoad>();
return std::tie(x.op, x.offset, x.align, *x.ptr) < std::tie(y.op, y.offset, y.align, *y.ptr) ;
}
case Expression::MemoryInitId: { case Expression::MemoryInitId: {
const auto &x = *a.cast<MemoryInit>(); const auto &x = *a.cast<MemoryInit>();
const auto &y = *b.cast<MemoryInit>(); const auto &y = *b.cast<MemoryInit>();
...@@ -275,6 +288,42 @@ namespace wasm { ...@@ -275,6 +288,42 @@ namespace wasm {
return std::tie(*x.dest, *x.value, *x.size) < std::tie(*y.dest, *y.value, *y.size); return std::tie(*x.dest, *x.value, *x.size) < std::tie(*y.dest, *y.value, *y.size);
} }
case Expression::PushId:{
const auto &x = *a.cast<Push>();
const auto &y = *b.cast<Push>();
return std::tie(*x.value) < std::tie(*y.value);
}
case Expression::PopId:{
[[maybe_unused]] const auto &x = *a.cast<Pop>();
[[maybe_unused]] const auto &y = *b.cast<Pop>();
return false;
}
case Expression::TryId:{
const auto &x = *a.cast<Try>();
const auto &y = *b.cast<Try>();
return std::forward_as_tuple(opt(x.body), opt(x.catchBody)) < std::forward_as_tuple(opt(y.body), opt(y.catchBody));
}
case Expression::ThrowId:{
const auto &x = *a.cast<Throw>();
const auto &y = *b.cast<Throw>();
return std::tie(x.operands) < std::tie(y.operands);
}
case Expression::RethrowId:{
const auto &x = *a.cast<Rethrow>();
const auto &y = *b.cast<Rethrow>();
return std::forward_as_tuple(opt(x.exnref)) < std::forward_as_tuple(opt(y.exnref));
}
case Expression::BrOnExnId:{
const auto &x = *a.cast<BrOnExn>();
const auto &y = *b.cast<BrOnExn>();
return std::forward_as_tuple(opt(x.exnref)) < std::forward_as_tuple(opt(y.exnref));
}
default: default:
WASM_UNREACHABLE(); WASM_UNREACHABLE();
} }
......
...@@ -88,21 +88,21 @@ namespace kyut::watermarker { ...@@ -88,21 +88,21 @@ namespace kyut::watermarker {
return SideEffect::write; return SideEffect::write;
} }
SideEffect visitGetLocal([[maybe_unused]] wasm::GetLocal *expr) { SideEffect visitLocalGet([[maybe_unused]] wasm::LocalGet *expr) {
return SideEffect::readOnly; return SideEffect::readOnly;
} }
SideEffect visitSetLocal(wasm::SetLocal *expr) { SideEffect visitLocalSet(wasm::LocalSet *expr) {
visit(expr->value); visit(expr->value);
return SideEffect::write; return SideEffect::write;
} }
SideEffect visitGetGlobal([[maybe_unused]] wasm::GetGlobal *expr) { SideEffect visitGlobalGet([[maybe_unused]] wasm::GlobalGet *expr) {
return SideEffect::readOnly; return SideEffect::readOnly;
} }
SideEffect visitSetGlobal(wasm::SetGlobal *expr) { SideEffect visitGlobalSet(wasm::GlobalSet *expr) {
visit(expr->value); visit(expr->value);
return SideEffect::write; return SideEffect::write;
...@@ -216,6 +216,10 @@ namespace kyut::watermarker { ...@@ -216,6 +216,10 @@ namespace kyut::watermarker {
return SideEffect::write; return SideEffect::write;
} }
SideEffect visitAtomicFence([[maybe_unused]] wasm::AtomicFence *expr) {
return SideEffect::write;
}
SideEffect visitSIMDExtract(wasm::SIMDExtract *expr) { SideEffect visitSIMDExtract(wasm::SIMDExtract *expr) {
return visit(expr->vec); return visit(expr->vec);
} }
...@@ -228,11 +232,11 @@ namespace kyut::watermarker { ...@@ -228,11 +232,11 @@ namespace kyut::watermarker {
return (std::max)(visit(expr->left), visit(expr->right)); return (std::max)(visit(expr->left), visit(expr->right));
} }
SideEffect visitSIMDBitselect(wasm::SIMDBitselect *expr) { SideEffect visitSIMDTernary(wasm::SIMDTernary *expr) {
return (std::max)({ return (std::max)({
visit(expr->cond), visit(expr->a),
visit(expr->left), visit(expr->b),
visit(expr->right), visit(expr->c),
}); });
} }
...@@ -240,6 +244,13 @@ namespace kyut::watermarker { ...@@ -240,6 +244,13 @@ namespace kyut::watermarker {
return (std::max)(visit(expr->vec), visit(expr->shift)); return (std::max)(visit(expr->vec), visit(expr->shift));
} }
SideEffect visitSIMDLoad(wasm::SIMDLoad *expr) {
return (std::max)({
visit(expr->ptr),
SideEffect::readOnly,
});
}
SideEffect visitMemoryInit(wasm::MemoryInit *expr) { SideEffect visitMemoryInit(wasm::MemoryInit *expr) {
visit(expr->dest); visit(expr->dest);
visit(expr->offset); visit(expr->offset);
...@@ -268,6 +279,41 @@ namespace kyut::watermarker { ...@@ -268,6 +279,41 @@ namespace kyut::watermarker {
return SideEffect::write; return SideEffect::write;
} }
SideEffect visitPush([[maybe_unused]] wasm::Push *expr) {
visit(expr->value);
return SideEffect::write;
}
SideEffect visitPop([[maybe_unused]] wasm::Pop *expr) {
return SideEffect::write;
}
SideEffect visitTry(wasm::Try *expr) {
return (std::max)({
visit(expr->body),
visit(expr->catchBody),
});
}
SideEffect visitThrow(wasm::Throw *expr) {
visitExpressionList(expr->operands);
return SideEffect::write;
}
SideEffect visitRethrow(wasm::Rethrow *expr) {
visit(expr->exnref);
return SideEffect::write;
}
SideEffect visitBrOnExn(wasm::BrOnExn *expr) {
visit(expr->exnref);
return SideEffect::write;
}
SideEffect visit(wasm::Expression *expr) { SideEffect visit(wasm::Expression *expr) {
if (expr == nullptr) { if (expr == nullptr) {
return SideEffect::none; return SideEffect::none;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment