From 0fdbb1d33810d84bbd9a408b3486bff0d9015989 Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Mon, 17 Aug 2020 19:50:37 +0200 Subject: Prepare for compound types that are single but not basic (#3046) As a follow-up to https://github.com/WebAssembly/binaryen/pull/3012#pullrequestreview-459686171 this PR prepares for the new compound Signature, Struct and Array types that are single but not basic. This includes: * Renames `Type::getSingle` to `Type::getBasic` (NFC). Previously, its name was not representing its implementation (`isSingle` excluded `none` and `unreachable` while `getSingle` didn't, i.e. `getSingle` really was `getBasic`). Note that a hypothetical `Type::getSingle` cannot return `ValueType` anyway (new compound types are single but don't map to `ValueType`), so I figured it's best to skip implementing it until we actually need it. * Marks locations where we are (still) assuming that all single types are basic types, as suggested in https://github.com/WebAssembly/binaryen/pull/3012#discussion_r465356708, but using a macro, so we get useful errors once we start implementing the new types and can quickly traverse the affected locations. The macro is added where * there used to be a `switch (type.getSingle())` or similar that handled any basic type (NFC), but in the future will also have to handle single types that are not basic types. * we are not dealing with `Unary`, `Binary`, `Load`, `Store` or `AtomicXY` instructions, since these don't deal with compound types anyway. --- src/tools/wasm-reduce.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/tools/wasm-reduce.cpp') diff --git a/src/tools/wasm-reduce.cpp b/src/tools/wasm-reduce.cpp index 029b9092d..e0491c0db 100644 --- a/src/tools/wasm-reduce.cpp +++ b/src/tools/wasm-reduce.cpp @@ -578,9 +578,11 @@ struct Reducer continue; // no conversion } Expression* fixed = nullptr; - switch (curr->type.getSingle()) { + TODO_SINGLE_COMPOUND(curr->type); + switch (curr->type.getBasic()) { case Type::i32: { - switch (child->type.getSingle()) { + TODO_SINGLE_COMPOUND(child->type); + switch (child->type.getBasic()) { case Type::i32: WASM_UNREACHABLE("invalid type"); case Type::i64: @@ -605,7 +607,8 @@ struct Reducer break; } case Type::i64: { - switch (child->type.getSingle()) { + TODO_SINGLE_COMPOUND(child->type); + switch (child->type.getBasic()) { case Type::i32: fixed = builder->makeUnary(ExtendSInt32, child); break; @@ -630,7 +633,8 @@ struct Reducer break; } case Type::f32: { - switch (child->type.getSingle()) { + TODO_SINGLE_COMPOUND(child->type); + switch (child->type.getBasic()) { case Type::i32: fixed = builder->makeUnary(ConvertSInt32ToFloat32, child); break; @@ -655,7 +659,8 @@ struct Reducer break; } case Type::f64: { - switch (child->type.getSingle()) { + TODO_SINGLE_COMPOUND(child->type); + switch (child->type.getBasic()) { case Type::i32: fixed = builder->makeUnary(ConvertSInt32ToFloat64, child); break; -- cgit v1.2.3