summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/Print.cpp2
-rw-r--r--src/wasm-interpreter.h10
-rw-r--r--src/wasm-s-parser.h8
-rw-r--r--test/llvm_autogenerated/legalize.wast336
-rw-r--r--test/llvm_autogenerated/select.wast24
m---------test/spec0
-rw-r--r--test/unit.fromasm2
-rw-r--r--test/unit.wast2
-rw-r--r--test/unit.wast.fromBinary2
9 files changed, 195 insertions, 191 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 3c3cdd659..f365db02f 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -314,7 +314,7 @@ struct PrintSExpression : public WasmVisitor<PrintSExpression, void> {
}
void visitSelect(Select *curr) {
o << '(';
- prepareColor(o) << printWasmType(curr->type) << ".select";
+ prepareColor(o) << "select";
incIndent();
printFullLine(curr->ifTrue);
printFullLine(curr->ifFalse);
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 2a841f6fd..a7405e948 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -29,6 +29,10 @@
#include "support/bits.h"
#include "wasm.h"
+#ifdef WASM_INTERPRETER_DEBUG
+#include "wasm-printing.h"
+#endif
+
namespace wasm {
using namespace cashew;
@@ -166,7 +170,7 @@ private:
indent++;
#if WASM_INTERPRETER_DEBUG == 2
doIndent(std::cout, indent);
- expression->print(std::cout, indent) << '\n';
+ std::cout << "\n" << expression << '\n';
indent++;
#endif
}
@@ -445,8 +449,8 @@ private:
if (flow.breaking()) return flow;
Literal right = flow.value;
NOTE_EVAL2(left, right);
- assert(left.type == curr->left->type);
- assert(right.type == curr->right->type);
+ assert(isConcreteWasmType(curr->left->type) ? left.type == curr->left->type : true);
+ assert(isConcreteWasmType(curr->right->type) ? right.type == curr->right->type : true);
if (left.type == i32) {
switch (curr->op) {
case Add: return left.add(right);
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index d0206bcc2..24ca1b811 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -524,7 +524,6 @@ public:
abort_on(op);
}
case 's': {
- if (op[1] == 'e') return makeSelect(s, type);
if (op[1] == 'h') {
if (op[2] == 'l') return makeBinary(s, BinaryOp::Shl, type);
return makeBinary(s, op[4] == 'u' ? BinaryOp::ShrU : BinaryOp::ShrS, type);
@@ -598,7 +597,8 @@ public:
abort_on(str);
}
case 's': {
- if (str[1] == 'e') return makeSetLocal(s);
+ if (str[1] == 'e' && str[2] == 't') return makeSetLocal(s);
+ if (str[1] == 'e' && str[2] == 'l') return makeSelect(s);
abort_on(str);
}
case 'r': {
@@ -637,12 +637,12 @@ private:
return ret;
}
- Expression* makeSelect(Element& s, WasmType type) {
+ Expression* makeSelect(Element& s) {
auto ret = allocator.alloc<Select>();
ret->ifTrue = parseExpression(s[1]);
ret->ifFalse = parseExpression(s[2]);
ret->condition = parseExpression(s[3]);
- ret->type = type;
+ ret->finalize();
return ret;
}
diff --git a/test/llvm_autogenerated/legalize.wast b/test/llvm_autogenerated/legalize.wast
index 5739c158d..83f2e8a54 100644
--- a/test/llvm_autogenerated/legalize.wast
+++ b/test/llvm_autogenerated/legalize.wast
@@ -2804,9 +2804,9 @@
(get_local $$0)
(i32.const 8)
)
- (i64.select
- (i64.select
- (i64.select
+ (select
+ (select
+ (select
(i64.load
(i32.add
(get_local $$311)
@@ -2840,9 +2840,9 @@
)
(i64.store
(get_local $$0)
- (i64.select
- (i64.select
- (i64.select
+ (select
+ (select
+ (select
(get_local $$152)
(i64.const 0)
(get_local $$168)
@@ -2859,11 +2859,11 @@
(get_local $$0)
(i32.const 24)
)
- (i64.select
- (i64.select
- (i64.select
+ (select
+ (select
+ (select
(get_local $$4)
- (i64.select
+ (select
(i64.or
(get_local $$149)
(get_local $$150)
@@ -2890,11 +2890,11 @@
(get_local $$0)
(i32.const 16)
)
- (i64.select
- (i64.select
- (i64.select
+ (select
+ (select
+ (select
(get_local $$3)
- (i64.select
+ (select
(i64.or
(get_local $$146)
(get_local $$147)
@@ -2916,14 +2916,14 @@
(get_local $$0)
(i32.const 56)
)
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$8)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$8)
- (i64.select
+ (select
(i64.or
(get_local $$132)
(get_local $$133)
@@ -2933,7 +2933,7 @@
)
(get_local $$165)
)
- (i64.select
+ (select
(get_local $$135)
(i64.const 0)
(set_local $$164
@@ -2944,9 +2944,9 @@
)
)
)
- (i64.select
+ (select
(get_local $$4)
- (i64.select
+ (select
(i64.or
(get_local $$130)
(get_local $$129)
@@ -2979,14 +2979,14 @@
(get_local $$0)
(i32.const 48)
)
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$7)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$7)
- (i64.select
+ (select
(i64.or
(get_local $$125)
(get_local $$126)
@@ -2996,15 +2996,15 @@
)
(get_local $$165)
)
- (i64.select
+ (select
(get_local $$128)
(i64.const 0)
(get_local $$164)
)
)
- (i64.select
+ (select
(get_local $$3)
- (i64.select
+ (select
(i64.or
(get_local $$123)
(get_local $$122)
@@ -3027,19 +3027,19 @@
(get_local $$0)
(i32.const 40)
)
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$6)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$144)
(i64.const 0)
(get_local $$168)
)
- (i64.select
+ (select
(get_local $$2)
- (i64.select
+ (select
(i64.or
(get_local $$141)
(get_local $$142)
@@ -3055,7 +3055,7 @@
)
)
)
- (i64.select
+ (select
(get_local $$145)
(i64.const 0)
(get_local $$163)
@@ -3073,19 +3073,19 @@
(get_local $$0)
(i32.const 32)
)
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$5)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$139)
(i64.const 0)
(get_local $$168)
)
- (i64.select
+ (select
(get_local $$1)
- (i64.select
+ (select
(i64.or
(get_local $$136)
(get_local $$137)
@@ -3096,7 +3096,7 @@
(get_local $$162)
)
)
- (i64.select
+ (select
(get_local $$140)
(i64.const 0)
(get_local $$163)
@@ -3114,17 +3114,17 @@
(get_local $$0)
(i32.const 120)
)
- (i64.select
+ (select
(get_local $$16)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$16)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$16)
- (i64.select
+ (select
(i64.or
(get_local $$51)
(get_local $$52)
@@ -3134,15 +3134,15 @@
)
(get_local $$165)
)
- (i64.select
+ (select
(get_local $$54)
(i64.const 0)
(get_local $$164)
)
)
- (i64.select
+ (select
(get_local $$12)
- (i64.select
+ (select
(i64.or
(get_local $$49)
(get_local $$48)
@@ -3156,8 +3156,8 @@
)
(get_local $$165)
)
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$55)
(i64.const 0)
(set_local $$161
@@ -3176,13 +3176,13 @@
)
)
)
- (i64.select
+ (select
(get_local $$8)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$8)
- (i64.select
+ (select
(i64.or
(get_local $$45)
(get_local $$175)
@@ -3202,7 +3202,7 @@
)
)
)
- (i64.select
+ (select
(get_local $$47)
(i64.const 0)
(set_local $$157
@@ -3213,9 +3213,9 @@
)
)
)
- (i64.select
+ (select
(get_local $$4)
- (i64.select
+ (select
(i64.or
(get_local $$177)
(get_local $$174)
@@ -3254,17 +3254,17 @@
(get_local $$0)
(i32.const 112)
)
- (i64.select
+ (select
(get_local $$15)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$15)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$15)
- (i64.select
+ (select
(i64.or
(get_local $$40)
(get_local $$41)
@@ -3274,15 +3274,15 @@
)
(get_local $$165)
)
- (i64.select
+ (select
(get_local $$43)
(i64.const 0)
(get_local $$164)
)
)
- (i64.select
+ (select
(get_local $$11)
- (i64.select
+ (select
(i64.or
(get_local $$38)
(get_local $$37)
@@ -3296,8 +3296,8 @@
)
(get_local $$165)
)
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$44)
(i64.const 0)
(get_local $$161)
@@ -3306,13 +3306,13 @@
(get_local $$160)
)
)
- (i64.select
+ (select
(get_local $$7)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$7)
- (i64.select
+ (select
(i64.or
(get_local $$34)
(get_local $$33)
@@ -3322,15 +3322,15 @@
)
(get_local $$158)
)
- (i64.select
+ (select
(get_local $$36)
(i64.const 0)
(get_local $$157)
)
)
- (i64.select
+ (select
(get_local $$3)
- (i64.select
+ (select
(i64.or
(get_local $$181)
(get_local $$173)
@@ -3354,22 +3354,22 @@
(get_local $$0)
(i32.const 104)
)
- (i64.select
+ (select
(get_local $$14)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$14)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$115)
(i64.const 0)
(get_local $$168)
)
- (i64.select
+ (select
(get_local $$10)
- (i64.select
+ (select
(i64.or
(get_local $$112)
(get_local $$113)
@@ -3380,7 +3380,7 @@
(get_local $$162)
)
)
- (i64.select
+ (select
(get_local $$116)
(i64.const 0)
(get_local $$163)
@@ -3389,10 +3389,10 @@
)
(get_local $$165)
)
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$6)
- (i64.select
+ (select
(i64.or
(get_local $$109)
(get_local $$110)
@@ -3411,18 +3411,18 @@
(get_local $$160)
)
)
- (i64.select
+ (select
(get_local $$6)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$120)
(i64.const 0)
(get_local $$159)
)
- (i64.select
+ (select
(get_local $$2)
- (i64.select
+ (select
(i64.or
(get_local $$117)
(get_local $$118)
@@ -3438,7 +3438,7 @@
)
)
)
- (i64.select
+ (select
(get_local $$121)
(i64.const 0)
(get_local $$156)
@@ -3457,22 +3457,22 @@
(get_local $$0)
(i32.const 96)
)
- (i64.select
+ (select
(get_local $$13)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$13)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$102)
(i64.const 0)
(get_local $$168)
)
- (i64.select
+ (select
(get_local $$9)
- (i64.select
+ (select
(i64.or
(get_local $$99)
(get_local $$100)
@@ -3483,7 +3483,7 @@
(get_local $$162)
)
)
- (i64.select
+ (select
(get_local $$103)
(i64.const 0)
(get_local $$163)
@@ -3492,10 +3492,10 @@
)
(get_local $$165)
)
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$5)
- (i64.select
+ (select
(i64.or
(get_local $$96)
(get_local $$97)
@@ -3509,18 +3509,18 @@
(get_local $$160)
)
)
- (i64.select
+ (select
(get_local $$5)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$107)
(i64.const 0)
(get_local $$159)
)
- (i64.select
+ (select
(get_local $$1)
- (i64.select
+ (select
(i64.or
(get_local $$104)
(get_local $$105)
@@ -3531,7 +3531,7 @@
(get_local $$155)
)
)
- (i64.select
+ (select
(get_local $$108)
(i64.const 0)
(get_local $$156)
@@ -3550,12 +3550,12 @@
(get_local $$0)
(i32.const 72)
)
- (i64.select
+ (select
(get_local $$10)
- (i64.select
+ (select
(i64.or
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$94)
(i64.const 0)
(get_local $$168)
@@ -3563,13 +3563,13 @@
(i64.const 0)
(get_local $$167)
)
- (i64.select
+ (select
(get_local $$2)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$2)
- (i64.select
+ (select
(i64.or
(get_local $$90)
(get_local $$91)
@@ -3579,7 +3579,7 @@
)
(get_local $$153)
)
- (i64.select
+ (select
(get_local $$93)
(i64.const 0)
(set_local $$163
@@ -3590,9 +3590,9 @@
)
)
)
- (i64.select
+ (select
(get_local $$6)
- (i64.select
+ (select
(i64.or
(get_local $$87)
(get_local $$88)
@@ -3607,8 +3607,8 @@
(get_local $$153)
)
)
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$95)
(i64.const 0)
(get_local $$159)
@@ -3626,12 +3626,12 @@
(get_local $$0)
(i32.const 64)
)
- (i64.select
+ (select
(get_local $$9)
- (i64.select
+ (select
(i64.or
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$85)
(i64.const 0)
(get_local $$168)
@@ -3639,13 +3639,13 @@
(i64.const 0)
(get_local $$167)
)
- (i64.select
+ (select
(get_local $$1)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$1)
- (i64.select
+ (select
(i64.or
(get_local $$81)
(get_local $$82)
@@ -3655,15 +3655,15 @@
)
(get_local $$153)
)
- (i64.select
+ (select
(get_local $$84)
(i64.const 0)
(get_local $$163)
)
)
- (i64.select
+ (select
(get_local $$5)
- (i64.select
+ (select
(i64.or
(get_local $$78)
(get_local $$79)
@@ -3678,8 +3678,8 @@
(get_local $$153)
)
)
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$86)
(i64.const 0)
(get_local $$159)
@@ -3697,14 +3697,14 @@
(get_local $$0)
(i32.const 88)
)
- (i64.select
+ (select
(get_local $$12)
- (i64.select
+ (select
(i64.or
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$12)
- (i64.select
+ (select
(i64.or
(get_local $$67)
(get_local $$68)
@@ -3717,18 +3717,18 @@
(i64.const 0)
(get_local $$167)
)
- (i64.select
+ (select
(get_local $$4)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$73)
(i64.const 0)
(get_local $$161)
)
- (i64.select
+ (select
(get_local $$8)
- (i64.select
+ (select
(i64.or
(get_local $$70)
(get_local $$71)
@@ -3744,7 +3744,7 @@
)
)
)
- (i64.select
+ (select
(get_local $$74)
(i64.const 0)
(get_local $$164)
@@ -3754,10 +3754,10 @@
(get_local $$153)
)
)
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$4)
- (i64.select
+ (select
(i64.or
(get_local $$76)
(get_local $$75)
@@ -3780,14 +3780,14 @@
(get_local $$0)
(i32.const 80)
)
- (i64.select
+ (select
(get_local $$11)
- (i64.select
+ (select
(i64.or
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$11)
- (i64.select
+ (select
(i64.or
(get_local $$56)
(get_local $$57)
@@ -3800,18 +3800,18 @@
(i64.const 0)
(get_local $$167)
)
- (i64.select
+ (select
(get_local $$3)
- (i64.select
+ (select
(i64.or
- (i64.select
+ (select
(get_local $$62)
(i64.const 0)
(get_local $$161)
)
- (i64.select
+ (select
(get_local $$7)
- (i64.select
+ (select
(i64.or
(get_local $$59)
(get_local $$60)
@@ -3822,7 +3822,7 @@
(get_local $$162)
)
)
- (i64.select
+ (select
(get_local $$63)
(i64.const 0)
(get_local $$164)
@@ -3832,10 +3832,10 @@
(get_local $$153)
)
)
- (i64.select
- (i64.select
+ (select
+ (select
(get_local $$3)
- (i64.select
+ (select
(i64.or
(get_local $$65)
(get_local $$64)
diff --git a/test/llvm_autogenerated/select.wast b/test/llvm_autogenerated/select.wast
index 4f61a4e68..55bdba129 100644
--- a/test/llvm_autogenerated/select.wast
+++ b/test/llvm_autogenerated/select.wast
@@ -14,7 +14,7 @@
(export "select_f64_ne" $select_f64_ne)
(func $select_i32_bool (param $$0 i32) (param $$1 i32) (param $$2 i32) (result i32)
(return
- (i32.select
+ (select
(get_local $$1)
(get_local $$2)
(get_local $$0)
@@ -23,7 +23,7 @@
)
(func $select_i32_eq (param $$0 i32) (param $$1 i32) (param $$2 i32) (result i32)
(return
- (i32.select
+ (select
(get_local $$2)
(get_local $$1)
(get_local $$0)
@@ -32,7 +32,7 @@
)
(func $select_i32_ne (param $$0 i32) (param $$1 i32) (param $$2 i32) (result i32)
(return
- (i32.select
+ (select
(get_local $$1)
(get_local $$2)
(get_local $$0)
@@ -41,7 +41,7 @@
)
(func $select_i64_bool (param $$0 i32) (param $$1 i64) (param $$2 i64) (result i64)
(return
- (i64.select
+ (select
(get_local $$1)
(get_local $$2)
(get_local $$0)
@@ -50,7 +50,7 @@
)
(func $select_i64_eq (param $$0 i32) (param $$1 i64) (param $$2 i64) (result i64)
(return
- (i64.select
+ (select
(get_local $$2)
(get_local $$1)
(get_local $$0)
@@ -59,7 +59,7 @@
)
(func $select_i64_ne (param $$0 i32) (param $$1 i64) (param $$2 i64) (result i64)
(return
- (i64.select
+ (select
(get_local $$1)
(get_local $$2)
(get_local $$0)
@@ -68,7 +68,7 @@
)
(func $select_f32_bool (param $$0 i32) (param $$1 f32) (param $$2 f32) (result f32)
(return
- (f32.select
+ (select
(get_local $$1)
(get_local $$2)
(get_local $$0)
@@ -77,7 +77,7 @@
)
(func $select_f32_eq (param $$0 i32) (param $$1 f32) (param $$2 f32) (result f32)
(return
- (f32.select
+ (select
(get_local $$2)
(get_local $$1)
(get_local $$0)
@@ -86,7 +86,7 @@
)
(func $select_f32_ne (param $$0 i32) (param $$1 f32) (param $$2 f32) (result f32)
(return
- (f32.select
+ (select
(get_local $$1)
(get_local $$2)
(get_local $$0)
@@ -95,7 +95,7 @@
)
(func $select_f64_bool (param $$0 i32) (param $$1 f64) (param $$2 f64) (result f64)
(return
- (f64.select
+ (select
(get_local $$1)
(get_local $$2)
(get_local $$0)
@@ -104,7 +104,7 @@
)
(func $select_f64_eq (param $$0 i32) (param $$1 f64) (param $$2 f64) (result f64)
(return
- (f64.select
+ (select
(get_local $$2)
(get_local $$1)
(get_local $$0)
@@ -113,7 +113,7 @@
)
(func $select_f64_ne (param $$0 i32) (param $$1 f64) (param $$2 f64) (result f64)
(return
- (f64.select
+ (select
(get_local $$1)
(get_local $$2)
(get_local $$0)
diff --git a/test/spec b/test/spec
-Subproject 86fdbcf887b12463c488d9c10f2011f7066db74
+Subproject 5a1bb1b3cefdf831c68b7674675fad95d00db5a
diff --git a/test/unit.fromasm b/test/unit.fromasm
index 4d2b54a96..83376be39 100644
--- a/test/unit.fromasm
+++ b/test/unit.fromasm
@@ -296,7 +296,7 @@
(set_local $asm2wasm_i32_temp
(i32.const 0)
)
- (i32.select
+ (select
(i32.sub
(i32.const 0)
(get_local $asm2wasm_i32_temp)
diff --git a/test/unit.wast b/test/unit.wast
index deb553ad3..2ac3d7ebd 100644
--- a/test/unit.wast
+++ b/test/unit.wast
@@ -310,7 +310,7 @@
(set_local $asm2wasm_i32_temp
(i32.const 0)
)
- (i32.select
+ (select
(i32.sub
(i32.const 0)
(get_local $asm2wasm_i32_temp)
diff --git a/test/unit.wast.fromBinary b/test/unit.wast.fromBinary
index d5aee6f8d..0e6a6d769 100644
--- a/test/unit.wast.fromBinary
+++ b/test/unit.wast.fromBinary
@@ -313,7 +313,7 @@
(set_local $var$1
(i32.const 0)
)
- (i32.select
+ (select
(i32.sub
(i32.const 0)
(get_local $var$1)