summaryrefslogtreecommitdiff
path: root/src/tools/wasm-reduce.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/wasm-reduce.cpp')
-rw-r--r--src/tools/wasm-reduce.cpp120
1 files changed, 60 insertions, 60 deletions
diff --git a/src/tools/wasm-reduce.cpp b/src/tools/wasm-reduce.cpp
index 6adb1e174..5a05fc7d2 100644
--- a/src/tools/wasm-reduce.cpp
+++ b/src/tools/wasm-reduce.cpp
@@ -462,7 +462,7 @@ struct Reducer
void visitExpression(Expression* curr) {
// type-based reductions
- if (curr->type == none) {
+ if (curr->type == Type::none) {
if (tryToReduceCurrentToNop()) {
return;
}
@@ -471,14 +471,14 @@ struct Reducer
return;
}
} else {
- assert(curr->type == unreachable);
+ assert(curr->type == Type::unreachable);
if (tryToReduceCurrentToUnreachable()) {
return;
}
}
// specific reductions
if (auto* iff = curr->dynCast<If>()) {
- if (iff->type == none) {
+ if (iff->type == Type::none) {
// perhaps we need just the condition?
if (tryToReplaceCurrent(builder->makeDrop(iff->condition))) {
return;
@@ -556,7 +556,7 @@ struct Reducer
}
// Finally, try to replace with a child.
for (auto* child : ChildIterator(curr)) {
- if (child->type.isConcrete() && curr->type == none) {
+ if (child->type.isConcrete() && curr->type == Type::none) {
if (tryToReplaceCurrent(builder->makeDrop(child))) {
return;
}
@@ -578,114 +578,114 @@ struct Reducer
}
Expression* fixed = nullptr;
switch (curr->type) {
- case i32: {
+ case Type::i32: {
switch (child->type) {
- case i32:
+ case Type::i32:
WASM_UNREACHABLE("invalid type");
- case i64:
+ case Type::i64:
fixed = builder->makeUnary(WrapInt64, child);
break;
- case f32:
+ case Type::f32:
fixed = builder->makeUnary(TruncSFloat32ToInt32, child);
break;
- case f64:
+ case Type::f64:
fixed = builder->makeUnary(TruncSFloat64ToInt32, child);
break;
- case v128:
- case funcref:
- case anyref:
- case nullref:
- case exnref:
+ case Type::v128:
+ case Type::funcref:
+ case Type::anyref:
+ case Type::nullref:
+ case Type::exnref:
continue; // not implemented yet
- case none:
- case unreachable:
+ case Type::none:
+ case Type::unreachable:
WASM_UNREACHABLE("unexpected type");
}
break;
}
- case i64: {
+ case Type::i64: {
switch (child->type) {
- case i32:
+ case Type::i32:
fixed = builder->makeUnary(ExtendSInt32, child);
break;
- case i64:
+ case Type::i64:
WASM_UNREACHABLE("invalid type");
- case f32:
+ case Type::f32:
fixed = builder->makeUnary(TruncSFloat32ToInt64, child);
break;
- case f64:
+ case Type::f64:
fixed = builder->makeUnary(TruncSFloat64ToInt64, child);
break;
- case v128:
- case funcref:
- case anyref:
- case nullref:
- case exnref:
+ case Type::v128:
+ case Type::funcref:
+ case Type::anyref:
+ case Type::nullref:
+ case Type::exnref:
continue; // not implemented yet
- case none:
- case unreachable:
+ case Type::none:
+ case Type::unreachable:
WASM_UNREACHABLE("unexpected type");
}
break;
}
- case f32: {
+ case Type::f32: {
switch (child->type) {
- case i32:
+ case Type::i32:
fixed = builder->makeUnary(ConvertSInt32ToFloat32, child);
break;
- case i64:
+ case Type::i64:
fixed = builder->makeUnary(ConvertSInt64ToFloat32, child);
break;
- case f32:
+ case Type::f32:
WASM_UNREACHABLE("unexpected type");
- case f64:
+ case Type::f64:
fixed = builder->makeUnary(DemoteFloat64, child);
break;
- case v128:
- case funcref:
- case anyref:
- case nullref:
- case exnref:
+ case Type::v128:
+ case Type::funcref:
+ case Type::anyref:
+ case Type::nullref:
+ case Type::exnref:
continue; // not implemented yet
- case none:
- case unreachable:
+ case Type::none:
+ case Type::unreachable:
WASM_UNREACHABLE("unexpected type");
}
break;
}
- case f64: {
+ case Type::f64: {
switch (child->type) {
- case i32:
+ case Type::i32:
fixed = builder->makeUnary(ConvertSInt32ToFloat64, child);
break;
- case i64:
+ case Type::i64:
fixed = builder->makeUnary(ConvertSInt64ToFloat64, child);
break;
- case f32:
+ case Type::f32:
fixed = builder->makeUnary(PromoteFloat32, child);
break;
- case f64:
+ case Type::f64:
WASM_UNREACHABLE("unexpected type");
- case v128:
- case funcref:
- case anyref:
- case nullref:
- case exnref:
+ case Type::v128:
+ case Type::funcref:
+ case Type::anyref:
+ case Type::nullref:
+ case Type::exnref:
continue; // not implemented yet
- case none:
- case unreachable:
+ case Type::none:
+ case Type::unreachable:
WASM_UNREACHABLE("unexpected type");
}
break;
}
- case v128:
- case funcref:
- case anyref:
- case nullref:
- case exnref:
+ case Type::v128:
+ case Type::funcref:
+ case Type::anyref:
+ case Type::nullref:
+ case Type::exnref:
continue; // not implemented yet
- case none:
- case unreachable:
+ case Type::none:
+ case Type::unreachable:
WASM_UNREACHABLE("unexpected type");
}
assert(fixed->type == curr->type);
@@ -879,7 +879,7 @@ struct Reducer
auto funcSig = func->sig;
auto* funcBody = func->body;
for (auto* child : ChildIterator(func->body)) {
- if (!(child->type.isConcrete() || child->type == none)) {
+ if (!(child->type.isConcrete() || child->type == Type::none)) {
continue; // not something a function can return
}
// Try to replace the body with the child, fixing up the function