summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2019-01-07 13:24:58 -0800
committerGitHub <noreply@github.com>2019-01-07 13:24:58 -0800
commit7d94900ded8e2e5ce8ef8ee2687528531d8f2a97 (patch)
treed8bba13d306b0c5ecba384384e602e6cccc83015 /src
parent6f91af190effd7b8a5969314dd4fb3d2ec540524 (diff)
downloadbinaryen-7d94900ded8e2e5ce8ef8ee2687528531d8f2a97.tar.gz
binaryen-7d94900ded8e2e5ce8ef8ee2687528531d8f2a97.tar.bz2
binaryen-7d94900ded8e2e5ce8ef8ee2687528531d8f2a97.zip
Massive renaming (#1855)
Automated renaming according to https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329.
Diffstat (limited to 'src')
-rw-r--r--src/abi/stack.h2
-rw-r--r--src/asm2wasm.h2
-rw-r--r--src/dataflow/graph.h6
-rw-r--r--src/gen-s-parser.inc365
-rw-r--r--src/ir/ExpressionAnalyzer.cpp2
-rw-r--r--src/ir/LocalGraph.cpp6
-rw-r--r--src/ir/local-graph.h4
-rw-r--r--src/ir/properties.h2
-rw-r--r--src/js/binaryen.js-post.js40
-rw-r--r--src/passes/CodePushing.cpp4
-rw-r--r--src/passes/ConstHoisting.cpp4
-rw-r--r--src/passes/DataFlowOpts.cpp4
-rw-r--r--src/passes/Flatten.cpp14
-rw-r--r--src/passes/Inlining.cpp4
-rw-r--r--src/passes/InstrumentLocals.cpp8
-rw-r--r--src/passes/LocalCSE.cpp4
-rw-r--r--src/passes/MergeLocals.cpp20
-rw-r--r--src/passes/OptimizeInstructions.cpp2
-rw-r--r--src/passes/Precompute.cpp6
-rw-r--r--src/passes/Print.cpp103
-rw-r--r--src/passes/RedundantSetElimination.cpp4
-rw-r--r--src/passes/RemoveUnusedBrs.cpp20
-rw-r--r--src/passes/SimplifyLocals.cpp56
-rw-r--r--src/passes/Souperify.cpp2
-rw-r--r--src/passes/StackIR.cpp6
-rw-r--r--src/passes/Untee.cpp2
-rw-r--r--src/passes/pass.cpp4
-rw-r--r--src/passes/wasm-intrinsics.wast516
-rw-r--r--src/shared-constants.h2
-rw-r--r--src/tools/wasm-ctor-eval.cpp2
-rw-r--r--src/tools/wasm-merge.cpp2
-rw-r--r--src/wasm-emscripten.h2
-rw-r--r--src/wasm/wasm-binary.cpp8
-rw-r--r--src/wasm/wasm-s-parser.cpp10
-rw-r--r--src/wasm/wasm-validator.cpp20
-rw-r--r--src/wasm/wasm.cpp10
36 files changed, 641 insertions, 627 deletions
diff --git a/src/abi/stack.h b/src/abi/stack.h
index e43be07ec..77e166c2a 100644
--- a/src/abi/stack.h
+++ b/src/abi/stack.h
@@ -39,7 +39,7 @@ inline Index stackAlign(Index size) {
// Allocate some space on the stack, and assign it to a local.
// The local will have the same constant value in all the function, so you can just
-// get_local it anywhere there.
+// local.get it anywhere there.
inline void getStackSpace(Index local, Function* func, Index size, Module& wasm) {
auto* stackPointer = GlobalUtils::getGlobalInitializedToImport(wasm, ENV, "STACKTOP");
if (!stackPointer) {
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index edd54f06d..d958c4b6a 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -1684,7 +1684,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
Fatal() << "error: access of a non-existent global var " << name.str;
}
auto* ret = builder.makeSetGlobal(name, process(assign->value()));
- // set_global does not return; if our value is trivially not used, don't emit a load (if nontrivially not used, opts get it later)
+ // global.set does not return; if our value is trivially not used, don't emit a load (if nontrivially not used, opts get it later)
auto parent = astStackHelper.getParent();
if (!parent || parent->isArray(BLOCK) || parent->isArray(IF)) return ret;
return builder.makeSequence(ret, builder.makeGetGlobal(name, ret->value->type));
diff --git a/src/dataflow/graph.h b/src/dataflow/graph.h
index 9a30b7576..85b37b7b0 100644
--- a/src/dataflow/graph.h
+++ b/src/dataflow/graph.h
@@ -40,7 +40,7 @@ namespace DataFlow {
// contains the DataFlow IR for that expression, which can be a
// Bad node if not supported, or nullptr if not relevant (we only
// use the return value for internal expressions, that is, the
-// value of a set_local or the condition of an if etc).
+// value of a local.set or the condition of an if etc).
struct Graph : public UnifiedExpressionVisitor<Graph, Node*> {
// We only need one canonical bad node. It is never modified.
Node bad = Node(Node::Type::Bad);
@@ -699,7 +699,7 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> {
return node;
}
- // Given a node representing something that is set_local'd, return
+ // Given a node representing something that is local.set'd, return
// the set.
SetLocal* getSet(Node* node) {
auto iter = nodeParentMap.find(node);
@@ -721,7 +721,7 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> {
}
// Creates an expression that uses a node. Generally, a node represents
- // a value in a local, so we create a get_local for it.
+ // a value in a local, so we create a local.get for it.
Expression* makeUse(Node* node) {
Builder builder(*module);
if (node->isPhi()) {
diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc
index 77e505260..6db1d7a2c 100644
--- a/src/gen-s-parser.inc
+++ b/src/gen-s-parser.inc
@@ -87,25 +87,25 @@ switch (op[0]) {
if (strcmp(op, "f32.const") == 0) return makeConst(s, f32);
goto parse_error;
case 'v': {
- switch (op[12]) {
- case 's': {
- switch (op[15]) {
- case '3':
- if (strcmp(op, "f32.convert_s/i32") == 0) return makeUnary(s, UnaryOp::ConvertSInt32ToFloat32);
+ switch (op[13]) {
+ case '3': {
+ switch (op[16]) {
+ case 's':
+ if (strcmp(op, "f32.convert_i32_s") == 0) return makeUnary(s, UnaryOp::ConvertSInt32ToFloat32);
goto parse_error;
- case '6':
- if (strcmp(op, "f32.convert_s/i64") == 0) return makeUnary(s, UnaryOp::ConvertSInt64ToFloat32);
+ case 'u':
+ if (strcmp(op, "f32.convert_i32_u") == 0) return makeUnary(s, UnaryOp::ConvertUInt32ToFloat32);
goto parse_error;
default: goto parse_error;
}
}
- case 'u': {
- switch (op[15]) {
- case '3':
- if (strcmp(op, "f32.convert_u/i32") == 0) return makeUnary(s, UnaryOp::ConvertUInt32ToFloat32);
+ case '6': {
+ switch (op[16]) {
+ case 's':
+ if (strcmp(op, "f32.convert_i64_s") == 0) return makeUnary(s, UnaryOp::ConvertSInt64ToFloat32);
goto parse_error;
- case '6':
- if (strcmp(op, "f32.convert_u/i64") == 0) return makeUnary(s, UnaryOp::ConvertUInt64ToFloat32);
+ case 'u':
+ if (strcmp(op, "f32.convert_i64_u") == 0) return makeUnary(s, UnaryOp::ConvertUInt64ToFloat32);
goto parse_error;
default: goto parse_error;
}
@@ -128,7 +128,7 @@ switch (op[0]) {
case 'd': {
switch (op[5]) {
case 'e':
- if (strcmp(op, "f32.demote/f64") == 0) return makeUnary(s, UnaryOp::DemoteFloat64);
+ if (strcmp(op, "f32.demote_f64") == 0) return makeUnary(s, UnaryOp::DemoteFloat64);
goto parse_error;
case 'i':
if (strcmp(op, "f32.div") == 0) return makeBinary(s, BinaryOp::DivFloat32);
@@ -196,7 +196,7 @@ switch (op[0]) {
}
}
case 'r':
- if (strcmp(op, "f32.reinterpret/i32") == 0) return makeUnary(s, UnaryOp::ReinterpretInt32);
+ if (strcmp(op, "f32.reinterpret_i32") == 0) return makeUnary(s, UnaryOp::ReinterpretInt32);
goto parse_error;
case 's': {
switch (op[5]) {
@@ -232,12 +232,12 @@ switch (op[0]) {
}
}
case 'c': {
- switch (op[14]) {
+ switch (op[20]) {
case 's':
- if (strcmp(op, "f32x4.convert_s/i32x4") == 0) return makeUnary(s, UnaryOp::ConvertSVecI32x4ToVecF32x4);
+ if (strcmp(op, "f32x4.convert_i32x4_s") == 0) return makeUnary(s, UnaryOp::ConvertSVecI32x4ToVecF32x4);
goto parse_error;
case 'u':
- if (strcmp(op, "f32x4.convert_u/i32x4") == 0) return makeUnary(s, UnaryOp::ConvertUVecI32x4ToVecF32x4);
+ if (strcmp(op, "f32x4.convert_i32x4_u") == 0) return makeUnary(s, UnaryOp::ConvertUVecI32x4ToVecF32x4);
goto parse_error;
default: goto parse_error;
}
@@ -354,25 +354,25 @@ switch (op[0]) {
if (strcmp(op, "f64.const") == 0) return makeConst(s, f64);
goto parse_error;
case 'v': {
- switch (op[12]) {
- case 's': {
- switch (op[15]) {
- case '3':
- if (strcmp(op, "f64.convert_s/i32") == 0) return makeUnary(s, UnaryOp::ConvertSInt32ToFloat64);
+ switch (op[13]) {
+ case '3': {
+ switch (op[16]) {
+ case 's':
+ if (strcmp(op, "f64.convert_i32_s") == 0) return makeUnary(s, UnaryOp::ConvertSInt32ToFloat64);
goto parse_error;
- case '6':
- if (strcmp(op, "f64.convert_s/i64") == 0) return makeUnary(s, UnaryOp::ConvertSInt64ToFloat64);
+ case 'u':
+ if (strcmp(op, "f64.convert_i32_u") == 0) return makeUnary(s, UnaryOp::ConvertUInt32ToFloat64);
goto parse_error;
default: goto parse_error;
}
}
- case 'u': {
- switch (op[15]) {
- case '3':
- if (strcmp(op, "f64.convert_u/i32") == 0) return makeUnary(s, UnaryOp::ConvertUInt32ToFloat64);
+ case '6': {
+ switch (op[16]) {
+ case 's':
+ if (strcmp(op, "f64.convert_i64_s") == 0) return makeUnary(s, UnaryOp::ConvertSInt64ToFloat64);
goto parse_error;
- case '6':
- if (strcmp(op, "f64.convert_u/i64") == 0) return makeUnary(s, UnaryOp::ConvertUInt64ToFloat64);
+ case 'u':
+ if (strcmp(op, "f64.convert_i64_u") == 0) return makeUnary(s, UnaryOp::ConvertUInt64ToFloat64);
goto parse_error;
default: goto parse_error;
}
@@ -455,10 +455,10 @@ switch (op[0]) {
}
}
case 'p':
- if (strcmp(op, "f64.promote/f32") == 0) return makeUnary(s, UnaryOp::PromoteFloat32);
+ if (strcmp(op, "f64.promote_f32") == 0) return makeUnary(s, UnaryOp::PromoteFloat32);
goto parse_error;
case 'r':
- if (strcmp(op, "f64.reinterpret/i64") == 0) return makeUnary(s, UnaryOp::ReinterpretInt64);
+ if (strcmp(op, "f64.reinterpret_i64") == 0) return makeUnary(s, UnaryOp::ReinterpretInt64);
goto parse_error;
case 's': {
switch (op[5]) {
@@ -494,12 +494,12 @@ switch (op[0]) {
}
}
case 'c': {
- switch (op[14]) {
+ switch (op[20]) {
case 's':
- if (strcmp(op, "f64x2.convert_s/i64x2") == 0) return makeUnary(s, UnaryOp::ConvertSVecI64x2ToVecF64x2);
+ if (strcmp(op, "f64x2.convert_i64x2_s") == 0) return makeUnary(s, UnaryOp::ConvertSVecI64x2ToVecF64x2);
goto parse_error;
case 'u':
- if (strcmp(op, "f64x2.convert_u/i64x2") == 0) return makeUnary(s, UnaryOp::ConvertUVecI64x2ToVecF64x2);
+ if (strcmp(op, "f64x2.convert_i64x2_u") == 0) return makeUnary(s, UnaryOp::ConvertUVecI64x2ToVecF64x2);
goto parse_error;
default: goto parse_error;
}
@@ -593,13 +593,13 @@ switch (op[0]) {
}
case 'g': {
switch (op[1]) {
- case 'e': {
- switch (op[4]) {
+ case 'l': {
+ switch (op[7]) {
case 'g':
- if (strcmp(op, "get_global") == 0) return makeGetGlobal(s);
+ if (strcmp(op, "global.get") == 0) return makeGetGlobal(s);
goto parse_error;
- case 'l':
- if (strcmp(op, "get_local") == 0) return makeGetLocal(s);
+ case 's':
+ if (strcmp(op, "global.set") == 0) return makeSetGlobal(s);
goto parse_error;
default: goto parse_error;
}
@@ -850,34 +850,34 @@ switch (op[0]) {
}
}
case '1': {
- switch (op[19]) {
+ switch (op[17]) {
case 'a': {
- switch (op[20]) {
+ switch (op[18]) {
case 'd':
- if (strcmp(op, "i32.atomic.rmw16_u.add") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
+ if (strcmp(op, "i32.atomic.rmw16.add_u") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
goto parse_error;
case 'n':
- if (strcmp(op, "i32.atomic.rmw16_u.and") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
+ if (strcmp(op, "i32.atomic.rmw16.and_u") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
goto parse_error;
default: goto parse_error;
}
}
case 'c':
- if (strcmp(op, "i32.atomic.rmw16_u.cmpxchg") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
+ if (strcmp(op, "i32.atomic.rmw16.cmpxchg_u") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
goto parse_error;
case 'o':
- if (strcmp(op, "i32.atomic.rmw16_u.or") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
+ if (strcmp(op, "i32.atomic.rmw16.or_u") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
goto parse_error;
case 's':
- if (strcmp(op, "i32.atomic.rmw16_u.sub") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
+ if (strcmp(op, "i32.atomic.rmw16.sub_u") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
goto parse_error;
case 'x': {
- switch (op[20]) {
+ switch (op[18]) {
case 'c':
- if (strcmp(op, "i32.atomic.rmw16_u.xchg") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
+ if (strcmp(op, "i32.atomic.rmw16.xchg_u") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
goto parse_error;
case 'o':
- if (strcmp(op, "i32.atomic.rmw16_u.xor") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
+ if (strcmp(op, "i32.atomic.rmw16.xor_u") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
goto parse_error;
default: goto parse_error;
}
@@ -886,34 +886,34 @@ switch (op[0]) {
}
}
case '8': {
- switch (op[18]) {
+ switch (op[16]) {
case 'a': {
- switch (op[19]) {
+ switch (op[17]) {
case 'd':
- if (strcmp(op, "i32.atomic.rmw8_u.add") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
+ if (strcmp(op, "i32.atomic.rmw8.add_u") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
goto parse_error;
case 'n':
- if (strcmp(op, "i32.atomic.rmw8_u.and") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
+ if (strcmp(op, "i32.atomic.rmw8.and_u") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
goto parse_error;
default: goto parse_error;
}
}
case 'c':
- if (strcmp(op, "i32.atomic.rmw8_u.cmpxchg") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
+ if (strcmp(op, "i32.atomic.rmw8.cmpxchg_u") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
goto parse_error;
case 'o':
- if (strcmp(op, "i32.atomic.rmw8_u.or") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
+ if (strcmp(op, "i32.atomic.rmw8.or_u") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
goto parse_error;
case 's':
- if (strcmp(op, "i32.atomic.rmw8_u.sub") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
+ if (strcmp(op, "i32.atomic.rmw8.sub_u") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
goto parse_error;
case 'x': {
- switch (op[19]) {
+ switch (op[17]) {
case 'c':
- if (strcmp(op, "i32.atomic.rmw8_u.xchg") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
+ if (strcmp(op, "i32.atomic.rmw8.xchg_u") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
goto parse_error;
case 'o':
- if (strcmp(op, "i32.atomic.rmw8_u.xor") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
+ if (strcmp(op, "i32.atomic.rmw8.xor_u") == 0) return makeAtomicRMWOrCmpxchg(s, i32);
goto parse_error;
default: goto parse_error;
}
@@ -1097,7 +1097,7 @@ switch (op[0]) {
case 'e': {
switch (op[6]) {
case 'i':
- if (strcmp(op, "i32.reinterpret/f32") == 0) return makeUnary(s, UnaryOp::ReinterpretFloat32);
+ if (strcmp(op, "i32.reinterpret_f32") == 0) return makeUnary(s, UnaryOp::ReinterpretFloat32);
goto parse_error;
case 'm': {
switch (op[8]) {
@@ -1170,26 +1170,26 @@ switch (op[0]) {
}
case 't': {
switch (op[10]) {
- case 's': {
+ case 'f': {
switch (op[11]) {
- case '/': {
- switch (op[13]) {
- case '3':
- if (strcmp(op, "i32.trunc_s/f32") == 0) return makeUnary(s, UnaryOp::TruncSFloat32ToInt32);
+ case '3': {
+ switch (op[14]) {
+ case 's':
+ if (strcmp(op, "i32.trunc_f32_s") == 0) return makeUnary(s, UnaryOp::TruncSFloat32ToInt32);
goto parse_error;
- case '6':
- if (strcmp(op, "i32.trunc_s/f64") == 0) return makeUnary(s, UnaryOp::TruncSFloat64ToInt32);
+ case 'u':
+ if (strcmp(op, "i32.trunc_f32_u") == 0) return makeUnary(s, UnaryOp::TruncUFloat32ToInt32);
goto parse_error;
default: goto parse_error;
}
}
- case ':': {
- switch (op[17]) {
- case '3':
- if (strcmp(op, "i32.trunc_s:sat/f32") == 0) return makeUnary(s, UnaryOp::TruncSatSFloat32ToInt32);
+ case '6': {
+ switch (op[14]) {
+ case 's':
+ if (strcmp(op, "i32.trunc_f64_s") == 0) return makeUnary(s, UnaryOp::TruncSFloat64ToInt32);
goto parse_error;
- case '6':
- if (strcmp(op, "i32.trunc_s:sat/f64") == 0) return makeUnary(s, UnaryOp::TruncSatSFloat64ToInt32);
+ case 'u':
+ if (strcmp(op, "i32.trunc_f64_u") == 0) return makeUnary(s, UnaryOp::TruncUFloat64ToInt32);
goto parse_error;
default: goto parse_error;
}
@@ -1197,26 +1197,26 @@ switch (op[0]) {
default: goto parse_error;
}
}
- case 'u': {
- switch (op[11]) {
- case '/': {
- switch (op[13]) {
- case '3':
- if (strcmp(op, "i32.trunc_u/f32") == 0) return makeUnary(s, UnaryOp::TruncUFloat32ToInt32);
+ case 's': {
+ switch (op[15]) {
+ case '3': {
+ switch (op[18]) {
+ case 's':
+ if (strcmp(op, "i32.trunc_sat_f32_s") == 0) return makeUnary(s, UnaryOp::TruncSatSFloat32ToInt32);
goto parse_error;
- case '6':
- if (strcmp(op, "i32.trunc_u/f64") == 0) return makeUnary(s, UnaryOp::TruncUFloat64ToInt32);
+ case 'u':
+ if (strcmp(op, "i32.trunc_sat_f32_u") == 0) return makeUnary(s, UnaryOp::TruncSatUFloat32ToInt32);
goto parse_error;
default: goto parse_error;
}
}
- case ':': {
- switch (op[17]) {
- case '3':
- if (strcmp(op, "i32.trunc_u:sat/f32") == 0) return makeUnary(s, UnaryOp::TruncSatUFloat32ToInt32);
+ case '6': {
+ switch (op[18]) {
+ case 's':
+ if (strcmp(op, "i32.trunc_sat_f64_s") == 0) return makeUnary(s, UnaryOp::TruncSatSFloat64ToInt32);
goto parse_error;
- case '6':
- if (strcmp(op, "i32.trunc_u:sat/f64") == 0) return makeUnary(s, UnaryOp::TruncSatUFloat64ToInt32);
+ case 'u':
+ if (strcmp(op, "i32.trunc_sat_f64_u") == 0) return makeUnary(s, UnaryOp::TruncSatUFloat64ToInt32);
goto parse_error;
default: goto parse_error;
}
@@ -1233,7 +1233,7 @@ switch (op[0]) {
if (strcmp(op, "i32.wait") == 0) return makeAtomicWait(s, i32);
goto parse_error;
case 'r':
- if (strcmp(op, "i32.wrap/i64") == 0) return makeUnary(s, UnaryOp::WrapInt64);
+ if (strcmp(op, "i32.wrap_i64") == 0) return makeUnary(s, UnaryOp::WrapInt64);
goto parse_error;
default: goto parse_error;
}
@@ -1373,12 +1373,12 @@ switch (op[0]) {
}
}
case 't': {
- switch (op[12]) {
+ switch (op[22]) {
case 's':
- if (strcmp(op, "i32x4.trunc_s/f32x4:sat") == 0) return makeUnary(s, UnaryOp::TruncSatSVecF32x4ToVecI32x4);
+ if (strcmp(op, "i32x4.trunc_sat_f32x4_s") == 0) return makeUnary(s, UnaryOp::TruncSatSVecF32x4ToVecI32x4);
goto parse_error;
case 'u':
- if (strcmp(op, "i32x4.trunc_u/f32x4:sat") == 0) return makeUnary(s, UnaryOp::TruncSatUVecF32x4ToVecI32x4);
+ if (strcmp(op, "i32x4.trunc_sat_f32x4_u") == 0) return makeUnary(s, UnaryOp::TruncSatUVecF32x4ToVecI32x4);
goto parse_error;
default: goto parse_error;
}
@@ -1459,34 +1459,34 @@ switch (op[0]) {
}
}
case '1': {
- switch (op[19]) {
+ switch (op[17]) {
case 'a': {
- switch (op[20]) {
+ switch (op[18]) {
case 'd':
- if (strcmp(op, "i64.atomic.rmw16_u.add") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw16.add_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 'n':
- if (strcmp(op, "i64.atomic.rmw16_u.and") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw16.and_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
default: goto parse_error;
}
}
case 'c':
- if (strcmp(op, "i64.atomic.rmw16_u.cmpxchg") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw16.cmpxchg_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 'o':
- if (strcmp(op, "i64.atomic.rmw16_u.or") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw16.or_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 's':
- if (strcmp(op, "i64.atomic.rmw16_u.sub") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw16.sub_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 'x': {
- switch (op[20]) {
+ switch (op[18]) {
case 'c':
- if (strcmp(op, "i64.atomic.rmw16_u.xchg") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw16.xchg_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 'o':
- if (strcmp(op, "i64.atomic.rmw16_u.xor") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw16.xor_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
default: goto parse_error;
}
@@ -1495,34 +1495,34 @@ switch (op[0]) {
}
}
case '3': {
- switch (op[19]) {
+ switch (op[17]) {
case 'a': {
- switch (op[20]) {
+ switch (op[18]) {
case 'd':
- if (strcmp(op, "i64.atomic.rmw32_u.add") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw32.add_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 'n':
- if (strcmp(op, "i64.atomic.rmw32_u.and") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw32.and_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
default: goto parse_error;
}
}
case 'c':
- if (strcmp(op, "i64.atomic.rmw32_u.cmpxchg") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw32.cmpxchg_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 'o':
- if (strcmp(op, "i64.atomic.rmw32_u.or") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw32.or_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 's':
- if (strcmp(op, "i64.atomic.rmw32_u.sub") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw32.sub_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 'x': {
- switch (op[20]) {
+ switch (op[18]) {
case 'c':
- if (strcmp(op, "i64.atomic.rmw32_u.xchg") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw32.xchg_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 'o':
- if (strcmp(op, "i64.atomic.rmw32_u.xor") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw32.xor_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
default: goto parse_error;
}
@@ -1531,34 +1531,34 @@ switch (op[0]) {
}
}
case '8': {
- switch (op[18]) {
+ switch (op[16]) {
case 'a': {
- switch (op[19]) {
+ switch (op[17]) {
case 'd':
- if (strcmp(op, "i64.atomic.rmw8_u.add") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw8.add_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 'n':
- if (strcmp(op, "i64.atomic.rmw8_u.and") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw8.and_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
default: goto parse_error;
}
}
case 'c':
- if (strcmp(op, "i64.atomic.rmw8_u.cmpxchg") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw8.cmpxchg_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 'o':
- if (strcmp(op, "i64.atomic.rmw8_u.or") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw8.or_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 's':
- if (strcmp(op, "i64.atomic.rmw8_u.sub") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw8.sub_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 'x': {
- switch (op[19]) {
+ switch (op[17]) {
case 'c':
- if (strcmp(op, "i64.atomic.rmw8_u.xchg") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw8.xchg_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
case 'o':
- if (strcmp(op, "i64.atomic.rmw8_u.xor") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
+ if (strcmp(op, "i64.atomic.rmw8.xor_u") == 0) return makeAtomicRMWOrCmpxchg(s, i64);
goto parse_error;
default: goto parse_error;
}
@@ -1642,12 +1642,12 @@ switch (op[0]) {
if (strcmp(op, "i64.extend8_s") == 0) return makeUnary(s, UnaryOp::ExtendS8Int64);
goto parse_error;
case '_': {
- switch (op[11]) {
+ switch (op[15]) {
case 's':
- if (strcmp(op, "i64.extend_s/i32") == 0) return makeUnary(s, UnaryOp::ExtendSInt32);
+ if (strcmp(op, "i64.extend_i32_s") == 0) return makeUnary(s, UnaryOp::ExtendSInt32);
goto parse_error;
case 'u':
- if (strcmp(op, "i64.extend_u/i32") == 0) return makeUnary(s, UnaryOp::ExtendUInt32);
+ if (strcmp(op, "i64.extend_i32_u") == 0) return makeUnary(s, UnaryOp::ExtendUInt32);
goto parse_error;
default: goto parse_error;
}
@@ -1770,7 +1770,7 @@ switch (op[0]) {
case 'e': {
switch (op[6]) {
case 'i':
- if (strcmp(op, "i64.reinterpret/f64") == 0) return makeUnary(s, UnaryOp::ReinterpretFloat64);
+ if (strcmp(op, "i64.reinterpret_f64") == 0) return makeUnary(s, UnaryOp::ReinterpretFloat64);
goto parse_error;
case 'm': {
switch (op[8]) {
@@ -1846,26 +1846,26 @@ switch (op[0]) {
}
case 't': {
switch (op[10]) {
- case 's': {
+ case 'f': {
switch (op[11]) {
- case '/': {
- switch (op[13]) {
- case '3':
- if (strcmp(op, "i64.trunc_s/f32") == 0) return makeUnary(s, UnaryOp::TruncSFloat32ToInt64);
+ case '3': {
+ switch (op[14]) {
+ case 's':
+ if (strcmp(op, "i64.trunc_f32_s") == 0) return makeUnary(s, UnaryOp::TruncSFloat32ToInt64);
goto parse_error;
- case '6':
- if (strcmp(op, "i64.trunc_s/f64") == 0) return makeUnary(s, UnaryOp::TruncSFloat64ToInt64);
+ case 'u':
+ if (strcmp(op, "i64.trunc_f32_u") == 0) return makeUnary(s, UnaryOp::TruncUFloat32ToInt64);
goto parse_error;
default: goto parse_error;
}
}
- case ':': {
- switch (op[17]) {
- case '3':
- if (strcmp(op, "i64.trunc_s:sat/f32") == 0) return makeUnary(s, UnaryOp::TruncSatSFloat32ToInt64);
+ case '6': {
+ switch (op[14]) {
+ case 's':
+ if (strcmp(op, "i64.trunc_f64_s") == 0) return makeUnary(s, UnaryOp::TruncSFloat64ToInt64);
goto parse_error;
- case '6':
- if (strcmp(op, "i64.trunc_s:sat/f64") == 0) return makeUnary(s, UnaryOp::TruncSatSFloat64ToInt64);
+ case 'u':
+ if (strcmp(op, "i64.trunc_f64_u") == 0) return makeUnary(s, UnaryOp::TruncUFloat64ToInt64);
goto parse_error;
default: goto parse_error;
}
@@ -1873,26 +1873,26 @@ switch (op[0]) {
default: goto parse_error;
}
}
- case 'u': {
- switch (op[11]) {
- case '/': {
- switch (op[13]) {
- case '3':
- if (strcmp(op, "i64.trunc_u/f32") == 0) return makeUnary(s, UnaryOp::TruncUFloat32ToInt64);
+ case 's': {
+ switch (op[15]) {
+ case '3': {
+ switch (op[18]) {
+ case 's':
+ if (strcmp(op, "i64.trunc_sat_f32_s") == 0) return makeUnary(s, UnaryOp::TruncSatSFloat32ToInt64);
goto parse_error;
- case '6':
- if (strcmp(op, "i64.trunc_u/f64") == 0) return makeUnary(s, UnaryOp::TruncUFloat64ToInt64);
+ case 'u':
+ if (strcmp(op, "i64.trunc_sat_f32_u") == 0) return makeUnary(s, UnaryOp::TruncSatUFloat32ToInt64);
goto parse_error;
default: goto parse_error;
}
}
- case ':': {
- switch (op[17]) {
- case '3':
- if (strcmp(op, "i64.trunc_u:sat/f32") == 0) return makeUnary(s, UnaryOp::TruncSatUFloat32ToInt64);
+ case '6': {
+ switch (op[18]) {
+ case 's':
+ if (strcmp(op, "i64.trunc_sat_f64_s") == 0) return makeUnary(s, UnaryOp::TruncSatSFloat64ToInt64);
goto parse_error;
- case '6':
- if (strcmp(op, "i64.trunc_u:sat/f64") == 0) return makeUnary(s, UnaryOp::TruncSatUFloat64ToInt64);
+ case 'u':
+ if (strcmp(op, "i64.trunc_sat_f64_u") == 0) return makeUnary(s, UnaryOp::TruncSatUFloat64ToInt64);
goto parse_error;
default: goto parse_error;
}
@@ -1968,12 +1968,12 @@ switch (op[0]) {
}
}
case 't': {
- switch (op[12]) {
+ switch (op[22]) {
case 's':
- if (strcmp(op, "i64x2.trunc_s/f64x2:sat") == 0) return makeUnary(s, UnaryOp::TruncSatSVecF64x2ToVecI64x2);
+ if (strcmp(op, "i64x2.trunc_sat_f64x2_s") == 0) return makeUnary(s, UnaryOp::TruncSatSVecF64x2ToVecI64x2);
goto parse_error;
case 'u':
- if (strcmp(op, "i64x2.trunc_u/f64x2:sat") == 0) return makeUnary(s, UnaryOp::TruncSatUVecF64x2ToVecI64x2);
+ if (strcmp(op, "i64x2.trunc_sat_f64x2_u") == 0) return makeUnary(s, UnaryOp::TruncSatUVecF64x2ToVecI64x2);
goto parse_error;
default: goto parse_error;
}
@@ -2161,45 +2161,40 @@ switch (op[0]) {
default: goto parse_error;
}
}
- case 'l':
- if (strcmp(op, "loop") == 0) return makeLoop(s);
- goto parse_error;
- case 'n':
- if (strcmp(op, "nop") == 0) return makeNop();
- goto parse_error;
- case 'r':
- if (strcmp(op, "return") == 0) return makeReturn(s);
- goto parse_error;
- case 's': {
+ case 'l': {
switch (op[2]) {
- case 'l':
- if (strcmp(op, "select") == 0) return makeSelect(s);
- goto parse_error;
- case 't': {
- switch (op[4]) {
+ case 'c': {
+ switch (op[6]) {
case 'g':
- if (strcmp(op, "set_global") == 0) return makeSetGlobal(s);
+ if (strcmp(op, "local.get") == 0) return makeGetLocal(s);
goto parse_error;
- case 'l':
- if (strcmp(op, "set_local") == 0) return makeSetLocal(s);
+ case 's':
+ if (strcmp(op, "local.set") == 0) return makeSetLocal(s);
+ goto parse_error;
+ case 't':
+ if (strcmp(op, "local.tee") == 0) return makeTeeLocal(s);
goto parse_error;
default: goto parse_error;
}
}
- default: goto parse_error;
- }
- }
- case 't': {
- switch (op[1]) {
- case 'e':
- if (strcmp(op, "tee_local") == 0) return makeTeeLocal(s);
- goto parse_error;
- case 'h':
- if (strcmp(op, "then") == 0) return makeThenOrElse(s);
+ case 'o':
+ if (strcmp(op, "loop") == 0) return makeLoop(s);
goto parse_error;
default: goto parse_error;
}
}
+ case 'n':
+ if (strcmp(op, "nop") == 0) return makeNop();
+ goto parse_error;
+ case 'r':
+ if (strcmp(op, "return") == 0) return makeReturn(s);
+ goto parse_error;
+ case 's':
+ if (strcmp(op, "select") == 0) return makeSelect(s);
+ goto parse_error;
+ case 't':
+ if (strcmp(op, "then") == 0) return makeThenOrElse(s);
+ goto parse_error;
case 'u':
if (strcmp(op, "unreachable") == 0) return makeUnreachable();
goto parse_error;
diff --git a/src/ir/ExpressionAnalyzer.cpp b/src/ir/ExpressionAnalyzer.cpp
index 6ecfb5517..0efc7b888 100644
--- a/src/ir/ExpressionAnalyzer.cpp
+++ b/src/ir/ExpressionAnalyzer.cpp
@@ -388,7 +388,7 @@ HashType ExpressionAnalyzer::hash(Expression* curr) {
hash(curr->_id);
// we often don't need to hash the type, as it is tied to other values
// we are hashing anyhow, but there are exceptions: for example, a
- // get_local's type is determined by the function, so if we are
+ // local.get's type is determined by the function, so if we are
// hashing only expression fragments, then two from different
// functions may turn out the same even if the type differs. Likewise,
// if we hash between modules, then we need to take int account
diff --git a/src/ir/LocalGraph.cpp b/src/ir/LocalGraph.cpp
index e0105693a..6a99ed44e 100644
--- a/src/ir/LocalGraph.cpp
+++ b/src/ir/LocalGraph.cpp
@@ -28,8 +28,8 @@ namespace LocalGraphInternal {
// Information about a basic block.
struct Info {
- std::vector<Expression*> actions; // actions occurring in this block: get_locals and set_locals
- std::unordered_map<Index, SetLocal*> lastSets; // for each index, the last set_local for it
+ std::vector<Expression*> actions; // actions occurring in this block: local.gets and local.sets
+ std::unordered_map<Index, SetLocal*> lastSets; // for each index, the last local.set for it
};
// flow helper class. flows the gets to their sets
@@ -78,7 +78,7 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> {
size_t lastTraversedIteration;
std::vector<Expression*> actions;
std::vector<FlowBlock*> in;
- // Sor each index, the last set_local for it
+ // Sor each index, the last local.set for it
// The unordered_map from BasicBlock.Info is converted into a vector
// This speeds up search as there are usually few sets in a block, so just scanning
// them linearly is efficient, avoiding hash computations (while in Info,
diff --git a/src/ir/local-graph.h b/src/ir/local-graph.h
index 84be2a4c2..725be0536 100644
--- a/src/ir/local-graph.h
+++ b/src/ir/local-graph.h
@@ -20,7 +20,7 @@
namespace wasm {
//
-// Finds the connections between get_locals and set_locals, creating
+// Finds the connections between local.gets and local.sets, creating
// a graph of those ties. This is useful for "ssa-style" optimization,
// in which you want to know exactly which sets are relevant for a
// a get, so it is as if each get has just one set, logically speaking
@@ -33,7 +33,7 @@ struct LocalGraph {
// the constructor computes getSetses, the sets affecting each get
LocalGraph(Function* func);
- // the set_locals relevant for an index or a get.
+ // the local.sets relevant for an index or a get.
typedef std::set<SetLocal*> Sets;
typedef std::map<GetLocal*, Sets> GetSetses;
diff --git a/src/ir/properties.h b/src/ir/properties.h
index 6848e9481..4afe3e909 100644
--- a/src/ir/properties.h
+++ b/src/ir/properties.h
@@ -146,7 +146,7 @@ inline Index getZeroExtBits(Expression* curr) {
return Bits::getMaskedBits(curr->cast<Binary>()->right->cast<Const>()->value.geti32());
}
-// Returns a falling-through value, that is, it looks through a tee_local
+// Returns a falling-through value, that is, it looks through a local.tee
// and other operations that receive a value and let it flow through them.
inline Expression* getFallthrough(Expression* curr) {
// If the current node is unreachable, there is no value
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index dadc94bd7..aa2e613ce 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -424,21 +424,35 @@ function wrapModule(module, self) {
return Module['_BinaryenCallIndirect'](module, target, i32sToStack(operands), operands.length, strToStack(type));
});
};
- self['getLocal'] = self['get_local'] = function(index, type) {
- return Module['_BinaryenGetLocal'](module, index, type);
- };
- self['setLocal'] = self['set_local'] = self['set_local'] = function(index, value) {
- return Module['_BinaryenSetLocal'](module, index, value);
- };
- self['teeLocal'] = self['tee_local'] = function(index, value) {
- return Module['_BinaryenTeeLocal'](module, index, value);
- };
- self['getGlobal'] = self['get_global'] = function(name, type) {
- return Module['_BinaryenGetGlobal'](module, strToStack(name), type);
+
+ self['local'] = {
+ 'get': function(index, type) {
+ return Module['_BinaryenGetLocal'](module, index, type);
+ },
+ 'set': function(index, value) {
+ return Module['_BinaryenSetLocal'](module, index, value);
+ },
+ 'tee': function(index, value) {
+ return Module['_BinaryenTeeLocal'](module, index, value);
+ }
}
- self['setGlobal'] = self['set_global'] = function(name, value) {
- return Module['_BinaryenSetGlobal'](module, strToStack(name), value);
+
+ self['getLocal'] = self['local']['get'];
+ self['setLocal'] = self['local']['set'];
+ self['teeLocal'] = self['local']['tee'];
+
+ self['global'] = {
+ 'get': function(name, type) {
+ return Module['_BinaryenGetGlobal'](module, strToStack(name), type);
+ },
+ 'set': function(name, value) {
+ return Module['_BinaryenSetGlobal'](module, strToStack(name), value);
+ }
}
+
+ self['getGlobal'] = self['global']['get'];
+ self['setGlobal'] = self['global']['set'];
+
self['currentMemory'] = self['current_memory'] = function() {
return Module['_BinaryenHost'](module, Module['CurrentMemory']);
}
diff --git a/src/passes/CodePushing.cpp b/src/passes/CodePushing.cpp
index fefceb6ec..931df140d 100644
--- a/src/passes/CodePushing.cpp
+++ b/src/passes/CodePushing.cpp
@@ -29,8 +29,8 @@ namespace wasm {
//
// Analyzers some useful local properties: # of sets and gets, and SFA.
//
-// Single First Assignment (SFA) form: the local has a single set_local, is
-// not a parameter, and has no get_locals before the set_local in postorder.
+// Single First Assignment (SFA) form: the local has a single local.set, is
+// not a parameter, and has no local.gets before the local.set in postorder.
// This is a much weaker property than SSA, obviously, but together with
// our implicit dominance properties in the structured AST is quite useful.
//
diff --git a/src/passes/ConstHoisting.cpp b/src/passes/ConstHoisting.cpp
index 77ac5d251..11188a9ba 100644
--- a/src/passes/ConstHoisting.cpp
+++ b/src/passes/ConstHoisting.cpp
@@ -15,7 +15,7 @@
*/
//
-// Hoists repeated constants to a local. A get_local takes 2 bytes
+// Hoists repeated constants to a local. A local.get takes 2 bytes
// in most cases, and if a const is larger than that, it may be
// better to store it to a local, then get it from that local.
//
@@ -108,7 +108,7 @@ private:
// or
// num > (size+2)/(size-2)
auto before = num * size;
- auto after = size + 2 /* set_local */ + (2 /* get_local */ * num);
+ auto after = size + 2 /* local.set */ + (2 /* local.get */ * num);
return after < before;
}
diff --git a/src/passes/DataFlowOpts.cpp b/src/passes/DataFlowOpts.cpp
index e32fcb700..702b3e7f4 100644
--- a/src/passes/DataFlowOpts.cpp
+++ b/src/passes/DataFlowOpts.cpp
@@ -88,7 +88,7 @@ struct DataFlowOpts : public WalkerPass<PostWalker<DataFlowOpts>> {
// then copy the result if it's smaller.
if (node->isPhi() && DataFlow::allInputsIdentical(node)) {
// Note we don't need to check for effects when replacing, as in
- // flattened IR expression children are get_locals or consts.
+ // flattened IR expression children are local.gets or consts.
auto* value = node->getValue(1);
if (value->isConst()) {
replaceAllUsesWith(node, value);
@@ -112,7 +112,7 @@ struct DataFlowOpts : public WalkerPass<PostWalker<DataFlowOpts>> {
//dump(node, std::cout);
auto* expr = node->expr;
// First, note that some of the expression's children may be
- // get_locals that we inferred during SSA analysis as constant.
+ // local.gets that we inferred during SSA analysis as constant.
// We can apply those now.
for (Index i = 0; i < node->values.size(); i++) {
if (node->values[i]->isConst()) {
diff --git a/src/passes/Flatten.cpp b/src/passes/Flatten.cpp
index aa5c1a491..61fc60b2b 100644
--- a/src/passes/Flatten.cpp
+++ b/src/passes/Flatten.cpp
@@ -27,26 +27,26 @@
// )
// =>
// (if (..condition..)
-// (set_local $temp
+// (local.set $temp
// (..if true..)
// )
-// (set_local $temp
+// (local.set $temp
// (..if false..)
// )
// )
// (i32.add
-// (get_local $temp)
+// (local.get $temp)
// (i32.const 1)
// )
//
// Formally, this pass flattens in the precise sense of
// making the AST have these properties:
//
-// 1. The operands of an instruction must be a get_local or a const.
+// 1. The operands of an instruction must be a local.get or a const.
// anything else is written to a local earlier.
// 2. Disallow block, loop, and if return values, i.e., do not use
// control flow to pass around values.
-// 3. Disallow tee_local, setting a local is always done in a set_local
+// 3. Disallow local.tee, setting a local is always done in a local.set
// on a non-nested-expression location.
//
@@ -62,7 +62,7 @@ namespace wasm {
// We use the following algorithm: we maintain a list of "preludes", code
// that runs right before an expression. When we visit an expression we
// must handle it and its preludes. If the expression has side effects,
-// we reduce it to a get_local and add a prelude for that. We then handle
+// we reduce it to a local.get and add a prelude for that. We then handle
// the preludes, by moving them to the parent or handling them directly.
// we can move them to the parent if the parent is not a control flow
// structure. Otherwise, if the parent is a control flow structure, it
@@ -190,7 +190,7 @@ struct Flatten : public WalkerPass<ExpressionStackWalker<Flatten, UnifiedExpress
// special handling
if (auto* set = curr->dynCast<SetLocal>()) {
if (set->isTee()) {
- // we disallow tee_local
+ // we disallow local.tee
if (set->value->type == unreachable) {
replaceCurrent(set->value); // trivial, no set happens
} else {
diff --git a/src/passes/Inlining.cpp b/src/passes/Inlining.cpp
index 35afc5776..f801662e0 100644
--- a/src/passes/Inlining.cpp
+++ b/src/passes/Inlining.cpp
@@ -55,11 +55,11 @@ static const int FLEXIBLE_SIZE_LIMIT = 20;
// smaller than the call instruction itself. 2 is a safe number because
// there is no risk of things like
// (func $reverse (param $x i32) (param $y i32)
-// (call $something (get_local $y) (get_local $x))
+// (call $something (local.get $y) (local.get $x))
// )
// in which case the reversing of the params means we'll possibly need
// a block and a temp local. But that takes at least 3 nodes, and 2 < 3.
-// More generally, with 2 items we may have a get_local, but no way to
+// More generally, with 2 items we may have a local.get, but no way to
// require it to be saved instead of directly consumed.
static const int INLINING_OPTIMIZING_WILL_DECREASE_SIZE_LIMIT = 2;
diff --git a/src/passes/InstrumentLocals.cpp b/src/passes/InstrumentLocals.cpp
index f582004d5..a1835eb64 100644
--- a/src/passes/InstrumentLocals.cpp
+++ b/src/passes/InstrumentLocals.cpp
@@ -20,22 +20,22 @@
// gets:
//
// Before:
-// (get_local $x)
+// (local.get $x)
//
// After:
// (call $get_TYPE
// (i32.const n) // call id
// (i32.const n) // local id
-// (get_local $x)
+// (local.get $x)
// )
//
// sets:
//
// Before:
-// (set_local $x (i32.const 1))
+// (local.set $x (i32.const 1))
//
// After:
-// (set_local $x
+// (local.set $x
// (call $set_TYPE
// (i32.const n) // call id
// (i32.const n) // local id
diff --git a/src/passes/LocalCSE.cpp b/src/passes/LocalCSE.cpp
index 8faa5b47c..32cc97b34 100644
--- a/src/passes/LocalCSE.cpp
+++ b/src/passes/LocalCSE.cpp
@@ -20,7 +20,7 @@
// This requires --flatten to be run before in order to be effective,
// and preserves flatness. The reason flatness is required is that
// this pass assumes everything is stored in a local, and all it does
-// is alter set_locals to do get_locals of an existing value when
+// is alter local.sets to do local.gets of an existing value when
// possible, replacing a recomputing of that value. That design means that
// if there are block and if return values, nested expressions not stored
// to a local, etc., then it can't operate on them (and will just not
@@ -56,7 +56,7 @@ struct LocalCSE : public WalkerPass<LinearExecutionWalker<LocalCSE>> {
// information for an expression we can reuse
struct UsableInfo {
Expression* value; // the value we can reuse
- Index index; // the local we are assigned to, get_local that to reuse us
+ Index index; // the local we are assigned to, local.get that to reuse us
EffectAnalyzer effects;
UsableInfo(Expression* value, Index index, PassOptions& passOptions) : value(value), index(index), effects(passOptions, value) {}
diff --git a/src/passes/MergeLocals.cpp b/src/passes/MergeLocals.cpp
index 8dcaa0cb9..4092e1ea8 100644
--- a/src/passes/MergeLocals.cpp
+++ b/src/passes/MergeLocals.cpp
@@ -22,11 +22,11 @@
// example, in
//
// (if (result i32)
-// (tee_local $x
-// (get_local $y)
+// (local.tee $x
+// (local.get $y)
// )
// (i32.const 100)
-// (get_local $x)
+// (local.get $x)
// )
//
// If that assignment of $y is never used again, everything is fine. But if
@@ -60,13 +60,13 @@ struct MergeLocals : public WalkerPass<PostWalker<MergeLocals, UnifiedExpression
void doWalkFunction(Function* func) {
// first, instrument the graph by modifying each copy
- // (set_local $x
- // (get_local $y)
+ // (local.set $x
+ // (local.get $y)
// )
// to
- // (set_local $x
- // (tee_local $y
- // (get_local $y)
+ // (local.set $x
+ // (local.tee $y
+ // (local.get $y)
// )
// )
// That is, we add a trivial assign of $y. This ensures we
@@ -128,8 +128,8 @@ struct MergeLocals : public WalkerPass<PostWalker<MergeLocals, UnifiedExpression
optimizedToCopy[copy] = trivial;
} else {
// alternatively, we can try to remove the conflict in the opposite way: given
- // (set_local $x
- // (get_local $y)
+ // (local.set $x
+ // (local.get $y)
// )
// we can look for uses of $x that could instead be uses of $y. this extends
// $y's live range, but if it removes the conflict between $x and $y, it may be
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index 181e8285e..7d4735686 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -48,7 +48,7 @@ Name I32_EXPR = "i32.expr",
// returns the maximum amount of bits used in an integer expression
// not extremely precise (doesn't look into add operands, etc.)
// LocalInfoProvider is an optional class that can provide answers about
-// get_local.
+// local.get.
template<typename LocalInfoProvider>
Index getMaxBits(Expression* curr, LocalInfoProvider* localInfoProvider) {
if (auto* const_ = curr->dynCast<Const>()) {
diff --git a/src/passes/Precompute.cpp b/src/passes/Precompute.cpp
index 042a8be20..c23babda4 100644
--- a/src/passes/Precompute.cpp
+++ b/src/passes/Precompute.cpp
@@ -46,7 +46,7 @@ class PrecomputingExpressionRunner : public ExpressionRunner<PrecomputingExpress
GetValues& getValues;
// Whether we are trying to precompute down to an expression (which we can do on
- // say 5 + 6) or to a value (which we can't do on a tee_local that flows a 7
+ // say 5 + 6) or to a value (which we can't do on a local.tee that flows a 7
// through it). When we want to replace the expression, we can only do so
// when it has no side effects. When we don't care about replacing the expression,
// we just want to know if it will contain a known constant.
@@ -159,7 +159,7 @@ struct Precompute : public WalkerPass<PostWalker<Precompute, UnifiedExpressionVi
}
void visitExpression(Expression* curr) {
- // TODO: if get_local, only replace with a constant if we don't care about size...?
+ // TODO: if local.get, only replace with a constant if we don't care about size...?
if (curr->is<Const>() || curr->is<Nop>()) return;
// Until engines implement v128.const and we have SIMD-aware optimizations
// that can break large v128.const instructions into smaller consts and
@@ -245,7 +245,7 @@ private:
// itself. This differs from precomputeExpression in that we care about
// the value the expression will have, which we cannot necessary replace
// the expression with. For example,
- // (tee_local (i32.const 1))
+ // (local.tee (i32.const 1))
// will have value 1 which we can optimize here, but in precomputeExpression
// we could not do anything.
Literal precomputeValue(Expression* curr) {
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 2cfa5092c..e544447fe 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -113,22 +113,22 @@ struct PrintExpressionContents : public Visitor<PrintExpressionContents> {
printMedium(o, "call_indirect (type ") << curr->fullType << ')';
}
void visitGetLocal(GetLocal* curr) {
- printMedium(o, "get_local ") << printableLocal(curr->index, currFunction);
+ printMedium(o, "local.get ") << printableLocal(curr->index, currFunction);
}
void visitSetLocal(SetLocal* curr) {
if (curr->isTee()) {
- printMedium(o, "tee_local ");
+ printMedium(o, "local.tee ");
} else {
- printMedium(o, "set_local ");
+ printMedium(o, "local.set ");
}
o << printableLocal(curr->index, currFunction);
}
void visitGetGlobal(GetGlobal* curr) {
- printMedium(o, "get_global ");
+ printMedium(o, "global.get ");
printName(curr->name, o);
}
void visitSetGlobal(SetGlobal* curr) {
- printMedium(o, "set_global ");
+ printMedium(o, "global.set ");
printName(curr->name, o);
}
void visitLoad(Load* curr) {
@@ -192,7 +192,6 @@ struct PrintExpressionContents : public Visitor<PrintExpressionContents> {
} else {
WASM_UNREACHABLE();
}
- o << "_u";
}
o << '.';
}
@@ -207,6 +206,9 @@ struct PrintExpressionContents : public Visitor<PrintExpressionContents> {
case Xor: o << "xor"; break;
case Xchg: o << "xchg"; break;
}
+ if (curr->bytes != getTypeSize(curr->type)) {
+ o << "_u";
+ }
restoreNormalColor(o);
if (curr->offset) {
o << " offset=" << curr->offset;
@@ -215,7 +217,10 @@ struct PrintExpressionContents : public Visitor<PrintExpressionContents> {
void visitAtomicCmpxchg(AtomicCmpxchg* curr) {
prepareColor(o);
printRMWSize(o, curr->type, curr->bytes);
- o << "cmpxchg";
+ o << "cmpxchg";
+ if (curr->bytes != getTypeSize(curr->type)) {
+ o << "_u";
+ }
restoreNormalColor(o);
if (curr->offset) {
o << " offset=" << curr->offset;
@@ -316,44 +321,44 @@ struct PrintExpressionContents : public Visitor<PrintExpressionContents> {
case TruncFloat64: o << "f64.trunc"; break;
case NearestFloat64: o << "f64.nearest"; break;
case SqrtFloat64: o << "f64.sqrt"; break;
- case ExtendSInt32: o << "i64.extend_s/i32"; break;
- case ExtendUInt32: o << "i64.extend_u/i32"; break;
- case WrapInt64: o << "i32.wrap/i64"; break;
- case TruncSFloat32ToInt32: o << "i32.trunc_s/f32"; break;
- case TruncSFloat32ToInt64: o << "i64.trunc_s/f32"; break;
- case TruncUFloat32ToInt32: o << "i32.trunc_u/f32"; break;
- case TruncUFloat32ToInt64: o << "i64.trunc_u/f32"; break;
- case TruncSFloat64ToInt32: o << "i32.trunc_s/f64"; break;
- case TruncSFloat64ToInt64: o << "i64.trunc_s/f64"; break;
- case TruncUFloat64ToInt32: o << "i32.trunc_u/f64"; break;
- case TruncUFloat64ToInt64: o << "i64.trunc_u/f64"; break;
- case ReinterpretFloat32: o << "i32.reinterpret/f32"; break;
- case ReinterpretFloat64: o << "i64.reinterpret/f64"; break;
- case ConvertUInt32ToFloat32: o << "f32.convert_u/i32"; break;
- case ConvertUInt32ToFloat64: o << "f64.convert_u/i32"; break;
- case ConvertSInt32ToFloat32: o << "f32.convert_s/i32"; break;
- case ConvertSInt32ToFloat64: o << "f64.convert_s/i32"; break;
- case ConvertUInt64ToFloat32: o << "f32.convert_u/i64"; break;
- case ConvertUInt64ToFloat64: o << "f64.convert_u/i64"; break;
- case ConvertSInt64ToFloat32: o << "f32.convert_s/i64"; break;
- case ConvertSInt64ToFloat64: o << "f64.convert_s/i64"; break;
- case PromoteFloat32: o << "f64.promote/f32"; break;
- case DemoteFloat64: o << "f32.demote/f64"; break;
- case ReinterpretInt32: o << "f32.reinterpret/i32"; break;
- case ReinterpretInt64: o << "f64.reinterpret/i64"; break;
+ case ExtendSInt32: o << "i64.extend_i32_s"; break;
+ case ExtendUInt32: o << "i64.extend_i32_u"; break;
+ case WrapInt64: o << "i32.wrap_i64"; break;
+ case TruncSFloat32ToInt32: o << "i32.trunc_f32_s"; break;
+ case TruncSFloat32ToInt64: o << "i64.trunc_f32_s"; break;
+ case TruncUFloat32ToInt32: o << "i32.trunc_f32_u"; break;
+ case TruncUFloat32ToInt64: o << "i64.trunc_f32_u"; break;
+ case TruncSFloat64ToInt32: o << "i32.trunc_f64_s"; break;
+ case TruncSFloat64ToInt64: o << "i64.trunc_f64_s"; break;
+ case TruncUFloat64ToInt32: o << "i32.trunc_f64_u"; break;
+ case TruncUFloat64ToInt64: o << "i64.trunc_f64_u"; break;
+ case ReinterpretFloat32: o << "i32.reinterpret_f32"; break;
+ case ReinterpretFloat64: o << "i64.reinterpret_f64"; break;
+ case ConvertUInt32ToFloat32: o << "f32.convert_i32_u"; break;
+ case ConvertUInt32ToFloat64: o << "f64.convert_i32_u"; break;
+ case ConvertSInt32ToFloat32: o << "f32.convert_i32_s"; break;
+ case ConvertSInt32ToFloat64: o << "f64.convert_i32_s"; break;
+ case ConvertUInt64ToFloat32: o << "f32.convert_i64_u"; break;
+ case ConvertUInt64ToFloat64: o << "f64.convert_i64_u"; break;
+ case ConvertSInt64ToFloat32: o << "f32.convert_i64_s"; break;
+ case ConvertSInt64ToFloat64: o << "f64.convert_i64_s"; break;
+ case PromoteFloat32: o << "f64.promote_f32"; break;
+ case DemoteFloat64: o << "f32.demote_f64"; break;
+ case ReinterpretInt32: o << "f32.reinterpret_i32"; break;
+ case ReinterpretInt64: o << "f64.reinterpret_i64"; break;
case ExtendS8Int32: o << "i32.extend8_s"; break;
case ExtendS16Int32: o << "i32.extend16_s"; break;
case ExtendS8Int64: o << "i64.extend8_s"; break;
case ExtendS16Int64: o << "i64.extend16_s"; break;
case ExtendS32Int64: o << "i64.extend32_s"; break;
- case TruncSatSFloat32ToInt32: o << "i32.trunc_s:sat/f32"; break;
- case TruncSatUFloat32ToInt32: o << "i32.trunc_u:sat/f32"; break;
- case TruncSatSFloat64ToInt32: o << "i32.trunc_s:sat/f64"; break;
- case TruncSatUFloat64ToInt32: o << "i32.trunc_u:sat/f64"; break;
- case TruncSatSFloat32ToInt64: o << "i64.trunc_s:sat/f32"; break;
- case TruncSatUFloat32ToInt64: o << "i64.trunc_u:sat/f32"; break;
- case TruncSatSFloat64ToInt64: o << "i64.trunc_s:sat/f64"; break;
- case TruncSatUFloat64ToInt64: o << "i64.trunc_u:sat/f64"; break;
+ case TruncSatSFloat32ToInt32: o << "i32.trunc_sat_f32_s"; break;
+ case TruncSatUFloat32ToInt32: o << "i32.trunc_sat_f32_u"; break;
+ case TruncSatSFloat64ToInt32: o << "i32.trunc_sat_f64_s"; break;
+ case TruncSatUFloat64ToInt32: o << "i32.trunc_sat_f64_u"; break;
+ case TruncSatSFloat32ToInt64: o << "i64.trunc_sat_f32_s"; break;
+ case TruncSatUFloat32ToInt64: o << "i64.trunc_sat_f32_u"; break;
+ case TruncSatSFloat64ToInt64: o << "i64.trunc_sat_f64_s"; break;
+ case TruncSatUFloat64ToInt64: o << "i64.trunc_sat_f64_u"; break;
case SplatVecI8x16: o << "i8x16.splat"; break;
case SplatVecI16x8: o << "i16x8.splat"; break;
case SplatVecI32x4: o << "i32x4.splat"; break;
@@ -379,14 +384,14 @@ struct PrintExpressionContents : public Visitor<PrintExpressionContents> {
case AbsVecF64x2: o << "f64x2.abs"; break;
case NegVecF64x2: o << "f64x2.neg"; break;
case SqrtVecF64x2: o << "f64x2.sqrt"; break;
- case TruncSatSVecF32x4ToVecI32x4: o << "i32x4.trunc_s/f32x4:sat"; break;
- case TruncSatUVecF32x4ToVecI32x4: o << "i32x4.trunc_u/f32x4:sat"; break;
- case TruncSatSVecF64x2ToVecI64x2: o << "i64x2.trunc_s/f64x2:sat"; break;
- case TruncSatUVecF64x2ToVecI64x2: o << "i64x2.trunc_u/f64x2:sat"; break;
- case ConvertSVecI32x4ToVecF32x4: o << "f32x4.convert_s/i32x4"; break;
- case ConvertUVecI32x4ToVecF32x4: o << "f32x4.convert_u/i32x4"; break;
- case ConvertSVecI64x2ToVecF64x2: o << "f64x2.convert_s/i64x2"; break;
- case ConvertUVecI64x2ToVecF64x2: o << "f64x2.convert_u/i64x2"; break;
+ case TruncSatSVecF32x4ToVecI32x4: o << "i32x4.trunc_sat_f32x4_s"; break;
+ case TruncSatUVecF32x4ToVecI32x4: o << "i32x4.trunc_sat_f32x4_u"; break;
+ case TruncSatSVecF64x2ToVecI64x2: o << "i64x2.trunc_sat_f64x2_s"; break;
+ case TruncSatUVecF64x2ToVecI64x2: o << "i64x2.trunc_sat_f64x2_u"; break;
+ case ConvertSVecI32x4ToVecF32x4: o << "f32x4.convert_i32x4_s"; break;
+ case ConvertUVecI32x4ToVecF32x4: o << "f32x4.convert_i32x4_u"; break;
+ case ConvertSVecI64x2ToVecF64x2: o << "f64x2.convert_i64x2_s"; break;
+ case ConvertUVecI64x2ToVecF64x2: o << "f64x2.convert_i64x2_u"; break;
case InvalidUnary: WASM_UNREACHABLE();
}
}
@@ -1177,7 +1182,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
printName(curr->name, o) << ' ';
o << curr->initial;
if (curr->hasMax()) o << ' ' << curr->max;
- o << " anyfunc)";
+ o << " funcref)";
}
void visitTable(Table* curr) {
if (!curr->exists) return;
diff --git a/src/passes/RedundantSetElimination.cpp b/src/passes/RedundantSetElimination.cpp
index 8cd8fbf99..6f39fce9f 100644
--- a/src/passes/RedundantSetElimination.cpp
+++ b/src/passes/RedundantSetElimination.cpp
@@ -15,7 +15,7 @@
*/
//
-// Eliminate redundant set_locals: if a local already has a particular
+// Eliminate redundant local.sets: if a local already has a particular
// value, we don't need to set it again. A common case here is loops
// that start at zero, since the default value is initialized to
// zero anyhow.
@@ -28,7 +28,7 @@
// values no longer necessary.
//
// So far this tracks constant values, and for everything else it considers
-// them unique (so each set_local of a non-constant is a unique value, each
+// them unique (so each local.set of a non-constant is a unique value, each
// merge is a unique value, etc.; there is no sophisticated value numbering
// here).
//
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp
index 58694b25c..614503581 100644
--- a/src/passes/RemoveUnusedBrs.cpp
+++ b/src/passes/RemoveUnusedBrs.cpp
@@ -292,7 +292,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
}
}
// TODO: if-else can be turned into a br_if as well, if one of the sides is a dead end
- // we handle the case of a returned value to a set_local later down, see
+ // we handle the case of a returned value to a local.set later down, see
// visitSetLocal.
}
@@ -847,7 +847,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
}
// If one arm is a br, we prefer a br_if and the set later:
- // (set_local $x
+ // (local.set $x
// (if (result i32)
// (..condition..)
// (br $somewhere)
@@ -858,7 +858,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
// (br_if $somewhere
// (..condition..)
// )
- // (set_local $x
+ // (local.set $x
// (..result)
// )
// TODO: handle a condition in the br? need to watch for side effects
@@ -900,38 +900,38 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
// we can remove. If this is not a tee, then we remove the get
// as well as the if-else opcode in the binary format, which is
// great:
- // (set_local $x
+ // (local.set $x
// (if (result i32)
// (..condition..)
// (..result)
- // (get_local $x)
+ // (local.get $x)
// )
// )
// =>
// (if
// (..condition..)
- // (set_local $x
+ // (local.set $x
// (..result)
// )
// )
// If this is a tee, then we can do the same operation but
// inside a block, and keep the get:
- // (tee_local $x
+ // (local.tee $x
// (if (result i32)
// (..condition..)
// (..result)
- // (get_local $x)
+ // (local.get $x)
// )
// )
// =>
// (block (result i32)
// (if
// (..condition..)
- // (set_local $x
+ // (local.set $x
// (..result)
// )
// )
- // (get_local $x)
+ // (local.get $x)
// )
// We save the if-else opcode, and add the block's opcodes.
// This may be detrimental, however, often the block can be
diff --git a/src/passes/SimplifyLocals.cpp b/src/passes/SimplifyLocals.cpp
index 75dadfbac..91f0f8d4f 100644
--- a/src/passes/SimplifyLocals.cpp
+++ b/src/passes/SimplifyLocals.cpp
@@ -17,15 +17,15 @@
//
// Locals-related optimizations
//
-// This "sinks" set_locals, pushing them to the next get_local where possible,
+// This "sinks" local.sets, pushing them to the next local.get where possible,
// and removing the set if there are no gets remaining (the latter is
// particularly useful in ssa mode, but not only).
//
-// We also note where set_locals coalesce: if all breaks of a block set
+// We also note where local.sets coalesce: if all breaks of a block set
// a specific local, we can use a block return value for it, in effect
-// removing multiple set_locals and replacing them with one that the
+// removing multiple local.sets and replacing them with one that the
// block returns to. Further optimization rounds then have the opportunity
-// to remove that set_local as well. TODO: support partial traces; right
+// to remove that local.set as well. TODO: support partial traces; right
// now, whenever control flow splits, we invalidate everything.
//
// After this pass, some locals may be completely unused. reorder-locals
@@ -37,7 +37,7 @@
// * Tee: allow teeing, i.e., sinking a local with more than one use,
// and so after sinking we have a tee for the first use.
// * Structure: create block and if return values, by merging the
-// internal set_locals into one on the outside,
+// internal local.sets into one on the outside,
// that can itself then be sunk further.
//
// There is also an option to disallow nesting entirely, which disallows
@@ -67,7 +67,7 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a
Pass* create() override { return new SimplifyLocals<allowTee, allowStructure, allowNesting>(); }
- // information for a set_local we can sink
+ // information for a local.set we can sink
struct SinkableInfo {
Expression** item;
EffectAnalyzer effects;
@@ -109,7 +109,7 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a
// whether this is the first cycle, in which we always disallow teeing
bool firstCycle;
- // local => # of get_locals for it
+ // local => # of local.gets for it
GetLocalCounter getCounter;
static void doNoteNonLinear(SimplifyLocals<allowTee, allowStructure, allowNesting>* self, Expression** currp) {
@@ -373,7 +373,7 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a
blockBreaks.erase(block->name);
if (breaks.size() == 0) return; // block has no branches TODO we might optimize trivial stuff here too
assert(!(*breaks[0].brp)->template cast<Break>()->value); // block does not already have a return value (if one break has one, they all do)
- // look for a set_local that is present in them all
+ // look for a local.set that is present in them all
bool found = false;
Index sharedIndex = -1;
for (auto& sinkable : sinkables) {
@@ -398,19 +398,19 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a
// (br_if
// (block
// ..use $x..
- // (set_local $x ..)
+ // (local.set $x ..)
// )
// )
// =>
// (br_if
- // (tee_local $x ..) ;; this now affects the use!
+ // (local.tee $x ..) ;; this now affects the use!
// (block
// ..use $x..
// )
// )
// so we must check for that.
for (size_t j = 0; j < breaks.size(); j++) {
- // move break set_local's value to the break
+ // move break local.set's value to the break
auto* breakSetLocalPointer = breaks[j].sinkables.at(sharedIndex).item;
auto* brp = breaks[j].brp;
auto* br = (*brp)->template cast<Break>();
@@ -446,14 +446,14 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a
blocksToEnlarge.push_back(block);
return;
}
- // move block set_local's value to the end, in return position, and nop the set
+ // move block local.set's value to the end, in return position, and nop the set
auto* blockSetLocalPointer = sinkables.at(sharedIndex).item;
auto* value = (*blockSetLocalPointer)->template cast<SetLocal>()->value;
block->list[block->list.size() - 1] = value;
block->type = value->type;
ExpressionManipulator::nop(*blockSetLocalPointer);
for (size_t j = 0; j < breaks.size(); j++) {
- // move break set_local's value to the break
+ // move break local.set's value to the break
auto* breakSetLocalPointer = breaks[j].sinkables.at(sharedIndex).item;
auto* brp = breaks[j].brp;
auto* br = (*brp)->template cast<Break>();
@@ -472,14 +472,14 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a
ExpressionManipulator::nop(set);
}
}
- // finally, create a set_local on the block itself
+ // finally, create a local.set on the block itself
auto* newSetLocal = Builder(*this->getModule()).makeSetLocal(sharedIndex, block);
this->replaceCurrent(newSetLocal);
sinkables.clear();
anotherCycle = true;
}
- // optimize set_locals from both sides of an if into a return value
+ // optimize local.sets from both sides of an if into a return value
void optimizeIfElseReturn(If* iff, Expression** currp, Sinkables& ifTrue) {
assert(iff->ifFalse);
// if this if already has a result, or is unreachable code, we have
@@ -491,10 +491,10 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a
// (if
// (..)
// (br $x)
- // (set_local $y (..))
+ // (local.set $y (..))
// )
// =>
- // (set_local $y
+ // (local.set $y
// (if (result i32)
// (..)
// (br $x)
@@ -562,27 +562,27 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a
}
iff->finalize(); // update type
assert(iff->type != none);
- // finally, create a set_local on the iff itself
+ // finally, create a local.set on the iff itself
auto* newSetLocal = Builder(*this->getModule()).makeSetLocal(goodIndex, iff);
*currp = newSetLocal;
anotherCycle = true;
}
- // Optimize set_locals from a one-sided iff, adding a get on the other:
+ // Optimize local.sets from a one-sided iff, adding a get on the other:
// (if
// (..condition..)
// (block
- // (set_local $x (..value..))
+ // (local.set $x (..value..))
// )
// )
// =>
- // (set_local $x
+ // (local.set $x
// (if (result ..)
// (..condition..)
// (block (result ..)
// (..value..)
// )
- // (get_local $x)
+ // (local.get $x)
// )
// )
// This is a speculative optimization: we add a get here, as well as a branch
@@ -617,7 +617,7 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a
// Update the get count.
getCounter.num[set->index]++;
assert(iff->type != none);
- // Finally, reuse the set_local on the iff itself.
+ // Finally, reuse the local.set on the iff itself.
set->value = iff;
set->finalize();
*currp = set;
@@ -648,7 +648,7 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a
}
void doWalkFunction(Function* func) {
- // scan get_locals
+ // scan local.gets
getCounter.analyze(func);
// multiple passes may be required per function, consider this:
// x = load
@@ -741,11 +741,11 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a
// we do that at the very end, and only after structure, as removing
// the copy here:
// (if
- // (get_local $var$0)
- // (set_local $var$0
- // (get_local $var$0)
+ // (local.get $var$0)
+ // (local.set $var$0
+ // (local.get $var$0)
// )
- // (set_local $var$0
+ // (local.set $var$0
// (i32.const 208)
// )
// )
diff --git a/src/passes/Souperify.cpp b/src/passes/Souperify.cpp
index 5875c8f42..62ec133fe 100644
--- a/src/passes/Souperify.cpp
+++ b/src/passes/Souperify.cpp
@@ -131,7 +131,7 @@ struct UseFinder {
};
// Generates a trace: all the information to generate a Souper LHS
-// for a specific set_local whose value we want to infer.
+// for a specific local.set whose value we want to infer.
struct Trace {
Graph& graph;
Node* toInfer;
diff --git a/src/passes/StackIR.cpp b/src/passes/StackIR.cpp
index 3772500c4..a8d66ae42 100644
--- a/src/passes/StackIR.cpp
+++ b/src/passes/StackIR.cpp
@@ -118,12 +118,12 @@ private:
}
}
- // If ordered properly, we can avoid a set_local/get_local pair,
+ // If ordered properly, we can avoid a local.set/local.get pair,
// and use the value directly from the stack, for example
// [..produce a value on the stack..]
- // set_local $x
+ // local.set $x
// [..much code..]
- // get_local $x
+ // local.get $x
// call $foo ;; use the value, foo(value)
// As long as the code in between does not modify $x, and has
// no control flow branching out, we can remove both the set
diff --git a/src/passes/Untee.cpp b/src/passes/Untee.cpp
index b61875243..00f2ffe5d 100644
--- a/src/passes/Untee.cpp
+++ b/src/passes/Untee.cpp
@@ -15,7 +15,7 @@
*/
//
-// Removes tee_locals, replacing them with gets and sets.
+// Removes local.tees, replacing them with gets and sets.
//
// This makes the code "flatter", with less nested side
// effects. That can make some passes, like CodePushing,
diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp
index 63b73ac6a..cae69860a 100644
--- a/src/passes/pass.cpp
+++ b/src/passes/pass.cpp
@@ -122,7 +122,7 @@ void PassRegistry::registerPasses() {
registerPass("reorder-functions", "sorts functions by access frequency", createReorderFunctionsPass);
registerPass("reorder-locals", "sorts locals by access frequency", createReorderLocalsPass);
registerPass("rereloop", "re-optimize control flow using the relooper algorithm", createReReloopPass);
- registerPass("rse", "remove redundant set_locals", createRedundantSetEliminationPass);
+ registerPass("rse", "remove redundant local.sets", createRedundantSetEliminationPass);
registerPass("safe-heap", "instrument loads and stores to check for invalid behavior", createSafeHeapPass);
registerPass("simplify-locals", "miscellaneous locals-related optimizations", createSimplifyLocalsPass);
registerPass("simplify-locals-nonesting", "miscellaneous locals-related optimizations (no nesting at all; preserves flatness)", createSimplifyLocalsNoNestingPass);
@@ -136,7 +136,7 @@ void PassRegistry::registerPasses() {
registerPass("strip", "strip debug info (including the names section)", createStripPass);
registerPass("trap-mode-clamp", "replace trapping operations with clamping semantics", createTrapModeClamp);
registerPass("trap-mode-js", "replace trapping operations with js semantics", createTrapModeJS);
- registerPass("untee", "removes tee_locals, replacing them with sets and gets", createUnteePass);
+ registerPass("untee", "removes local.tees, replacing them with sets and gets", createUnteePass);
registerPass("vacuum", "removes obviously unneeded code", createVacuumPass);
// registerPass("lower-i64", "lowers i64 into pairs of i32s", createLowerInt64Pass);
}
diff --git a/src/passes/wasm-intrinsics.wast b/src/passes/wasm-intrinsics.wast
index 8cd14d51d..26687508d 100644
--- a/src/passes/wasm-intrinsics.wast
+++ b/src/passes/wasm-intrinsics.wast
@@ -40,24 +40,24 @@
(loop $label$2
(drop
(br_if $label$1
- (get_local $var$1)
+ (local.get $var$1)
(i32.eqz
- (get_local $var$0)
+ (local.get $var$0)
)
)
)
- (set_local $var$0
+ (local.set $var$0
(i32.and
- (get_local $var$0)
+ (local.get $var$0)
(i32.sub
- (get_local $var$0)
+ (local.get $var$0)
(i32.const 1)
)
)
)
- (set_local $var$1
+ (local.set $var$1
(i32.add
- (get_local $var$1)
+ (local.get $var$1)
(i32.const 1)
)
)
@@ -73,24 +73,24 @@
(loop $label$2
(drop
(br_if $label$1
- (get_local $var$1)
+ (local.get $var$1)
(i64.eqz
- (get_local $var$0)
+ (local.get $var$0)
)
)
)
- (set_local $var$0
+ (local.set $var$0
(i64.and
- (get_local $var$0)
+ (local.get $var$0)
(i64.sub
- (get_local $var$0)
+ (local.get $var$0)
(i64.const 1)
)
)
)
- (set_local $var$1
+ (local.set $var$1
(i64.add
- (get_local $var$1)
+ (local.get $var$1)
(i64.const 1)
)
)
@@ -101,30 +101,30 @@
;; lowering of the i64.div_s instruction, return $var0 / $var$1
(func $__wasm_i64_sdiv (; 0 ;) (type $0) (param $var$0 i64) (param $var$1 i64) (result i64)
(call $_ZN17compiler_builtins3int4sdiv3Div3div17he78fc483e41d7ec7E
- (get_local $var$0)
- (get_local $var$1)
+ (local.get $var$0)
+ (local.get $var$1)
)
)
;; lowering of the i64.div_u instruction, return $var0 / $var$1
(func $__wasm_i64_udiv (; 1 ;) (type $0) (param $var$0 i64) (param $var$1 i64) (result i64)
(call $_ZN17compiler_builtins3int4udiv10divmod_u6417h6026910b5ed08e40E
- (get_local $var$0)
- (get_local $var$1)
+ (local.get $var$0)
+ (local.get $var$1)
)
)
;; lowering of the i64.rem_s instruction, return $var0 % $var$1
(func $__wasm_i64_srem (; 2 ;) (type $0) (param $var$0 i64) (param $var$1 i64) (result i64)
(call $_ZN17compiler_builtins3int4sdiv3Mod4mod_17h2cbb7bbf36e41d68E
- (get_local $var$0)
- (get_local $var$1)
+ (local.get $var$0)
+ (local.get $var$1)
)
)
;; lowering of the i64.rem_u instruction, return $var0 % $var$1
(func $__wasm_i64_urem (; 3 ;) (type $0) (param $var$0 i64) (param $var$1 i64) (result i64)
(drop
(call $_ZN17compiler_builtins3int4udiv10divmod_u6417h6026910b5ed08e40E
- (get_local $var$0)
- (get_local $var$1)
+ (local.get $var$0)
+ (local.get $var$1)
)
)
(i64.load
@@ -134,8 +134,8 @@
;; lowering of the i64.mul instruction, return $var0 * $var$1
(func $__wasm_i64_mul (; 4 ;) (type $0) (param $var$0 i64) (param $var$1 i64) (result i64)
(call $_ZN17compiler_builtins3int3mul3Mul3mul17h070e9a1c69faec5bE
- (get_local $var$0)
- (get_local $var$1)
+ (local.get $var$0)
+ (local.get $var$1)
)
)
;; lowering of the f32.trunc instruction, rounds to the nearest integer,
@@ -143,13 +143,13 @@
(func $__wasm_trunc_f32 (; 5 ;) (type $1) (param $var$0 f32) (result f32)
(select
(f32.ceil
- (get_local $var$0)
+ (local.get $var$0)
)
(f32.floor
- (get_local $var$0)
+ (local.get $var$0)
)
(f32.lt
- (get_local $var$0)
+ (local.get $var$0)
(f32.const 0)
)
)
@@ -159,13 +159,13 @@
(func $__wasm_trunc_f64 (; 6 ;) (type $2) (param $var$0 f64) (result f64)
(select
(f64.ceil
- (get_local $var$0)
+ (local.get $var$0)
)
(f64.floor
- (get_local $var$0)
+ (local.get $var$0)
)
(f64.lt
- (get_local $var$0)
+ (local.get $var$0)
(f64.const 0)
)
)
@@ -173,17 +173,17 @@
;; lowering of the i32.ctz instruction, counting the number of zeros in $var$0
(func $__wasm_ctz_i32 (; 7 ;) (type $3) (param $var$0 i32) (result i32)
(if
- (get_local $var$0)
+ (local.get $var$0)
(return
(i32.sub
(i32.const 31)
(i32.clz
(i32.xor
(i32.add
- (get_local $var$0)
+ (local.get $var$0)
(i32.const -1)
)
- (get_local $var$0)
+ (local.get $var$0)
)
)
)
@@ -196,7 +196,7 @@
(if
(i32.eqz
(i64.eqz
- (get_local $var$0)
+ (local.get $var$0)
)
)
(return
@@ -205,10 +205,10 @@
(i64.clz
(i64.xor
(i64.add
- (get_local $var$0)
+ (local.get $var$0)
(i64.const -1)
)
- (get_local $var$0)
+ (local.get $var$0)
)
)
)
@@ -225,34 +225,34 @@
(i32.and
(i32.shr_u
(i32.const -1)
- (tee_local $var$2
+ (local.tee $var$2
(i32.and
- (get_local $var$1)
+ (local.get $var$1)
(i32.const 31)
)
)
)
- (get_local $var$0)
+ (local.get $var$0)
)
- (get_local $var$2)
+ (local.get $var$2)
)
(i32.shr_u
(i32.and
(i32.shl
(i32.const -1)
- (tee_local $var$1
+ (local.tee $var$1
(i32.and
(i32.sub
(i32.const 0)
- (get_local $var$1)
+ (local.get $var$1)
)
(i32.const 31)
)
)
)
- (get_local $var$0)
+ (local.get $var$0)
)
- (get_local $var$1)
+ (local.get $var$1)
)
)
)
@@ -265,34 +265,34 @@
(i32.and
(i32.shl
(i32.const -1)
- (tee_local $var$2
+ (local.tee $var$2
(i32.and
- (get_local $var$1)
+ (local.get $var$1)
(i32.const 31)
)
)
)
- (get_local $var$0)
+ (local.get $var$0)
)
- (get_local $var$2)
+ (local.get $var$2)
)
(i32.shl
(i32.and
(i32.shr_u
(i32.const -1)
- (tee_local $var$1
+ (local.tee $var$1
(i32.and
(i32.sub
(i32.const 0)
- (get_local $var$1)
+ (local.get $var$1)
)
(i32.const 31)
)
)
)
- (get_local $var$0)
+ (local.get $var$0)
)
- (get_local $var$1)
+ (local.get $var$1)
)
)
)
@@ -305,34 +305,34 @@
(i64.and
(i64.shr_u
(i64.const -1)
- (tee_local $var$2
+ (local.tee $var$2
(i64.and
- (get_local $var$1)
+ (local.get $var$1)
(i64.const 63)
)
)
)
- (get_local $var$0)
+ (local.get $var$0)
)
- (get_local $var$2)
+ (local.get $var$2)
)
(i64.shr_u
(i64.and
(i64.shl
(i64.const -1)
- (tee_local $var$1
+ (local.tee $var$1
(i64.and
(i64.sub
(i64.const 0)
- (get_local $var$1)
+ (local.get $var$1)
)
(i64.const 63)
)
)
)
- (get_local $var$0)
+ (local.get $var$0)
)
- (get_local $var$1)
+ (local.get $var$1)
)
)
)
@@ -345,34 +345,34 @@
(i64.and
(i64.shl
(i64.const -1)
- (tee_local $var$2
+ (local.tee $var$2
(i64.and
- (get_local $var$1)
+ (local.get $var$1)
(i64.const 63)
)
)
)
- (get_local $var$0)
+ (local.get $var$0)
)
- (get_local $var$2)
+ (local.get $var$2)
)
(i64.shl
(i64.and
(i64.shr_u
(i64.const -1)
- (tee_local $var$1
+ (local.tee $var$1
(i64.and
(i64.sub
(i64.const 0)
- (get_local $var$1)
+ (local.get $var$1)
)
(i64.const 63)
)
)
)
- (get_local $var$0)
+ (local.get $var$0)
)
- (get_local $var$1)
+ (local.get $var$1)
)
)
)
@@ -384,12 +384,12 @@
(if
(i32.eqz
(f32.lt
- (tee_local $var$2
+ (local.tee $var$2
(f32.sub
- (get_local $var$0)
- (tee_local $var$1
+ (local.get $var$0)
+ (local.tee $var$1
(f32.floor
- (get_local $var$0)
+ (local.get $var$0)
)
)
)
@@ -398,34 +398,34 @@
)
)
(block
- (set_local $var$0
+ (local.set $var$0
(f32.ceil
- (get_local $var$0)
+ (local.get $var$0)
)
)
(if
(f32.gt
- (get_local $var$2)
+ (local.get $var$2)
(f32.const 0.5)
)
(return
- (get_local $var$0)
+ (local.get $var$0)
)
)
- (set_local $var$1
+ (local.set $var$1
(select
- (get_local $var$1)
- (get_local $var$0)
+ (local.get $var$1)
+ (local.get $var$0)
(f32.eq
(f32.sub
- (tee_local $var$2
+ (local.tee $var$2
(f32.mul
- (get_local $var$1)
+ (local.get $var$1)
(f32.const 0.5)
)
)
(f32.floor
- (get_local $var$2)
+ (local.get $var$2)
)
)
(f32.const 0)
@@ -434,7 +434,7 @@
)
)
)
- (get_local $var$1)
+ (local.get $var$1)
)
;; lowering of the f64.nearest instruction, rounding the input to the nearest
;; integer while breaking ties by rounding to even
@@ -444,12 +444,12 @@
(if
(i32.eqz
(f64.lt
- (tee_local $var$2
+ (local.tee $var$2
(f64.sub
- (get_local $var$0)
- (tee_local $var$1
+ (local.get $var$0)
+ (local.tee $var$1
(f64.floor
- (get_local $var$0)
+ (local.get $var$0)
)
)
)
@@ -458,34 +458,34 @@
)
)
(block
- (set_local $var$0
+ (local.set $var$0
(f64.ceil
- (get_local $var$0)
+ (local.get $var$0)
)
)
(if
(f64.gt
- (get_local $var$2)
+ (local.get $var$2)
(f64.const 0.5)
)
(return
- (get_local $var$0)
+ (local.get $var$0)
)
)
- (set_local $var$1
+ (local.set $var$1
(select
- (get_local $var$1)
- (get_local $var$0)
+ (local.get $var$1)
+ (local.get $var$0)
(f64.eq
(f64.sub
- (tee_local $var$2
+ (local.tee $var$2
(f64.mul
- (get_local $var$1)
+ (local.get $var$1)
(f64.const 0.5)
)
)
(f64.floor
- (get_local $var$2)
+ (local.get $var$2)
)
)
(f64.const 0)
@@ -494,7 +494,7 @@
)
)
)
- (get_local $var$1)
+ (local.get $var$1)
)
(func $_ZN17compiler_builtins3int4udiv10divmod_u6417h6026910b5ed08e40E (; 14 ;) (type $0) (param $var$0 i64) (param $var$1 i64) (result i64)
(local $var$2 i32)
@@ -516,10 +516,10 @@
(block $label$10
(block $label$11
(if
- (tee_local $var$2
- (i32.wrap/i64
+ (local.tee $var$2
+ (i32.wrap_i64
(i64.shr_u
- (get_local $var$0)
+ (local.get $var$0)
(i64.const 32)
)
)
@@ -527,19 +527,19 @@
(block
(br_if $label$11
(i32.eqz
- (tee_local $var$3
- (i32.wrap/i64
- (get_local $var$1)
+ (local.tee $var$3
+ (i32.wrap_i64
+ (local.get $var$1)
)
)
)
)
(br_if $label$9
(i32.eqz
- (tee_local $var$4
- (i32.wrap/i64
+ (local.tee $var$4
+ (i32.wrap_i64
(i64.shr_u
- (get_local $var$1)
+ (local.get $var$1)
(i64.const 32)
)
)
@@ -548,13 +548,13 @@
)
(br_if $label$8
(i32.le_u
- (tee_local $var$2
+ (local.tee $var$2
(i32.sub
(i32.clz
- (get_local $var$4)
+ (local.get $var$4)
)
(i32.clz
- (get_local $var$2)
+ (local.get $var$2)
)
)
)
@@ -566,97 +566,97 @@
)
(br_if $label$2
(i64.ge_u
- (get_local $var$1)
+ (local.get $var$1)
(i64.const 4294967296)
)
)
(i64.store
(i32.const 1024)
- (i64.extend_u/i32
+ (i64.extend_i32_u
(i32.sub
- (tee_local $var$2
- (i32.wrap/i64
- (get_local $var$0)
+ (local.tee $var$2
+ (i32.wrap_i64
+ (local.get $var$0)
)
)
(i32.mul
- (tee_local $var$2
+ (local.tee $var$2
(i32.div_u
- (get_local $var$2)
- (tee_local $var$3
- (i32.wrap/i64
- (get_local $var$1)
+ (local.get $var$2)
+ (local.tee $var$3
+ (i32.wrap_i64
+ (local.get $var$1)
)
)
)
)
- (get_local $var$3)
+ (local.get $var$3)
)
)
)
)
(return
- (i64.extend_u/i32
- (get_local $var$2)
+ (i64.extend_i32_u
+ (local.get $var$2)
)
)
)
- (set_local $var$3
- (i32.wrap/i64
+ (local.set $var$3
+ (i32.wrap_i64
(i64.shr_u
- (get_local $var$1)
+ (local.get $var$1)
(i64.const 32)
)
)
)
(br_if $label$7
(i32.eqz
- (i32.wrap/i64
- (get_local $var$0)
+ (i32.wrap_i64
+ (local.get $var$0)
)
)
)
(br_if $label$6
(i32.eqz
- (get_local $var$3)
+ (local.get $var$3)
)
)
(br_if $label$6
(i32.and
- (tee_local $var$4
+ (local.tee $var$4
(i32.add
- (get_local $var$3)
+ (local.get $var$3)
(i32.const -1)
)
)
- (get_local $var$3)
+ (local.get $var$3)
)
)
(i64.store
(i32.const 1024)
(i64.or
(i64.shl
- (i64.extend_u/i32
+ (i64.extend_i32_u
(i32.and
- (get_local $var$4)
- (get_local $var$2)
+ (local.get $var$4)
+ (local.get $var$2)
)
)
(i64.const 32)
)
(i64.and
- (get_local $var$0)
+ (local.get $var$0)
(i64.const 4294967295)
)
)
)
(return
- (i64.extend_u/i32
+ (i64.extend_i32_u
(i32.shr_u
- (get_local $var$2)
+ (local.get $var$2)
(i32.and
(i32.ctz
- (get_local $var$3)
+ (local.get $var$3)
)
(i32.const 31)
)
@@ -669,29 +669,29 @@
(br_if $label$5
(i32.eqz
(i32.and
- (tee_local $var$4
+ (local.tee $var$4
(i32.add
- (get_local $var$3)
+ (local.get $var$3)
(i32.const -1)
)
)
- (get_local $var$3)
+ (local.get $var$3)
)
)
)
- (set_local $var$3
+ (local.set $var$3
(i32.sub
(i32.const 0)
- (tee_local $var$2
+ (local.tee $var$2
(i32.sub
(i32.add
(i32.clz
- (get_local $var$3)
+ (local.get $var$3)
)
(i32.const 33)
)
(i32.clz
- (get_local $var$2)
+ (local.get $var$2)
)
)
)
@@ -699,15 +699,15 @@
)
(br $label$3)
)
- (set_local $var$3
+ (local.set $var$3
(i32.sub
(i32.const 63)
- (get_local $var$2)
+ (local.get $var$2)
)
)
- (set_local $var$2
+ (local.set $var$2
(i32.add
- (get_local $var$2)
+ (local.get $var$2)
(i32.const 1)
)
)
@@ -716,17 +716,17 @@
(i64.store
(i32.const 1024)
(i64.shl
- (i64.extend_u/i32
+ (i64.extend_i32_u
(i32.sub
- (get_local $var$2)
+ (local.get $var$2)
(i32.mul
- (tee_local $var$4
+ (local.tee $var$4
(i32.div_u
- (get_local $var$2)
- (get_local $var$3)
+ (local.get $var$2)
+ (local.get $var$3)
)
)
- (get_local $var$3)
+ (local.get $var$3)
)
)
)
@@ -734,20 +734,20 @@
)
)
(return
- (i64.extend_u/i32
- (get_local $var$4)
+ (i64.extend_i32_u
+ (local.get $var$4)
)
)
)
(br_if $label$4
(i32.lt_u
- (tee_local $var$2
+ (local.tee $var$2
(i32.sub
(i32.clz
- (get_local $var$3)
+ (local.get $var$3)
)
(i32.clz
- (get_local $var$2)
+ (local.get $var$2)
)
)
)
@@ -758,62 +758,62 @@
)
(i64.store
(i32.const 1024)
- (i64.extend_u/i32
+ (i64.extend_i32_u
(i32.and
- (get_local $var$4)
- (i32.wrap/i64
- (get_local $var$0)
+ (local.get $var$4)
+ (i32.wrap_i64
+ (local.get $var$0)
)
)
)
)
(br_if $label$1
(i32.eq
- (get_local $var$3)
+ (local.get $var$3)
(i32.const 1)
)
)
(return
(i64.shr_u
- (get_local $var$0)
- (i64.extend_u/i32
+ (local.get $var$0)
+ (i64.extend_i32_u
(i32.ctz
- (get_local $var$3)
+ (local.get $var$3)
)
)
)
)
)
- (set_local $var$3
+ (local.set $var$3
(i32.sub
(i32.const 63)
- (get_local $var$2)
+ (local.get $var$2)
)
)
- (set_local $var$2
+ (local.set $var$2
(i32.add
- (get_local $var$2)
+ (local.get $var$2)
(i32.const 1)
)
)
)
- (set_local $var$5
+ (local.set $var$5
(i64.shr_u
- (get_local $var$0)
- (i64.extend_u/i32
+ (local.get $var$0)
+ (i64.extend_i32_u
(i32.and
- (get_local $var$2)
+ (local.get $var$2)
(i32.const 63)
)
)
)
)
- (set_local $var$0
+ (local.set $var$0
(i64.shl
- (get_local $var$0)
- (i64.extend_u/i32
+ (local.get $var$0)
+ (i64.extend_i32_u
(i32.and
- (get_local $var$3)
+ (local.get $var$3)
(i32.const 63)
)
)
@@ -821,64 +821,64 @@
)
(block $label$13
(if
- (get_local $var$2)
+ (local.get $var$2)
(block
- (set_local $var$8
+ (local.set $var$8
(i64.add
- (get_local $var$1)
+ (local.get $var$1)
(i64.const -1)
)
)
(loop $label$15
- (set_local $var$5
+ (local.set $var$5
(i64.sub
- (tee_local $var$5
+ (local.tee $var$5
(i64.or
(i64.shl
- (get_local $var$5)
+ (local.get $var$5)
(i64.const 1)
)
(i64.shr_u
- (get_local $var$0)
+ (local.get $var$0)
(i64.const 63)
)
)
)
(i64.and
- (tee_local $var$6
+ (local.tee $var$6
(i64.shr_s
(i64.sub
- (get_local $var$8)
- (get_local $var$5)
+ (local.get $var$8)
+ (local.get $var$5)
)
(i64.const 63)
)
)
- (get_local $var$1)
+ (local.get $var$1)
)
)
)
- (set_local $var$0
+ (local.set $var$0
(i64.or
(i64.shl
- (get_local $var$0)
+ (local.get $var$0)
(i64.const 1)
)
- (get_local $var$7)
+ (local.get $var$7)
)
)
- (set_local $var$7
- (tee_local $var$6
+ (local.set $var$7
+ (local.tee $var$6
(i64.and
- (get_local $var$6)
+ (local.get $var$6)
(i64.const 1)
)
)
)
(br_if $label$15
- (tee_local $var$2
+ (local.tee $var$2
(i32.add
- (get_local $var$2)
+ (local.get $var$2)
(i32.const -1)
)
)
@@ -890,27 +890,27 @@
)
(i64.store
(i32.const 1024)
- (get_local $var$5)
+ (local.get $var$5)
)
(return
(i64.or
(i64.shl
- (get_local $var$0)
+ (local.get $var$0)
(i64.const 1)
)
- (get_local $var$6)
+ (local.get $var$6)
)
)
)
(i64.store
(i32.const 1024)
- (get_local $var$0)
+ (local.get $var$0)
)
- (set_local $var$0
+ (local.set $var$0
(i64.const 0)
)
)
- (get_local $var$0)
+ (local.get $var$0)
)
(func $_ZN17compiler_builtins3int3mul3Mul3mul17h070e9a1c69faec5bE (; 15 ;) (type $0) (param $var$0 i64) (param $var$1 i64) (result i64)
(local $var$2 i32)
@@ -920,27 +920,27 @@
(local $var$6 i32)
(i64.or
(i64.shl
- (i64.extend_u/i32
+ (i64.extend_i32_u
(i32.add
(i32.add
(i32.add
(i32.add
(i32.mul
- (tee_local $var$4
+ (local.tee $var$4
(i32.shr_u
- (tee_local $var$2
- (i32.wrap/i64
- (get_local $var$1)
+ (local.tee $var$2
+ (i32.wrap_i64
+ (local.get $var$1)
)
)
(i32.const 16)
)
)
- (tee_local $var$5
+ (local.tee $var$5
(i32.shr_u
- (tee_local $var$3
- (i32.wrap/i64
- (get_local $var$0)
+ (local.tee $var$3
+ (i32.wrap_i64
+ (local.get $var$0)
)
)
(i32.const 16)
@@ -948,40 +948,40 @@
)
)
(i32.mul
- (get_local $var$2)
- (i32.wrap/i64
+ (local.get $var$2)
+ (i32.wrap_i64
(i64.shr_u
- (get_local $var$0)
+ (local.get $var$0)
(i64.const 32)
)
)
)
)
(i32.mul
- (i32.wrap/i64
+ (i32.wrap_i64
(i64.shr_u
- (get_local $var$1)
+ (local.get $var$1)
(i64.const 32)
)
)
- (get_local $var$3)
+ (local.get $var$3)
)
)
(i32.shr_u
- (tee_local $var$2
+ (local.tee $var$2
(i32.add
(i32.shr_u
- (tee_local $var$6
+ (local.tee $var$6
(i32.mul
- (tee_local $var$2
+ (local.tee $var$2
(i32.and
- (get_local $var$2)
+ (local.get $var$2)
(i32.const 65535)
)
)
- (tee_local $var$3
+ (local.tee $var$3
(i32.and
- (get_local $var$3)
+ (local.get $var$3)
(i32.const 65535)
)
)
@@ -990,8 +990,8 @@
(i32.const 16)
)
(i32.mul
- (get_local $var$2)
- (get_local $var$5)
+ (local.get $var$2)
+ (local.get $var$5)
)
)
)
@@ -999,15 +999,15 @@
)
)
(i32.shr_u
- (tee_local $var$2
+ (local.tee $var$2
(i32.add
(i32.and
- (get_local $var$2)
+ (local.get $var$2)
(i32.const 65535)
)
(i32.mul
- (get_local $var$4)
- (get_local $var$3)
+ (local.get $var$4)
+ (local.get $var$3)
)
)
)
@@ -1017,14 +1017,14 @@
)
(i64.const 32)
)
- (i64.extend_u/i32
+ (i64.extend_i32_u
(i32.or
(i32.shl
- (get_local $var$2)
+ (local.get $var$2)
(i32.const 16)
)
(i32.and
- (get_local $var$6)
+ (local.get $var$6)
(i32.const 65535)
)
)
@@ -1038,40 +1038,40 @@
(i64.div_u
(i64.sub
(i64.xor
- (tee_local $var$2
+ (local.tee $var$2
(i64.shr_s
- (get_local $var$0)
+ (local.get $var$0)
(i64.const 63)
)
)
- (get_local $var$0)
+ (local.get $var$0)
)
- (get_local $var$2)
+ (local.get $var$2)
)
(i64.sub
(i64.xor
- (tee_local $var$2
+ (local.tee $var$2
(i64.shr_s
- (get_local $var$1)
+ (local.get $var$1)
(i64.const 63)
)
)
- (get_local $var$1)
+ (local.get $var$1)
)
- (get_local $var$2)
+ (local.get $var$2)
)
)
- (tee_local $var$0
+ (local.tee $var$0
(i64.shr_s
(i64.xor
- (get_local $var$1)
- (get_local $var$0)
+ (local.get $var$1)
+ (local.get $var$0)
)
(i64.const 63)
)
)
)
- (get_local $var$0)
+ (local.get $var$0)
)
)
(func $_ZN17compiler_builtins3int4sdiv3Mod4mod_17h2cbb7bbf36e41d68E (; 17 ;) (type $0) (param $var$0 i64) (param $var$1 i64) (result i64)
@@ -1081,32 +1081,32 @@
(i64.rem_u
(i64.sub
(i64.xor
- (tee_local $var$2
+ (local.tee $var$2
(i64.shr_s
- (get_local $var$0)
+ (local.get $var$0)
(i64.const 63)
)
)
- (get_local $var$0)
+ (local.get $var$0)
)
- (get_local $var$2)
+ (local.get $var$2)
)
(i64.sub
(i64.xor
- (tee_local $var$0
+ (local.tee $var$0
(i64.shr_s
- (get_local $var$1)
+ (local.get $var$1)
(i64.const 63)
)
)
- (get_local $var$1)
+ (local.get $var$1)
)
- (get_local $var$0)
+ (local.get $var$0)
)
)
- (get_local $var$2)
+ (local.get $var$2)
)
- (get_local $var$2)
+ (local.get $var$2)
)
)
;; custom section "linking", size 3
diff --git a/src/shared-constants.h b/src/shared-constants.h
index 55d90b057..ae7d915ef 100644
--- a/src/shared-constants.h
+++ b/src/shared-constants.h
@@ -54,7 +54,7 @@ extern Name GROW_WASM_MEMORY,
NEG_NAN,
CASE,
BR,
- ANYFUNC,
+ FUNCREF,
FAKE_RETURN,
MUT,
SPECTEST,
diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp
index 4a7ca51b7..c0730877a 100644
--- a/src/tools/wasm-ctor-eval.cpp
+++ b/src/tools/wasm-ctor-eval.cpp
@@ -226,7 +226,7 @@ struct CtorEvalExternalInterface : EvallingModuleInstance::ExternalInterface {
} else if (segment.offset->is<GetGlobal>()) {
start = 0;
} else {
- WASM_UNREACHABLE(); // wasm spec only allows const and get_global there
+ WASM_UNREACHABLE(); // wasm spec only allows const and global.get there
}
auto end = start + segment.data.size();
if (start <= index && index < end) {
diff --git a/src/tools/wasm-merge.cpp b/src/tools/wasm-merge.cpp
index 52f682e16..e9ac6d649 100644
--- a/src/tools/wasm-merge.cpp
+++ b/src/tools/wasm-merge.cpp
@@ -500,7 +500,7 @@ struct InputMergeable : public ExpressionStackWalker<InputMergeable, Visitor<Inp
}
private:
- // add an offset to a get_global. we look above, and if there is already an add,
+ // add an offset to a global.get. we look above, and if there is already an add,
// we can add into it, avoiding creating a new node
void addBump(Index bump) {
if (expressionStack.size() >= 2) {
diff --git a/src/wasm-emscripten.h b/src/wasm-emscripten.h
index a5de5a128..2b626a7c9 100644
--- a/src/wasm-emscripten.h
+++ b/src/wasm-emscripten.h
@@ -42,7 +42,7 @@ public:
// signature in the indirect function table.
void generateDynCallThunks();
- // Convert stack pointer access from get_global/set_global to calling save
+ // Convert stack pointer access from global.get/global.set to calling save
// and restore functions.
void replaceStackPointerGlobal();
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index de1374444..af42ed8a4 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -1986,10 +1986,10 @@ void WasmBinaryBuilder::visitCallIndirect(CallIndirect* curr) {
void WasmBinaryBuilder::visitGetLocal(GetLocal* curr) {
if (debug) std::cerr << "zz node: GetLocal " << pos << std::endl;
- requireFunctionContext("get_local");
+ requireFunctionContext("local.get");
curr->index = getU32LEB();
if (curr->index >= currFunction->getNumLocals()) {
- throwError("bad get_local index");
+ throwError("bad local.get index");
}
curr->type = currFunction->getLocalType(curr->index);
curr->finalize();
@@ -1997,10 +1997,10 @@ void WasmBinaryBuilder::visitGetLocal(GetLocal* curr) {
void WasmBinaryBuilder::visitSetLocal(SetLocal *curr, uint8_t code) {
if (debug) std::cerr << "zz node: Set|TeeLocal" << std::endl;
- requireFunctionContext("set_local outside of function");
+ requireFunctionContext("local.set outside of function");
curr->index = getU32LEB();
if (curr->index >= currFunction->getNumLocals()) {
- throwError("bad set_local index");
+ throwError("bad local.set index");
}
curr->value = popNonVoidExpression();
curr->type = curr->value->type;
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index 43fdb0a5a..0dfea962b 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -769,7 +769,7 @@ Expression* SExpressionWasmBuilder::makeGetGlobal(Element& s) {
ret->name = getGlobalName(*s[1]);
auto* global = wasm.getGlobalOrNull(ret->name);
if (!global) {
- throw ParseException("bad get_global name", s.line, s.col);
+ throw ParseException("bad global.get name", s.line, s.col);
}
ret->type = global->type;
return ret;
@@ -778,7 +778,7 @@ Expression* SExpressionWasmBuilder::makeGetGlobal(Element& s) {
Expression* SExpressionWasmBuilder::makeSetGlobal(Element& s) {
auto ret = allocator.alloc<SetGlobal>();
ret->name = getGlobalName(*s[1]);
- if (wasm.getGlobalOrNull(ret->name) && !wasm.getGlobalOrNull(ret->name)->mutable_) throw ParseException("set_global of immutable", s.line, s.col);
+ if (wasm.getGlobalOrNull(ret->name) && !wasm.getGlobalOrNull(ret->name)->mutable_) throw ParseException("global.set of immutable", s.line, s.col);
ret->value = parseExpression(s[2]);
ret->finalize();
return ret;
@@ -1751,7 +1751,7 @@ void SExpressionWasmBuilder::parseTable(Element& s, bool preParseImport) {
}
if (i == s.size()) return;
if (!s[i]->dollared()) {
- if (s[i]->str() == ANYFUNC) {
+ if (s[i]->str() == FUNCREF) {
// (table type (elem ..))
parseInnerElem(*s[i + 1]);
if (wasm.table.segments.size() > 0) {
@@ -1761,8 +1761,8 @@ void SExpressionWasmBuilder::parseTable(Element& s, bool preParseImport) {
}
return;
}
- // first element isn't dollared, and isn't anyfunc. this could be old syntax for (table 0 1) which means function 0 and 1, or it could be (table initial max? type), look for type
- if (s[s.size() - 1]->str() == ANYFUNC) {
+ // first element isn't dollared, and isn't funcref. this could be old syntax for (table 0 1) which means function 0 and 1, or it could be (table initial max? type), look for type
+ if (s[s.size() - 1]->str() == FUNCREF) {
// (table initial max? type)
if (i < s.size() - 1) {
wasm.table.initial = atoi(s[i++]->c_str());
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index b018db2d0..0b07be802 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -472,32 +472,32 @@ void FunctionValidator::visitCallIndirect(CallIndirect* curr) {
}
void FunctionValidator::visitGetLocal(GetLocal* curr) {
- shouldBeTrue(curr->index < getFunction()->getNumLocals(), curr, "get_local index must be small enough");
- shouldBeTrue(isConcreteType(curr->type), curr, "get_local must have a valid type - check what you provided when you constructed the node");
- shouldBeTrue(curr->type == getFunction()->getLocalType(curr->index), curr, "get_local must have proper type");
+ shouldBeTrue(curr->index < getFunction()->getNumLocals(), curr, "local.get index must be small enough");
+ shouldBeTrue(isConcreteType(curr->type), curr, "local.get must have a valid type - check what you provided when you constructed the node");
+ shouldBeTrue(curr->type == getFunction()->getLocalType(curr->index), curr, "local.get must have proper type");
}
void FunctionValidator::visitSetLocal(SetLocal* curr) {
- shouldBeTrue(curr->index < getFunction()->getNumLocals(), curr, "set_local index must be small enough");
+ shouldBeTrue(curr->index < getFunction()->getNumLocals(), curr, "local.set index must be small enough");
if (curr->value->type != unreachable) {
if (curr->type != none) { // tee is ok anyhow
- shouldBeEqualOrFirstIsUnreachable(curr->value->type, curr->type, curr, "set_local type must be correct");
+ shouldBeEqualOrFirstIsUnreachable(curr->value->type, curr->type, curr, "local.set type must be correct");
}
- shouldBeEqual(getFunction()->getLocalType(curr->index), curr->value->type, curr, "set_local type must match function");
+ shouldBeEqual(getFunction()->getLocalType(curr->index), curr->value->type, curr, "local.set type must match function");
}
}
void FunctionValidator::visitGetGlobal(GetGlobal* curr) {
if (!info.validateGlobally) return;
- shouldBeTrue(getModule()->getGlobalOrNull(curr->name), curr, "get_global name must be valid");
+ shouldBeTrue(getModule()->getGlobalOrNull(curr->name), curr, "global.get name must be valid");
}
void FunctionValidator::visitSetGlobal(SetGlobal* curr) {
if (!info.validateGlobally) return;
auto* global = getModule()->getGlobalOrNull(curr->name);
- if (shouldBeTrue(global, curr, "set_global name must be valid (and not an import; imports can't be modified)")) {
- shouldBeTrue(global->mutable_, curr, "set_global global must be mutable");
- shouldBeEqualOrFirstIsUnreachable(curr->value->type, global->type, curr, "set_global value must have right type");
+ if (shouldBeTrue(global, curr, "global.set name must be valid (and not an import; imports can't be modified)")) {
+ shouldBeTrue(global->mutable_, curr, "global.set global must be mutable");
+ shouldBeEqualOrFirstIsUnreachable(curr->value->type, global->type, curr, "global.set value must have right type");
}
}
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index 87278d3cd..cfee4f3c4 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -66,7 +66,7 @@ Name GROW_WASM_MEMORY("__growWasmMemory"),
NEG_NAN("-nan"),
CASE("case"),
BR("br"),
- ANYFUNC("anyfunc"),
+ FUNCREF("funcref"),
FAKE_RETURN("fake_return_waka123"),
MUT("mut"),
SPECTEST("spectest"),
@@ -85,10 +85,10 @@ const char* getExpressionName(Expression* curr) {
case Expression::Id::SwitchId: return "switch";
case Expression::Id::CallId: return "call";
case Expression::Id::CallIndirectId: return "call_indirect";
- case Expression::Id::GetLocalId: return "get_local";
- case Expression::Id::SetLocalId: return "set_local";
- case Expression::Id::GetGlobalId: return "get_global";
- case Expression::Id::SetGlobalId: return "set_global";
+ case Expression::Id::GetLocalId: return "local.get";
+ case Expression::Id::SetLocalId: return "local.set";
+ case Expression::Id::GetGlobalId: return "global.get";
+ case Expression::Id::SetGlobalId: return "global.set";
case Expression::Id::LoadId: return "load";
case Expression::Id::StoreId: return "store";
case Expression::Id::ConstId: return "const";