diff options
181 files changed, 1531 insertions, 1532 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 06080dd5f..ec2cf24b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,17 @@ full changeset diff at the end of each section. Current Trunk ------------- +- Removed APIs related to deprecated instruction names in Binaryen.js: + - `get_local` / `getLocal` + - `set_local` / `setLocal` + - `tee_local` / `teeLocal` + - `get_global` / `getGlobal` + - `set_global` / `setGlobal` + - `current_memory` / `currentMemory` + - `grow_memory` / `growMemory` + They are now available as their new instruction names: + `local.get`, `local.set`, `local.tee`, `global.get`, `global.set`, + `memory.size`, and `memory.grow`. - Add feature handling to the C/JS API with no feature enabled by default. v84 diff --git a/build-js.sh b/build-js.sh index 8317bce4a..9665bbc71 100755 --- a/build-js.sh +++ b/build-js.sh @@ -195,10 +195,10 @@ export_function "_BinaryenBreakId" export_function "_BinaryenSwitchId" export_function "_BinaryenCallId" export_function "_BinaryenCallIndirectId" -export_function "_BinaryenGetLocalId" -export_function "_BinaryenSetLocalId" -export_function "_BinaryenGetGlobalId" -export_function "_BinaryenSetGlobalId" +export_function "_BinaryenLocalGetId" +export_function "_BinaryenLocalSetId" +export_function "_BinaryenGlobalGetId" +export_function "_BinaryenGlobalSetId" export_function "_BinaryenLoadId" export_function "_BinaryenStoreId" export_function "_BinaryenConstId" @@ -385,8 +385,8 @@ export_function "_BinaryenLtFloat64" export_function "_BinaryenLeFloat64" export_function "_BinaryenGtFloat64" export_function "_BinaryenGeFloat64" -export_function "_BinaryenCurrentMemory" -export_function "_BinaryenGrowMemory" +export_function "_BinaryenMemorySize" +export_function "_BinaryenMemoryGrow" export_function "_BinaryenAtomicRMWAdd" export_function "_BinaryenAtomicRMWSub" export_function "_BinaryenAtomicRMWAnd" @@ -537,11 +537,11 @@ export_function "_BinaryenBreak" export_function "_BinaryenSwitch" export_function "_BinaryenCall" export_function "_BinaryenCallIndirect" -export_function "_BinaryenGetLocal" -export_function "_BinaryenSetLocal" -export_function "_BinaryenTeeLocal" -export_function "_BinaryenGetGlobal" -export_function "_BinaryenSetGlobal" +export_function "_BinaryenLocalGet" +export_function "_BinaryenLocalSet" +export_function "_BinaryenLocalTee" +export_function "_BinaryenGlobalGet" +export_function "_BinaryenGlobalSet" export_function "_BinaryenLoad" export_function "_BinaryenStore" export_function "_BinaryenConst" @@ -610,20 +610,20 @@ export_function "_BinaryenCallIndirectGetTarget" export_function "_BinaryenCallIndirectGetNumOperands" export_function "_BinaryenCallIndirectGetOperand" -# 'GetLocal' expression operations -export_function "_BinaryenGetLocalGetIndex" +# 'LocalGet' expression operations +export_function "_BinaryenLocalGetGetIndex" -# 'SetLocal' expression operations -export_function "_BinaryenSetLocalIsTee" -export_function "_BinaryenSetLocalGetIndex" -export_function "_BinaryenSetLocalGetValue" +# 'LocalSet' expression operations +export_function "_BinaryenLocalSetIsTee" +export_function "_BinaryenLocalSetGetIndex" +export_function "_BinaryenLocalSetGetValue" -# 'GetGlobal' expression operations -export_function "_BinaryenGetGlobalGetName" +# 'GlobalGet' expression operations +export_function "_BinaryenGlobalGetGetName" -# 'SetGlobal' expression operations -export_function "_BinaryenSetGlobalGetName" -export_function "_BinaryenSetGlobalGetValue" +# 'GlobalSet' expression operations +export_function "_BinaryenGlobalSetGetName" +export_function "_BinaryenGlobalSetGetValue" # 'Host' expression operations export_function "_BinaryenHostGetOp" @@ -767,8 +767,8 @@ export_function "_BinaryenRemoveExport" export_function "_BinaryenSetFunctionTable" export_function "_BinaryenSetMemory" export_function "_BinaryenSetStart" -export_function "_BinaryenGetFeatures" -export_function "_BinaryenSetFeatures" +export_function "_BinaryenModuleGetFeatures" +export_function "_BinaryenModuleSetFeatures" export_function "_BinaryenModuleParse" export_function "_BinaryenModulePrint" export_function "_BinaryenModulePrintAsmjs" diff --git a/scripts/fuzz_relooper.py b/scripts/fuzz_relooper.py index 62db2a3c5..3b14ed2cd 100755 --- a/scripts/fuzz_relooper.py +++ b/scripts/fuzz_relooper.py @@ -216,7 +216,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; ''' % (i, printed_ids[i]) @@ -226,7 +226,7 @@ int main() { BinaryenBlock(module, NULL, list, 2, BinaryenTypeNone()), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(%d)) ) ); @@ -279,7 +279,7 @@ int main() { BinaryenEqInt32(), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(%d)) ), BinaryenConst(module, BinaryenLiteralInt32(%d)) diff --git a/scripts/gen-s-parser.py b/scripts/gen-s-parser.py index 9dcfb3dd3..5e5ec494f 100755 --- a/scripts/gen-s-parser.py +++ b/scripts/gen-s-parser.py @@ -32,11 +32,11 @@ instructions = [ ("call_indirect", "makeCallIndirect(s)"), ("drop", "makeDrop(s)"), ("select", "makeSelect(s)"), - ("local.get", "makeGetLocal(s)"), - ("local.set", "makeSetLocal(s)"), - ("local.tee", "makeTeeLocal(s)"), - ("global.get", "makeGetGlobal(s)"), - ("global.set", "makeSetGlobal(s)"), + ("local.get", "makeLocalGet(s)"), + ("local.set", "makeLocalSet(s)"), + ("local.tee", "makeLocalTee(s)"), + ("global.get", "makeGlobalGet(s)"), + ("global.set", "makeGlobalSet(s)"), ("memory.init", "makeMemoryInit(s)"), ("data.drop", "makeDataDrop(s)"), ("memory.copy", "makeMemoryCopy(s)"), @@ -64,8 +64,8 @@ instructions = [ ("i64.store8", "makeStore(s, i64, /*isAtomic=*/false)"), ("i64.store16", "makeStore(s, i64, /*isAtomic=*/false)"), ("i64.store32", "makeStore(s, i64, /*isAtomic=*/false)"), - ("current_memory", "makeHost(s, HostOp::CurrentMemory)"), - ("grow_memory", "makeHost(s, HostOp::GrowMemory)"), + ("memory.size", "makeHost(s, HostOp::MemorySize)"), + ("memory.grow", "makeHost(s, HostOp::MemoryGrow)"), ("i32.const", "makeConst(s, i32)"), ("i64.const", "makeConst(s, i64)"), ("f32.const", "makeConst(s, f32)"), diff --git a/src/abi/stack.h b/src/abi/stack.h index f84c15d90..72220645c 100644 --- a/src/abi/stack.h +++ b/src/abi/stack.h @@ -50,21 +50,21 @@ getStackSpace(Index local, Function* func, Index size, Module& wasm) { // TODO: find existing stack usage, and add on top of that - carefully Builder builder(wasm); auto* block = builder.makeBlock(); - block->list.push_back(builder.makeSetLocal( - local, builder.makeGetGlobal(stackPointer->name, PointerType))); + block->list.push_back(builder.makeLocalSet( + local, builder.makeGlobalGet(stackPointer->name, PointerType))); // TODO: add stack max check Expression* added; if (PointerType == i32) { added = builder.makeBinary(AddInt32, - builder.makeGetLocal(local, PointerType), + builder.makeLocalGet(local, PointerType), builder.makeConst(Literal(int32_t(size)))); } else { WASM_UNREACHABLE(); } - block->list.push_back(builder.makeSetGlobal(stackPointer->name, added)); + block->list.push_back(builder.makeGlobalSet(stackPointer->name, added)); auto makeStackRestore = [&]() { - return builder.makeSetGlobal(stackPointer->name, - builder.makeGetLocal(local, PointerType)); + return builder.makeGlobalSet(stackPointer->name, + builder.makeLocalGet(local, PointerType)); }; // add stack restores to the returns FindAllPointers<Return> finder(func->body); @@ -74,10 +74,10 @@ getStackSpace(Index local, Function* func, Index size, Module& wasm) { // handle the returned value auto* block = builder.makeBlock(); auto temp = builder.addVar(func, ret->value->type); - block->list.push_back(builder.makeSetLocal(temp, ret->value)); + block->list.push_back(builder.makeLocalSet(temp, ret->value)); block->list.push_back(makeStackRestore()); block->list.push_back( - builder.makeReturn(builder.makeGetLocal(temp, ret->value->type))); + builder.makeReturn(builder.makeLocalGet(temp, ret->value->type))); block->finalize(); *ptr = block; } else { @@ -95,9 +95,9 @@ getStackSpace(Index local, Function* func, Index size, Module& wasm) { } else { // save the return value auto temp = builder.addVar(func, func->result); - block->list.push_back(builder.makeSetLocal(temp, func->body)); + block->list.push_back(builder.makeLocalSet(temp, func->body)); block->list.push_back(makeStackRestore()); - block->list.push_back(builder.makeGetLocal(temp, func->result)); + block->list.push_back(builder.makeLocalGet(temp, func->result)); } block->finalize(); func->body = block; diff --git a/src/asm2wasm.h b/src/asm2wasm.h index a4598c556..015c43053 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -1025,7 +1025,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { wasm.addGlobal( builder.makeGlobal(name, type, - builder.makeGetGlobal(import->name, type), + builder.makeGlobalGet(import->name, type), Builder::Mutable)); } } @@ -1262,7 +1262,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { // when function pointer casts are emulated. if (wasm.table.segments.size() == 0) { wasm.table.segments.emplace_back( - builder.makeGetGlobal(Name(TABLE_BASE), i32)); + builder.makeGlobalGet(Name(TABLE_BASE), i32)); } auto& segment = wasm.table.segments[0]; functionTableStarts[name] = @@ -1290,7 +1290,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { IString value = pair[1]->getIString(); if (key == Name("_emscripten_replace_memory")) { // asm.js memory growth provides this special non-asm function, - // which we don't need (we use grow_memory) + // which we don't need (we use memory.grow) assert(!wasm.getFunctionOrNull(value)); continue; } else if (key == UDIVMODDI4) { @@ -1732,7 +1732,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { if (curr->is<Return>()) { curr = curr->cast<Return>()->value; } - auto* get = curr->cast<GetGlobal>(); + auto* get = curr->cast<GlobalGet>(); tempRet0 = get->name; } // udivmoddi4 receives xl, xh, yl, yl, r, and @@ -1750,26 +1750,26 @@ void Asm2WasmBuilder::processAsm(Ref ast) { y64 = Builder::addVar(func, "y64", i64); auto* body = allocator.alloc<Block>(); body->list.push_back( - builder.makeSetLocal(x64, I64Utilities::recreateI64(builder, xl, xh))); + builder.makeLocalSet(x64, I64Utilities::recreateI64(builder, xl, xh))); body->list.push_back( - builder.makeSetLocal(y64, I64Utilities::recreateI64(builder, yl, yh))); + builder.makeLocalSet(y64, I64Utilities::recreateI64(builder, yl, yh))); body->list.push_back(builder.makeIf( - builder.makeGetLocal(r, i32), + builder.makeLocalGet(r, i32), builder.makeStore(8, 0, 8, - builder.makeGetLocal(r, i32), + builder.makeLocalGet(r, i32), builder.makeBinary(RemUInt64, - builder.makeGetLocal(x64, i64), - builder.makeGetLocal(y64, i64)), + builder.makeLocalGet(x64, i64), + builder.makeLocalGet(y64, i64)), i64))); body->list.push_back( - builder.makeSetLocal(x64, + builder.makeLocalSet(x64, builder.makeBinary(DivUInt64, - builder.makeGetLocal(x64, i64), - builder.makeGetLocal(y64, i64)))); + builder.makeLocalGet(x64, i64), + builder.makeLocalGet(y64, i64)))); body->list.push_back( - builder.makeSetGlobal(tempRet0, I64Utilities::getI64High(builder, x64))); + builder.makeGlobalSet(tempRet0, I64Utilities::getI64High(builder, x64))); body->list.push_back(I64Utilities::getI64Low(builder, x64)); body->finalize(); func->body = body; @@ -1855,7 +1855,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { IString name = ast->getIString(); if (functionVariables.has(name)) { // var in scope - auto ret = allocator.alloc<GetLocal>(); + auto ret = allocator.alloc<LocalGet>(); ret->index = function->getLocalIndex(name); ret->type = asmToWasmType(asmData.getType(name)); return ret; @@ -1883,7 +1883,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { ? true : (std::cerr << name.str << '\n', false)); MappedGlobal& global = mappedGlobals[name]; - return builder.makeGetGlobal(name, global.type); + return builder.makeGlobalGet(name, global.type); } if (ast->isNumber()) { auto ret = allocator.alloc<Const>(); @@ -1902,7 +1902,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { auto* assign = ast->asAssignName(); IString name = assign->target(); if (functionVariables.has(name)) { - auto ret = allocator.alloc<SetLocal>(); + auto ret = allocator.alloc<LocalSet>(); ret->index = function->getLocalIndex(assign->target()); ret->value = process(assign->value()); ret->setTee(false); @@ -1913,7 +1913,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { if (mappedGlobals.find(name) == mappedGlobals.end()) { Fatal() << "error: access of a non-existent global var " << name.str; } - auto* ret = builder.makeSetGlobal(name, process(assign->value())); + auto* ret = builder.makeGlobalSet(name, process(assign->value())); // 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(); @@ -1921,7 +1921,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { return ret; } return builder.makeSequence( - ret, builder.makeGetGlobal(name, ret->value->type)); + ret, builder.makeGlobalGet(name, ret->value->type)); } if (ast->isAssign()) { auto* assign = ast->asAssign(); @@ -2155,13 +2155,13 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { if (value->type == i32) { // No wasm support, so use a temp local ensureI32Temp(); - auto set = allocator.alloc<SetLocal>(); + auto set = allocator.alloc<LocalSet>(); set->index = function->getLocalIndex(I32_TEMP); set->value = value; set->setTee(false); set->finalize(); auto get = [&]() { - auto ret = allocator.alloc<GetLocal>(); + auto ret = allocator.alloc<LocalGet>(); ret->index = function->getLocalIndex(I32_TEMP); ret->type = i32; return ret; @@ -2264,9 +2264,9 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { view.bytes, 0, processUnshifted(ast[2][1], view.bytes), - builder.makeTeeLocal(temp, process(ast[2][2])), + builder.makeLocalTee(temp, process(ast[2][2])), type), - builder.makeGetLocal(temp, type)); + builder.makeLocalGet(temp, type)); } else if (name == Atomics_exchange) { return builder.makeAtomicRMW( AtomicRMWOp::Xchg, @@ -3092,7 +3092,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { // bits, then we can just look at the lower 32 bits auto temp = Builder::addVar(function, i64); auto* block = builder.makeBlock(); - block->list.push_back(builder.makeSetLocal(temp, offsetor)); + block->list.push_back(builder.makeLocalSet(temp, offsetor)); // if high bits, we can break to the default (we'll fill in the name // later) breakWhenNotMatching = builder.makeBreak( @@ -3101,10 +3101,10 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { builder.makeUnary( UnaryOp::WrapInt64, builder.makeBinary(BinaryOp::ShrUInt64, - builder.makeGetLocal(temp, i64), + builder.makeLocalGet(temp, i64), builder.makeConst(Literal(int64_t(32)))))); block->list.push_back(breakWhenNotMatching); - block->list.push_back(builder.makeGetLocal(temp, i64)); + block->list.push_back(builder.makeLocalGet(temp, i64)); block->finalize(); br->condition = builder.makeUnary(UnaryOp::WrapInt64, block); } @@ -3158,7 +3158,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { } else { // we can't switch, make an if-chain instead of br_table auto var = Builder::addVar(function, br->condition->type); - top->list.push_back(builder.makeSetLocal(var, br->condition)); + top->list.push_back(builder.makeLocalSet(var, br->condition)); auto* brHolder = top; If* chain = nullptr; If* first = nullptr; @@ -3175,7 +3175,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { name = nameMapper.pushLabelName("switch-case"); auto* iff = builder.makeIf( builder.makeBinary(br->condition->type == i32 ? EqInt32 : EqInt64, - builder.makeGetLocal(var, br->condition->type), + builder.makeLocalGet(var, br->condition->type), builder.makeConst(getLiteral(condition))), builder.makeBreak(name), chain); diff --git a/src/asmjs/shared-constants.cpp b/src/asmjs/shared-constants.cpp index f1123ba67..7f421a47d 100644 --- a/src/asmjs/shared-constants.cpp +++ b/src/asmjs/shared-constants.cpp @@ -89,8 +89,8 @@ cashew::IString WASM_ROTL32("__wasm_rotl_i32"); cashew::IString WASM_ROTL64("__wasm_rotl_i64"); cashew::IString WASM_ROTR32("__wasm_rotr_i32"); cashew::IString WASM_ROTR64("__wasm_rotr_i64"); -cashew::IString WASM_GROW_MEMORY("__wasm_grow_memory"); -cashew::IString WASM_CURRENT_MEMORY("__wasm_current_memory"); +cashew::IString WASM_MEMORY_GROW("__wasm_memory_grow"); +cashew::IString WASM_MEMORY_SIZE("__wasm_memory_size"); cashew::IString WASM_FETCH_HIGH_BITS("__wasm_fetch_high_bits"); cashew::IString INT64_TO_32_HIGH_BITS("i64toi32_i32$HIGH_BITS"); cashew::IString WASM_NEAREST_F32("__wasm_nearest_f32"); diff --git a/src/asmjs/shared-constants.h b/src/asmjs/shared-constants.h index e8d5d5693..8b4e8fff3 100644 --- a/src/asmjs/shared-constants.h +++ b/src/asmjs/shared-constants.h @@ -92,8 +92,8 @@ extern cashew::IString WASM_ROTL32; extern cashew::IString WASM_ROTL64; extern cashew::IString WASM_ROTR32; extern cashew::IString WASM_ROTR64; -extern cashew::IString WASM_GROW_MEMORY; -extern cashew::IString WASM_CURRENT_MEMORY; +extern cashew::IString WASM_MEMORY_GROW; +extern cashew::IString WASM_MEMORY_SIZE; extern cashew::IString WASM_FETCH_HIGH_BITS; extern cashew::IString INT64_TO_32_HIGH_BITS; extern cashew::IString WASM_NEAREST_F32; diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 03c6912f0..990612829 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -287,17 +287,17 @@ BinaryenExpressionId BinaryenCallId(void) { return Expression::Id::CallId; } BinaryenExpressionId BinaryenCallIndirectId(void) { return Expression::Id::CallIndirectId; } -BinaryenExpressionId BinaryenGetLocalId(void) { - return Expression::Id::GetLocalId; +BinaryenExpressionId BinaryenLocalGetId(void) { + return Expression::Id::LocalGetId; } -BinaryenExpressionId BinaryenSetLocalId(void) { - return Expression::Id::SetLocalId; +BinaryenExpressionId BinaryenLocalSetId(void) { + return Expression::Id::LocalSetId; } -BinaryenExpressionId BinaryenGetGlobalId(void) { - return Expression::Id::GetGlobalId; +BinaryenExpressionId BinaryenGlobalGetId(void) { + return Expression::Id::GlobalGetId; } -BinaryenExpressionId BinaryenSetGlobalId(void) { - return Expression::Id::SetGlobalId; +BinaryenExpressionId BinaryenGlobalSetId(void) { + return Expression::Id::GlobalSetId; } BinaryenExpressionId BinaryenLoadId(void) { return Expression::Id::LoadId; } BinaryenExpressionId BinaryenStoreId(void) { return Expression::Id::StoreId; } @@ -655,8 +655,8 @@ BinaryenOp BinaryenLtFloat64(void) { return LtFloat64; } BinaryenOp BinaryenLeFloat64(void) { return LeFloat64; } BinaryenOp BinaryenGtFloat64(void) { return GtFloat64; } BinaryenOp BinaryenGeFloat64(void) { return GeFloat64; } -BinaryenOp BinaryenCurrentMemory(void) { return CurrentMemory; } -BinaryenOp BinaryenGrowMemory(void) { return GrowMemory; } +BinaryenOp BinaryenMemorySize(void) { return MemorySize; } +BinaryenOp BinaryenMemoryGrow(void) { return MemoryGrow; } BinaryenOp BinaryenAtomicRMWAdd(void) { return AtomicRMWOp::Add; } BinaryenOp BinaryenAtomicRMWSub(void) { return AtomicRMWOp::Sub; } BinaryenOp BinaryenAtomicRMWAnd(void) { return AtomicRMWOp::And; } @@ -1041,13 +1041,13 @@ BinaryenExpressionRef BinaryenCallIndirect(BinaryenModuleRef module, ret->finalize(); return static_cast<Expression*>(ret); } -BinaryenExpressionRef BinaryenGetLocal(BinaryenModuleRef module, +BinaryenExpressionRef BinaryenLocalGet(BinaryenModuleRef module, BinaryenIndex index, BinaryenType type) { - auto* ret = ((Module*)module)->allocator.alloc<GetLocal>(); + auto* ret = ((Module*)module)->allocator.alloc<LocalGet>(); if (tracing) { - traceExpression(ret, "BinaryenGetLocal", index, type); + traceExpression(ret, "BinaryenLocalGet", index, type); } ret->index = index; @@ -1055,13 +1055,13 @@ BinaryenExpressionRef BinaryenGetLocal(BinaryenModuleRef module, ret->finalize(); return static_cast<Expression*>(ret); } -BinaryenExpressionRef BinaryenSetLocal(BinaryenModuleRef module, +BinaryenExpressionRef BinaryenLocalSet(BinaryenModuleRef module, BinaryenIndex index, BinaryenExpressionRef value) { - auto* ret = ((Module*)module)->allocator.alloc<SetLocal>(); + auto* ret = ((Module*)module)->allocator.alloc<LocalSet>(); if (tracing) { - traceExpression(ret, "BinaryenSetLocal", index, value); + traceExpression(ret, "BinaryenLocalSet", index, value); } ret->index = index; @@ -1070,13 +1070,13 @@ BinaryenExpressionRef BinaryenSetLocal(BinaryenModuleRef module, ret->finalize(); return static_cast<Expression*>(ret); } -BinaryenExpressionRef BinaryenTeeLocal(BinaryenModuleRef module, +BinaryenExpressionRef BinaryenLocalTee(BinaryenModuleRef module, BinaryenIndex index, BinaryenExpressionRef value) { - auto* ret = ((Module*)module)->allocator.alloc<SetLocal>(); + auto* ret = ((Module*)module)->allocator.alloc<LocalSet>(); if (tracing) { - traceExpression(ret, "BinaryenTeeLocal", index, value); + traceExpression(ret, "BinaryenLocalTee", index, value); } ret->index = index; @@ -1085,13 +1085,13 @@ BinaryenExpressionRef BinaryenTeeLocal(BinaryenModuleRef module, ret->finalize(); return static_cast<Expression*>(ret); } -BinaryenExpressionRef BinaryenGetGlobal(BinaryenModuleRef module, +BinaryenExpressionRef BinaryenGlobalGet(BinaryenModuleRef module, const char* name, BinaryenType type) { - auto* ret = ((Module*)module)->allocator.alloc<GetGlobal>(); + auto* ret = ((Module*)module)->allocator.alloc<GlobalGet>(); if (tracing) { - traceExpression(ret, "BinaryenGetGlobal", StringLit(name), type); + traceExpression(ret, "BinaryenGlobalGet", StringLit(name), type); } ret->name = name; @@ -1099,13 +1099,13 @@ BinaryenExpressionRef BinaryenGetGlobal(BinaryenModuleRef module, ret->finalize(); return static_cast<Expression*>(ret); } -BinaryenExpressionRef BinaryenSetGlobal(BinaryenModuleRef module, +BinaryenExpressionRef BinaryenGlobalSet(BinaryenModuleRef module, const char* name, BinaryenExpressionRef value) { - auto* ret = ((Module*)module)->allocator.alloc<SetGlobal>(); + auto* ret = ((Module*)module)->allocator.alloc<GlobalSet>(); if (tracing) { - traceExpression(ret, "BinaryenSetGlobal", StringLit(name), value); + traceExpression(ret, "BinaryenGlobalSet", StringLit(name), value); } ret->name = name; @@ -1787,79 +1787,79 @@ BinaryenExpressionRef BinaryenCallIndirectGetOperand(BinaryenExpressionRef expr, assert(index < static_cast<CallIndirect*>(expression)->operands.size()); return static_cast<CallIndirect*>(expression)->operands[index]; } -// GetLocal -BinaryenIndex BinaryenGetLocalGetIndex(BinaryenExpressionRef expr) { +// LocalGet +BinaryenIndex BinaryenLocalGetGetIndex(BinaryenExpressionRef expr) { if (tracing) { - std::cout << " BinaryenGetLocalGetIndex(expressions[" << expressions[expr] + std::cout << " BinaryenLocalGetGetIndex(expressions[" << expressions[expr] << "]);\n"; } auto* expression = (Expression*)expr; - assert(expression->is<GetLocal>()); - return static_cast<GetLocal*>(expression)->index; + assert(expression->is<LocalGet>()); + return static_cast<LocalGet*>(expression)->index; } -// SetLocal -int BinaryenSetLocalIsTee(BinaryenExpressionRef expr) { +// LocalSet +int BinaryenLocalSetIsTee(BinaryenExpressionRef expr) { if (tracing) { - std::cout << " BinaryenSetLocalIsTee(expressions[" << expressions[expr] + std::cout << " BinaryenLocalSetIsTee(expressions[" << expressions[expr] << "]);\n"; } auto* expression = (Expression*)expr; - assert(expression->is<SetLocal>()); - return static_cast<SetLocal*>(expression)->isTee(); + assert(expression->is<LocalSet>()); + return static_cast<LocalSet*>(expression)->isTee(); } -BinaryenIndex BinaryenSetLocalGetIndex(BinaryenExpressionRef expr) { +BinaryenIndex BinaryenLocalSetGetIndex(BinaryenExpressionRef expr) { if (tracing) { - std::cout << " BinaryenSetLocalGetIndex(expressions[" << expressions[expr] + std::cout << " BinaryenLocalSetGetIndex(expressions[" << expressions[expr] << "]);\n"; } auto* expression = (Expression*)expr; - assert(expression->is<SetLocal>()); - return static_cast<SetLocal*>(expression)->index; + assert(expression->is<LocalSet>()); + return static_cast<LocalSet*>(expression)->index; } -BinaryenExpressionRef BinaryenSetLocalGetValue(BinaryenExpressionRef expr) { +BinaryenExpressionRef BinaryenLocalSetGetValue(BinaryenExpressionRef expr) { if (tracing) { - std::cout << " BinaryenSetLocalGetValue(expressions[" << expressions[expr] + std::cout << " BinaryenLocalSetGetValue(expressions[" << expressions[expr] << "]);\n"; } auto* expression = (Expression*)expr; - assert(expression->is<SetLocal>()); - return static_cast<SetLocal*>(expression)->value; + assert(expression->is<LocalSet>()); + return static_cast<LocalSet*>(expression)->value; } -// GetGlobal -const char* BinaryenGetGlobalGetName(BinaryenExpressionRef expr) { +// GlobalGet +const char* BinaryenGlobalGetGetName(BinaryenExpressionRef expr) { if (tracing) { - std::cout << " BinaryenGetGlobalGetName(expressions[" << expressions[expr] + std::cout << " BinaryenGlobalGetGetName(expressions[" << expressions[expr] << "]);\n"; } auto* expression = (Expression*)expr; - assert(expression->is<GetGlobal>()); - return static_cast<GetGlobal*>(expression)->name.c_str(); + assert(expression->is<GlobalGet>()); + return static_cast<GlobalGet*>(expression)->name.c_str(); } -// SetGlobal -const char* BinaryenSetGlobalGetName(BinaryenExpressionRef expr) { +// GlobalSet +const char* BinaryenGlobalSetGetName(BinaryenExpressionRef expr) { if (tracing) { - std::cout << " BinaryenSetGlobalGetName(expressions[" << expressions[expr] + std::cout << " BinaryenGlobalSetGetName(expressions[" << expressions[expr] << "]);\n"; } auto* expression = (Expression*)expr; - assert(expression->is<SetGlobal>()); - return static_cast<SetGlobal*>(expression)->name.c_str(); + assert(expression->is<GlobalSet>()); + return static_cast<GlobalSet*>(expression)->name.c_str(); } -BinaryenExpressionRef BinaryenSetGlobalGetValue(BinaryenExpressionRef expr) { +BinaryenExpressionRef BinaryenGlobalSetGetValue(BinaryenExpressionRef expr) { if (tracing) { - std::cout << " BinaryenSetGlobalGetValue(expressions[" << expressions[expr] + std::cout << " BinaryenGlobalSetGetValue(expressions[" << expressions[expr] << "]);\n"; } auto* expression = (Expression*)expr; - assert(expression->is<SetGlobal>()); - return static_cast<SetGlobal*>(expression)->value; + assert(expression->is<GlobalSet>()); + return static_cast<GlobalSet*>(expression)->value; } // Host BinaryenOp BinaryenHostGetOp(BinaryenExpressionRef expr) { @@ -3079,17 +3079,19 @@ void BinaryenSetStart(BinaryenModuleRef module, BinaryenFunctionRef start) { // Features -BinaryenFeatures BinaryenGetFeatures(BinaryenModuleRef module) { +BinaryenFeatures BinaryenModuleGetFeatures(BinaryenModuleRef module) { if (tracing) { - std::cout << " BinaryenGetFeatures(the_module);\n"; + std::cout << " BinaryenModuleGetFeatures(the_module);\n"; } auto* wasm = static_cast<Module*>(module); return wasm->features.features; } -void BinaryenSetFeatures(BinaryenModuleRef module, BinaryenFeatures features) { +void BinaryenModuleSetFeatures(BinaryenModuleRef module, + BinaryenFeatures features) { if (tracing) { - std::cout << " BinaryenSetFeatures(the_module, " << features << ");\n"; + std::cout << " BinaryenModuleSetFeatures(the_module, " << features + << ");\n"; } auto* wasm = static_cast<Module*>(module); wasm->features.features = features; diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 19434692b..e287e2541 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -99,10 +99,10 @@ BinaryenExpressionId BinaryenBreakId(void); BinaryenExpressionId BinaryenSwitchId(void); BinaryenExpressionId BinaryenCallId(void); BinaryenExpressionId BinaryenCallIndirectId(void); -BinaryenExpressionId BinaryenGetLocalId(void); -BinaryenExpressionId BinaryenSetLocalId(void); -BinaryenExpressionId BinaryenGetGlobalId(void); -BinaryenExpressionId BinaryenSetGlobalId(void); +BinaryenExpressionId BinaryenLocalGetId(void); +BinaryenExpressionId BinaryenLocalSetId(void); +BinaryenExpressionId BinaryenGlobalGetId(void); +BinaryenExpressionId BinaryenGlobalSetId(void); BinaryenExpressionId BinaryenLoadId(void); BinaryenExpressionId BinaryenStoreId(void); BinaryenExpressionId BinaryenConstId(void); @@ -345,8 +345,8 @@ BinaryenOp BinaryenLtFloat64(void); BinaryenOp BinaryenLeFloat64(void); BinaryenOp BinaryenGtFloat64(void); BinaryenOp BinaryenGeFloat64(void); -BinaryenOp BinaryenCurrentMemory(void); -BinaryenOp BinaryenGrowMemory(void); +BinaryenOp BinaryenMemorySize(void); +BinaryenOp BinaryenMemoryGrow(void); BinaryenOp BinaryenAtomicRMWAdd(void); BinaryenOp BinaryenAtomicRMWSub(void); BinaryenOp BinaryenAtomicRMWAnd(void); @@ -542,33 +542,33 @@ BinaryenExpressionRef BinaryenCallIndirect(BinaryenModuleRef module, BinaryenExpressionRef* operands, BinaryenIndex numOperands, const char* type); -// GetLocal: Note the 'type' parameter. It might seem redundant, since the +// LocalGet: Note the 'type' parameter. It might seem redundant, since the // local at that index must have a type. However, this API lets you // build code "top-down": create a node, then its parents, and so // on, and finally create the function at the end. (Note that in fact // you do not mention a function when creating ExpressionRefs, only -// a module.) And since GetLocal is a leaf node, we need to be told +// a module.) And since LocalGet is a leaf node, we need to be told // its type. (Other nodes detect their type either from their // type or their opcode, or failing that, their children. But -// GetLocal has no children, it is where a "stream" of type info +// LocalGet has no children, it is where a "stream" of type info // begins.) // Note also that the index of a local can refer to a param or // a var, that is, either a parameter to the function or a variable // declared when you call BinaryenAddFunction. See BinaryenAddFunction // for more details. -BinaryenExpressionRef BinaryenGetLocal(BinaryenModuleRef module, +BinaryenExpressionRef BinaryenLocalGet(BinaryenModuleRef module, BinaryenIndex index, BinaryenType type); -BinaryenExpressionRef BinaryenSetLocal(BinaryenModuleRef module, +BinaryenExpressionRef BinaryenLocalSet(BinaryenModuleRef module, BinaryenIndex index, BinaryenExpressionRef value); -BinaryenExpressionRef BinaryenTeeLocal(BinaryenModuleRef module, +BinaryenExpressionRef BinaryenLocalTee(BinaryenModuleRef module, BinaryenIndex index, BinaryenExpressionRef value); -BinaryenExpressionRef BinaryenGetGlobal(BinaryenModuleRef module, +BinaryenExpressionRef BinaryenGlobalGet(BinaryenModuleRef module, const char* name, BinaryenType type); -BinaryenExpressionRef BinaryenSetGlobal(BinaryenModuleRef module, +BinaryenExpressionRef BinaryenGlobalSet(BinaryenModuleRef module, const char* name, BinaryenExpressionRef value); // Load: align can be 0, in which case it will be the natural alignment (equal @@ -722,16 +722,16 @@ BinaryenIndex BinaryenCallIndirectGetNumOperands(BinaryenExpressionRef expr); BinaryenExpressionRef BinaryenCallIndirectGetOperand(BinaryenExpressionRef expr, BinaryenIndex index); -BinaryenIndex BinaryenGetLocalGetIndex(BinaryenExpressionRef expr); +BinaryenIndex BinaryenLocalGetGetIndex(BinaryenExpressionRef expr); -int BinaryenSetLocalIsTee(BinaryenExpressionRef expr); -BinaryenIndex BinaryenSetLocalGetIndex(BinaryenExpressionRef expr); -BinaryenExpressionRef BinaryenSetLocalGetValue(BinaryenExpressionRef expr); +int BinaryenLocalSetIsTee(BinaryenExpressionRef expr); +BinaryenIndex BinaryenLocalSetGetIndex(BinaryenExpressionRef expr); +BinaryenExpressionRef BinaryenLocalSetGetValue(BinaryenExpressionRef expr); -const char* BinaryenGetGlobalGetName(BinaryenExpressionRef expr); +const char* BinaryenGlobalGetGetName(BinaryenExpressionRef expr); -const char* BinaryenSetGlobalGetName(BinaryenExpressionRef expr); -BinaryenExpressionRef BinaryenSetGlobalGetValue(BinaryenExpressionRef expr); +const char* BinaryenGlobalSetGetName(BinaryenExpressionRef expr); +BinaryenExpressionRef BinaryenGlobalSetGetValue(BinaryenExpressionRef expr); BinaryenOp BinaryenHostGetOp(BinaryenExpressionRef expr); const char* BinaryenHostGetNameOperand(BinaryenExpressionRef expr); @@ -945,8 +945,9 @@ void BinaryenSetStart(BinaryenModuleRef module, BinaryenFunctionRef start); // Features // These control what features are allowed when validation and in passes. -BinaryenFeatures BinaryenGetFeatures(BinaryenModuleRef module); -void BinaryenSetFeatures(BinaryenModuleRef module, BinaryenFeatures features); +BinaryenFeatures BinaryenModuleGetFeatures(BinaryenModuleRef module); +void BinaryenModuleSetFeatures(BinaryenModuleRef module, + BinaryenFeatures features); // // ========== Module Operations ========== diff --git a/src/cfg/Relooper.h b/src/cfg/Relooper.h index c38cb56b3..6b38816d0 100644 --- a/src/cfg/Relooper.h +++ b/src/cfg/Relooper.h @@ -49,11 +49,11 @@ public: RelooperBuilder(wasm::Module& wasm, wasm::Index labelHelper) : wasm::Builder(wasm), labelHelper(labelHelper) {} - wasm::GetLocal* makeGetLabel() { - return makeGetLocal(labelHelper, wasm::i32); + wasm::LocalGet* makeGetLabel() { + return makeLocalGet(labelHelper, wasm::i32); } - wasm::SetLocal* makeSetLabel(wasm::Index value) { - return makeSetLocal(labelHelper, makeConst(wasm::Literal(int32_t(value)))); + wasm::LocalSet* makeSetLabel(wasm::Index value) { + return makeLocalSet(labelHelper, makeConst(wasm::Literal(int32_t(value)))); } wasm::Binary* makeCheckLabel(wasm::Index value) { return makeBinary( diff --git a/src/cfg/liveness-traversal.h b/src/cfg/liveness-traversal.h index a0ce214bc..d665c07af 100644 --- a/src/cfg/liveness-traversal.h +++ b/src/cfg/liveness-traversal.h @@ -35,7 +35,7 @@ namespace wasm { // may be a great many potential elements but actual sets // may be fairly small. Specifically, we use a sorted // vector. -typedef SortedVector LocalSet; +typedef SortedVector SetOfLocals; // A liveness-relevant action. Supports a get, a set, or an // "other" which can be used for other purposes, to mark @@ -51,10 +51,10 @@ struct LivenessAction { : what(what), index(index), origin(origin), effective(false) { assert(what != Other); if (what == Get) { - assert((*origin)->is<GetLocal>()); + assert((*origin)->is<LocalGet>()); } if (what == Set) { - assert((*origin)->is<SetLocal>()); + assert((*origin)->is<LocalSet>()); } } LivenessAction(Expression** origin) : what(Other), origin(origin) {} @@ -66,9 +66,9 @@ struct LivenessAction { // Helper to remove a set that is a copy we know is not needed. This // updates both the IR and the action. void removeCopy() { - auto* set = (*origin)->cast<SetLocal>(); + auto* set = (*origin)->cast<LocalSet>(); if (set->isTee()) { - *origin = set->value->cast<GetLocal>(); + *origin = set->value->cast<LocalGet>(); } else { ExpressionManipulator::nop(set); } @@ -81,7 +81,7 @@ struct LivenessAction { // information about liveness in a basic block struct Liveness { - LocalSet start, end; // live locals at the start and end + SetOfLocals start, end; // live locals at the start and end std::vector<LivenessAction> actions; // actions occurring in this block #if LIVENESS_DEBUG @@ -114,8 +114,8 @@ struct LivenessWalker : public CFGWalker<SubType, VisitorType, Liveness> { // cfg traversal work - static void doVisitGetLocal(SubType* self, Expression** currp) { - auto* curr = (*currp)->cast<GetLocal>(); + static void doVisitLocalGet(SubType* self, Expression** currp) { + auto* curr = (*currp)->cast<LocalGet>(); // if in unreachable code, ignore if (!self->currBasicBlock) { *currp = Builder(*self->getModule()).replaceWithIdenticalType(curr); @@ -125,8 +125,8 @@ struct LivenessWalker : public CFGWalker<SubType, VisitorType, Liveness> { LivenessAction::Get, curr->index, currp); } - static void doVisitSetLocal(SubType* self, Expression** currp) { - auto* curr = (*currp)->cast<SetLocal>(); + static void doVisitLocalSet(SubType* self, Expression** currp) { + auto* curr = (*currp)->cast<LocalSet>(); // if in unreachable code, we don't need the tee (but might need the value, // if it has side effects) if (!self->currBasicBlock) { @@ -154,16 +154,16 @@ struct LivenessWalker : public CFGWalker<SubType, VisitorType, Liveness> { // recurse into nested ifs, and block return values? Those cases are trickier, // need to count to see if worth it. // TODO: an if can have two copies - GetLocal* getCopy(SetLocal* set) { - if (auto* get = set->value->dynCast<GetLocal>()) { + LocalGet* getCopy(LocalSet* set) { + if (auto* get = set->value->dynCast<LocalGet>()) { return get; } if (auto* iff = set->value->dynCast<If>()) { - if (auto* get = iff->ifTrue->dynCast<GetLocal>()) { + if (auto* get = iff->ifTrue->dynCast<LocalGet>()) { return get; } if (iff->ifFalse) { - if (auto* get = iff->ifFalse->dynCast<GetLocal>()) { + if (auto* get = iff->ifFalse->dynCast<LocalGet>()) { return get; } } @@ -208,7 +208,7 @@ struct LivenessWalker : public CFGWalker<SubType, VisitorType, Liveness> { auto iter = queue.begin(); auto* curr = *iter; queue.erase(iter); - LocalSet live; + SetOfLocals live; if (!mergeStartsAndCheckChange(curr->out, curr->contents.end, live)) { continue; } @@ -232,8 +232,8 @@ struct LivenessWalker : public CFGWalker<SubType, VisitorType, Liveness> { // whether anything changed vs an old state (which indicates further // processing is necessary). bool mergeStartsAndCheckChange(std::vector<BasicBlock*>& blocks, - LocalSet& old, - LocalSet& ret) { + SetOfLocals& old, + SetOfLocals& ret) { if (blocks.size() == 0) { return false; } @@ -248,7 +248,7 @@ struct LivenessWalker : public CFGWalker<SubType, VisitorType, Liveness> { } void scanLivenessThroughActions(std::vector<LivenessAction>& actions, - LocalSet& live) { + SetOfLocals& live) { // move towards the front for (int i = int(actions.size()) - 1; i >= 0; i--) { auto& action = actions[i]; diff --git a/src/dataflow/graph.h b/src/dataflow/graph.h index f41346857..5c01714f5 100644 --- a/src/dataflow/graph.h +++ b/src/dataflow/graph.h @@ -46,7 +46,7 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> { Node bad = Node(Node::Type::Bad); // Connects a specific set to the data in its value. - std::unordered_map<SetLocal*, Node*> setNodeMap; + std::unordered_map<LocalSet*, Node*> setNodeMap; // Maps a control-flow expression to the conditions for it. Currently, // this maps an if to the conditions for its arms @@ -65,7 +65,7 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> { std::unordered_map<Node*, Expression*> nodeParentMap; // All the sets, in order of appearance. - std::vector<SetLocal*> sets; + std::vector<LocalSet*> sets; // The function being processed. Function* func; @@ -206,10 +206,10 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> { return doVisitIf(iff); } else if (auto* loop = curr->dynCast<Loop>()) { return doVisitLoop(loop); - } else if (auto* get = curr->dynCast<GetLocal>()) { - return doVisitGetLocal(get); - } else if (auto* set = curr->dynCast<SetLocal>()) { - return doVisitSetLocal(set); + } else if (auto* get = curr->dynCast<LocalGet>()) { + return doVisitLocalGet(get); + } else if (auto* set = curr->dynCast<LocalSet>()) { + return doVisitLocalSet(set); } else if (auto* br = curr->dynCast<Break>()) { return doVisitBreak(br); } else if (auto* sw = curr->dynCast<Switch>()) { @@ -385,7 +385,7 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> { setInUnreachable(); return &bad; } - Node* doVisitGetLocal(GetLocal* curr) { + Node* doVisitLocalGet(LocalGet* curr) { if (!isRelevantLocal(curr->index) || isInUnreachable()) { return &bad; } @@ -393,7 +393,7 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> { auto* node = locals[curr->index]; return node; } - Node* doVisitSetLocal(SetLocal* curr) { + Node* doVisitLocalSet(LocalSet* curr) { if (!isRelevantLocal(curr->index) || isInUnreachable()) { return &bad; } @@ -735,12 +735,12 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> { // Given a node representing something that is local.set'd, return // the set. - SetLocal* getSet(Node* node) { + LocalSet* getSet(Node* node) { auto iter = nodeParentMap.find(node); if (iter == nodeParentMap.end()) { return nullptr; } - return iter->second->dynCast<SetLocal>(); + return iter->second->dynCast<LocalSet>(); } // Given an expression, return the parent if such exists. @@ -753,9 +753,9 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> { } // Given an expression, return the set for it if such exists. - SetLocal* getSet(Expression* curr) { + LocalSet* getSet(Expression* curr) { auto* parent = getParent(curr); - return parent ? parent->dynCast<SetLocal>() : nullptr; + return parent ? parent->dynCast<LocalSet>() : nullptr; } // Creates an expression that uses a node. Generally, a node represents @@ -766,13 +766,13 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> { // The index is the wasm local that we assign to when implementing // the phi; get from there. auto index = node->index; - return builder.makeGetLocal(index, func->getLocalType(index)); + return builder.makeLocalGet(index, func->getLocalType(index)); } else if (node->isConst()) { return builder.makeConst(node->expr->cast<Const>()->value); } else if (node->isExpr()) { // Find the set we are a value of. auto index = getSet(node)->index; - return builder.makeGetLocal(index, func->getLocalType(index)); + return builder.makeLocalGet(index, func->getLocalType(index)); } else if (node->isZext()) { // i1 zexts are a no-op for wasm return makeUse(node->values[0]); diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc index f49a47842..65a780b8b 100644 --- a/src/gen-s-parser.inc +++ b/src/gen-s-parser.inc @@ -38,20 +38,12 @@ switch (op[0]) { } } case 'c': { - switch (op[1]) { - case 'a': { - switch (op[4]) { - case '\0': - if (strcmp(op, "call") == 0) { return makeCall(s); } - goto parse_error; - case '_': - if (strcmp(op, "call_indirect") == 0) { return makeCallIndirect(s); } - goto parse_error; - default: goto parse_error; - } - } - case 'u': - if (strcmp(op, "current_memory") == 0) { return makeHost(s, HostOp::CurrentMemory); } + switch (op[4]) { + case '\0': + if (strcmp(op, "call") == 0) { return makeCall(s); } + goto parse_error; + case '_': + if (strcmp(op, "call_indirect") == 0) { return makeCallIndirect(s); } goto parse_error; default: goto parse_error; } @@ -605,20 +597,12 @@ switch (op[0]) { } } case 'g': { - switch (op[1]) { - case 'l': { - switch (op[7]) { - case 'g': - if (strcmp(op, "global.get") == 0) { return makeGetGlobal(s); } - goto parse_error; - case 's': - if (strcmp(op, "global.set") == 0) { return makeSetGlobal(s); } - goto parse_error; - default: goto parse_error; - } - } - case 'r': - if (strcmp(op, "grow_memory") == 0) { return makeHost(s, HostOp::GrowMemory); } + switch (op[7]) { + case 'g': + if (strcmp(op, "global.get") == 0) { return makeGlobalGet(s); } + goto parse_error; + case 's': + if (strcmp(op, "global.set") == 0) { return makeGlobalSet(s); } goto parse_error; default: goto parse_error; } @@ -2174,13 +2158,13 @@ switch (op[0]) { case 'c': { switch (op[6]) { case 'g': - if (strcmp(op, "local.get") == 0) { return makeGetLocal(s); } + if (strcmp(op, "local.get") == 0) { return makeLocalGet(s); } goto parse_error; case 's': - if (strcmp(op, "local.set") == 0) { return makeSetLocal(s); } + if (strcmp(op, "local.set") == 0) { return makeLocalSet(s); } goto parse_error; case 't': - if (strcmp(op, "local.tee") == 0) { return makeTeeLocal(s); } + if (strcmp(op, "local.tee") == 0) { return makeLocalTee(s); } goto parse_error; default: goto parse_error; } @@ -2199,9 +2183,15 @@ switch (op[0]) { case 'f': if (strcmp(op, "memory.fill") == 0) { return makeMemoryFill(s); } goto parse_error; + case 'g': + if (strcmp(op, "memory.grow") == 0) { return makeHost(s, HostOp::MemoryGrow); } + goto parse_error; case 'i': if (strcmp(op, "memory.init") == 0) { return makeMemoryInit(s); } goto parse_error; + case 's': + if (strcmp(op, "memory.size") == 0) { return makeHost(s, HostOp::MemorySize); } + goto parse_error; default: goto parse_error; } } diff --git a/src/ir/ExpressionAnalyzer.cpp b/src/ir/ExpressionAnalyzer.cpp index de37cd08b..32e763a45 100644 --- a/src/ir/ExpressionAnalyzer.cpp +++ b/src/ir/ExpressionAnalyzer.cpp @@ -136,12 +136,12 @@ template<typename T> void visitImmediates(Expression* curr, T& visitor) { void visitCallIndirect(CallIndirect* curr) { visitor.visitNonScopeName(curr->fullType); } - void visitGetLocal(GetLocal* curr) { visitor.visitIndex(curr->index); } - void visitSetLocal(SetLocal* curr) { visitor.visitIndex(curr->index); } - void visitGetGlobal(GetGlobal* curr) { + void visitLocalGet(LocalGet* curr) { visitor.visitIndex(curr->index); } + void visitLocalSet(LocalSet* curr) { visitor.visitIndex(curr->index); } + void visitGlobalGet(GlobalGet* curr) { visitor.visitNonScopeName(curr->name); } - void visitSetGlobal(SetGlobal* curr) { + void visitGlobalSet(GlobalSet* curr) { visitor.visitNonScopeName(curr->name); } void visitLoad(Load* curr) { diff --git a/src/ir/ExpressionManipulator.cpp b/src/ir/ExpressionManipulator.cpp index fcdfdf152..b52a8dd82 100644 --- a/src/ir/ExpressionManipulator.cpp +++ b/src/ir/ExpressionManipulator.cpp @@ -85,21 +85,21 @@ flexibleCopy(Expression* original, Module& wasm, CustomCopier custom) { } return ret; } - Expression* visitGetLocal(GetLocal* curr) { - return builder.makeGetLocal(curr->index, curr->type); + Expression* visitLocalGet(LocalGet* curr) { + return builder.makeLocalGet(curr->index, curr->type); } - Expression* visitSetLocal(SetLocal* curr) { + Expression* visitLocalSet(LocalSet* curr) { if (curr->isTee()) { - return builder.makeTeeLocal(curr->index, copy(curr->value)); + return builder.makeLocalTee(curr->index, copy(curr->value)); } else { - return builder.makeSetLocal(curr->index, copy(curr->value)); + return builder.makeLocalSet(curr->index, copy(curr->value)); } } - Expression* visitGetGlobal(GetGlobal* curr) { - return builder.makeGetGlobal(curr->name, curr->type); + Expression* visitGlobalGet(GlobalGet* curr) { + return builder.makeGlobalGet(curr->name, curr->type); } - Expression* visitSetGlobal(SetGlobal* curr) { - return builder.makeSetGlobal(curr->name, copy(curr->value)); + Expression* visitGlobalSet(GlobalSet* curr) { + return builder.makeGlobalSet(curr->name, copy(curr->value)); } Expression* visitLoad(Load* curr) { if (curr->isAtomic) { diff --git a/src/ir/LocalGraph.cpp b/src/ir/LocalGraph.cpp index a66009ec2..dd7046351 100644 --- a/src/ir/LocalGraph.cpp +++ b/src/ir/LocalGraph.cpp @@ -31,7 +31,7 @@ struct Info { // actions occurring in this block: local.gets and local.sets std::vector<Expression*> actions; // for each index, the last local.set for it - std::unordered_map<Index, SetLocal*> lastSets; + std::unordered_map<Index, LocalSet*> lastSets; }; // flow helper class. flows the gets to their sets @@ -55,8 +55,8 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { // cfg traversal work - static void doVisitGetLocal(Flower* self, Expression** currp) { - auto* curr = (*currp)->cast<GetLocal>(); + static void doVisitLocalGet(Flower* self, Expression** currp) { + auto* curr = (*currp)->cast<LocalGet>(); // if in unreachable code, skip if (!self->currBasicBlock) { return; @@ -65,8 +65,8 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { self->locations[curr] = currp; } - static void doVisitSetLocal(Flower* self, Expression** currp) { - auto* curr = (*currp)->cast<SetLocal>(); + static void doVisitLocalSet(Flower* self, Expression** currp) { + auto* curr = (*currp)->cast<LocalSet>(); // if in unreachable code, skip if (!self->currBasicBlock) { return; @@ -95,11 +95,11 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { // scanning them linearly is efficient, avoiding hash computations (while // in Info, it's convenient to have a map so we can assign them easily, // where the last one seen overwrites the previous; and, we do that O(1)). - std::vector<std::pair<Index, SetLocal*>> lastSets; + std::vector<std::pair<Index, LocalSet*>> lastSets; }; auto numLocals = func->getNumLocals(); - std::vector<std::vector<GetLocal*>> allGets; + std::vector<std::vector<LocalGet*>> allGets; allGets.resize(numLocals); std::vector<FlowBlock*> work; @@ -158,11 +158,11 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { // move towards the front, handling things as we go for (int i = int(actions.size()) - 1; i >= 0; i--) { auto* action = actions[i]; - if (auto* get = action->dynCast<GetLocal>()) { + if (auto* get = action->dynCast<LocalGet>()) { allGets[get->index].push_back(get); } else { // This set is the only set for all those gets. - auto* set = action->cast<SetLocal>(); + auto* set = action->cast<LocalSet>(); auto& gets = allGets[set->index]; for (auto* get : gets) { getSetses[get].insert(set); @@ -202,7 +202,7 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { auto lastSet = std::find_if(pred->lastSets.begin(), pred->lastSets.end(), - [&](std::pair<Index, SetLocal*>& value) { + [&](std::pair<Index, LocalSet*>& value) { return value.first == index; }); if (lastSet != pred->lastSets.end()) { @@ -248,13 +248,13 @@ LocalGraph::LocalGraph(Function* func) { void LocalGraph::computeInfluences() { for (auto& pair : locations) { auto* curr = pair.first; - if (auto* set = curr->dynCast<SetLocal>()) { - FindAll<GetLocal> findAll(set->value); + if (auto* set = curr->dynCast<LocalSet>()) { + FindAll<LocalGet> findAll(set->value); for (auto* get : findAll.list) { getInfluences[get].insert(set); } } else { - auto* get = curr->cast<GetLocal>(); + auto* get = curr->cast<LocalGet>(); for (auto* set : getSetses[get]) { setInfluences[set].insert(get); } @@ -263,7 +263,7 @@ void LocalGraph::computeInfluences() { } void LocalGraph::computeSSAIndexes() { - std::unordered_map<Index, std::set<SetLocal*>> indexSets; + std::unordered_map<Index, std::set<LocalSet*>> indexSets; for (auto& pair : getSetses) { auto* get = pair.first; auto& sets = pair.second; @@ -273,7 +273,7 @@ void LocalGraph::computeSSAIndexes() { } for (auto& pair : locations) { auto* curr = pair.first; - if (auto* set = curr->dynCast<SetLocal>()) { + if (auto* set = curr->dynCast<LocalSet>()) { auto& sets = indexSets[set->index]; if (sets.size() == 1 && *sets.begin() != curr) { // While it has just one set, it is not the right one (us), diff --git a/src/ir/ReFinalize.cpp b/src/ir/ReFinalize.cpp index ca058e2be..0bd8a7a0f 100644 --- a/src/ir/ReFinalize.cpp +++ b/src/ir/ReFinalize.cpp @@ -129,10 +129,10 @@ void ReFinalize::visitSwitch(Switch* curr) { } void ReFinalize::visitCall(Call* curr) { curr->finalize(); } void ReFinalize::visitCallIndirect(CallIndirect* curr) { curr->finalize(); } -void ReFinalize::visitGetLocal(GetLocal* curr) { curr->finalize(); } -void ReFinalize::visitSetLocal(SetLocal* curr) { curr->finalize(); } -void ReFinalize::visitGetGlobal(GetGlobal* curr) { curr->finalize(); } -void ReFinalize::visitSetGlobal(SetGlobal* curr) { curr->finalize(); } +void ReFinalize::visitLocalGet(LocalGet* curr) { curr->finalize(); } +void ReFinalize::visitLocalSet(LocalSet* curr) { curr->finalize(); } +void ReFinalize::visitGlobalGet(GlobalGet* curr) { curr->finalize(); } +void ReFinalize::visitGlobalSet(GlobalSet* curr) { curr->finalize(); } void ReFinalize::visitLoad(Load* curr) { curr->finalize(); } void ReFinalize::visitStore(Store* curr) { curr->finalize(); } void ReFinalize::visitAtomicRMW(AtomicRMW* curr) { curr->finalize(); } diff --git a/src/ir/cost.h b/src/ir/cost.h index 5e09ee90e..5fb32f933 100644 --- a/src/ir/cost.h +++ b/src/ir/cost.h @@ -65,10 +65,10 @@ struct CostAnalyzer : public Visitor<CostAnalyzer, Index> { } return ret; } - Index visitGetLocal(GetLocal* curr) { return 0; } - Index visitSetLocal(SetLocal* curr) { return 1; } - Index visitGetGlobal(GetGlobal* curr) { return 1; } - Index visitSetGlobal(SetGlobal* curr) { return 2; } + Index visitLocalGet(LocalGet* curr) { return 0; } + Index visitLocalSet(LocalSet* curr) { return 1; } + Index visitGlobalGet(GlobalGet* curr) { return 1; } + Index visitGlobalSet(GlobalSet* curr) { return 2; } Index visitLoad(Load* curr) { return 1 + visit(curr->ptr) + 10 * curr->isAtomic; } diff --git a/src/ir/effects.h b/src/ir/effects.h index bbcce07de..7c64beafd 100644 --- a/src/ir/effects.h +++ b/src/ir/effects.h @@ -64,7 +64,7 @@ struct EffectAnalyzer // side effects bool implicitTrap = false; // An atomic load/store/RMW/Cmpxchg or an operator that has a defined ordering - // wrt atomics (e.g. grow_memory) + // wrt atomics (e.g. memory.grow) bool isAtomic = false; // Helper functions to check for various effect types @@ -231,10 +231,10 @@ struct EffectAnalyzer } } void visitCallIndirect(CallIndirect* curr) { calls = true; } - void visitGetLocal(GetLocal* curr) { localsRead.insert(curr->index); } - void visitSetLocal(SetLocal* curr) { localsWritten.insert(curr->index); } - void visitGetGlobal(GetGlobal* curr) { globalsRead.insert(curr->name); } - void visitSetGlobal(SetGlobal* curr) { globalsWritten.insert(curr->name); } + void visitLocalGet(LocalGet* curr) { localsRead.insert(curr->index); } + void visitLocalSet(LocalSet* curr) { localsWritten.insert(curr->index); } + void visitGlobalGet(GlobalGet* curr) { globalsRead.insert(curr->name); } + void visitGlobalSet(GlobalSet* curr) { globalsWritten.insert(curr->name); } void visitLoad(Load* curr) { readsMemory = true; isAtomic |= curr->isAtomic; @@ -360,10 +360,10 @@ struct EffectAnalyzer void visitReturn(Return* curr) { branches = true; } void visitHost(Host* curr) { calls = true; - // grow_memory modifies the set of valid addresses, and thus can be modeled + // memory.grow modifies the set of valid addresses, and thus can be modeled // as modifying memory writesMemory = true; - // Atomics are also sequentially consistent with grow_memory. + // Atomics are also sequentially consistent with memory.grow. isAtomic = true; } void visitNop(Nop* curr) {} diff --git a/src/ir/flat.h b/src/ir/flat.h index 199d5e35e..b9d272bf5 100644 --- a/src/ir/flat.h +++ b/src/ir/flat.h @@ -75,11 +75,11 @@ inline void verifyFlatness(Function* func) { if (isControlFlowStructure(curr)) { verify(!isConcreteType(curr->type), "control flow structures must not flow values"); - } else if (curr->is<SetLocal>()) { + } else if (curr->is<LocalSet>()) { verify(!isConcreteType(curr->type), "tees are not allowed, only sets"); } else { for (auto* child : ChildIterator(curr)) { - verify(child->is<Const>() || child->is<GetLocal>() || + verify(child->is<Const>() || child->is<LocalGet>() || child->is<Unreachable>(), "instructions must only have const, local.get, or unreachable " "as children"); diff --git a/src/ir/global-utils.h b/src/ir/global-utils.h index 113a37f31..93e5c8a67 100644 --- a/src/ir/global-utils.h +++ b/src/ir/global-utils.h @@ -44,7 +44,7 @@ getGlobalInitializedToImport(Module& wasm, Name module, Name base) { // find a global inited to it Global* ret = nullptr; ModuleUtils::iterDefinedGlobals(wasm, [&](Global* defined) { - if (auto* init = defined->init->dynCast<GetGlobal>()) { + if (auto* init = defined->init->dynCast<GlobalGet>()) { if (init->name == imported) { ret = defined; } diff --git a/src/ir/local-graph.h b/src/ir/local-graph.h index ae389c899..42a560c61 100644 --- a/src/ir/local-graph.h +++ b/src/ir/local-graph.h @@ -36,9 +36,9 @@ struct LocalGraph { LocalGraph(Function* func); // the local.sets relevant for an index or a get. - typedef std::set<SetLocal*> Sets; + typedef std::set<LocalSet*> Sets; - typedef std::map<GetLocal*, Sets> GetSetses; + typedef std::map<LocalGet*, Sets> GetSetses; typedef std::map<Expression*, Expression**> Locations; @@ -54,9 +54,9 @@ struct LocalGraph { void computeInfluences(); // for each get, the sets whose values are influenced by that get - std::unordered_map<GetLocal*, std::unordered_set<SetLocal*>> getInfluences; + std::unordered_map<LocalGet*, std::unordered_set<LocalSet*>> getInfluences; // for each set, the gets whose values are influenced by that set - std::unordered_map<SetLocal*, std::unordered_set<GetLocal*>> setInfluences; + std::unordered_map<LocalSet*, std::unordered_set<LocalGet*>> setInfluences; // Optional: Compute the local indexes that are SSA, in the sense of // * a single set for all the gets for that local index diff --git a/src/ir/local-utils.h b/src/ir/local-utils.h index 5d6b660cd..c2a99b5af 100644 --- a/src/ir/local-utils.h +++ b/src/ir/local-utils.h @@ -22,12 +22,12 @@ namespace wasm { -struct GetLocalCounter : public PostWalker<GetLocalCounter> { +struct LocalGetCounter : public PostWalker<LocalGetCounter> { std::vector<Index> num; - GetLocalCounter() = default; - GetLocalCounter(Function* func) { analyze(func, func->body); } - GetLocalCounter(Function* func, Expression* ast) { analyze(func, ast); } + LocalGetCounter() = default; + LocalGetCounter(Function* func) { analyze(func, func->body); } + LocalGetCounter(Function* func, Expression* ast) { analyze(func, ast); } void analyze(Function* func) { analyze(func, func->body); } void analyze(Function* func, Expression* ast) { @@ -36,7 +36,7 @@ struct GetLocalCounter : public PostWalker<GetLocalCounter> { walk(ast); } - void visitGetLocal(GetLocal* curr) { num[curr->index]++; } + void visitLocalGet(LocalGet* curr) { num[curr->index]++; } }; // Removes trivially unneeded sets: sets for whom there is no possible get, and @@ -44,33 +44,33 @@ struct GetLocalCounter : public PostWalker<GetLocalCounter> { struct UnneededSetRemover : public PostWalker<UnneededSetRemover> { PassOptions& passOptions; - GetLocalCounter* getLocalCounter = nullptr; + LocalGetCounter* localGetCounter = nullptr; UnneededSetRemover(Function* func, PassOptions& passOptions) : passOptions(passOptions) { - GetLocalCounter counter(func); + LocalGetCounter counter(func); UnneededSetRemover inner(counter, func, passOptions); removed = inner.removed; } - UnneededSetRemover(GetLocalCounter& getLocalCounter, + UnneededSetRemover(LocalGetCounter& localGetCounter, Function* func, PassOptions& passOptions) - : passOptions(passOptions), getLocalCounter(&getLocalCounter) { + : passOptions(passOptions), localGetCounter(&localGetCounter) { walk(func->body); } bool removed = false; - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { // If no possible uses, remove. - if (getLocalCounter->num[curr->index] == 0) { + if (localGetCounter->num[curr->index] == 0) { remove(curr); } // If setting the same value as we already have, remove. auto* value = curr->value; while (true) { - if (auto* set = value->dynCast<SetLocal>()) { + if (auto* set = value->dynCast<LocalSet>()) { if (set->index == curr->index) { remove(curr); } else { @@ -78,7 +78,7 @@ struct UnneededSetRemover : public PostWalker<UnneededSetRemover> { value = set->value; continue; } - } else if (auto* get = value->dynCast<GetLocal>()) { + } else if (auto* get = value->dynCast<LocalGet>()) { if (get->index == curr->index) { remove(curr); } @@ -87,12 +87,12 @@ struct UnneededSetRemover : public PostWalker<UnneededSetRemover> { } } - void remove(SetLocal* set) { + void remove(LocalSet* set) { auto* value = set->value; if (set->isTee()) { replaceCurrent(value); } else if (EffectAnalyzer(passOptions, set->value).hasSideEffects()) { - Drop* drop = ExpressionManipulator::convert<SetLocal, Drop>(set); + Drop* drop = ExpressionManipulator::convert<LocalSet, Drop>(set); drop->value = value; drop->finalize(); } else { diff --git a/src/ir/localize.h b/src/ir/localize.h index 05eadc593..ff454382d 100644 --- a/src/ir/localize.h +++ b/src/ir/localize.h @@ -30,13 +30,13 @@ struct Localizer { Localizer(Expression* input, Function* func, Module* wasm) { expr = input; - if (auto* get = expr->dynCast<GetLocal>()) { + if (auto* get = expr->dynCast<LocalGet>()) { index = get->index; - } else if (auto* set = expr->dynCast<SetLocal>()) { + } else if (auto* set = expr->dynCast<LocalSet>()) { index = set->index; } else { index = Builder::addVar(func, expr->type); - expr = Builder(*wasm).makeTeeLocal(index, expr); + expr = Builder(*wasm).makeLocalTee(index, expr); } } }; diff --git a/src/ir/properties.h b/src/ir/properties.h index b664ab008..bb88af6c5 100644 --- a/src/ir/properties.h +++ b/src/ir/properties.h @@ -159,7 +159,7 @@ inline Expression* getFallthrough(Expression* curr) { if (curr->type == unreachable) { return curr; } - if (auto* set = curr->dynCast<SetLocal>()) { + if (auto* set = curr->dynCast<LocalSet>()) { if (set->isTee()) { return getFallthrough(set->value); } diff --git a/src/ir/utils.h b/src/ir/utils.h index 4e941b8d0..a8af3ed18 100644 --- a/src/ir/utils.h +++ b/src/ir/utils.h @@ -118,10 +118,10 @@ struct ReFinalize void visitSwitch(Switch* curr); void visitCall(Call* curr); void visitCallIndirect(CallIndirect* curr); - void visitGetLocal(GetLocal* curr); - void visitSetLocal(SetLocal* curr); - void visitGetGlobal(GetGlobal* curr); - void visitSetGlobal(SetGlobal* curr); + void visitLocalGet(LocalGet* curr); + void visitLocalSet(LocalSet* curr); + void visitGlobalGet(GlobalGet* curr); + void visitGlobalSet(GlobalSet* curr); void visitLoad(Load* curr); void visitStore(Store* curr); void visitAtomicRMW(AtomicRMW* curr); @@ -174,10 +174,10 @@ struct ReFinalizeNode : public OverriddenVisitor<ReFinalizeNode> { void visitSwitch(Switch* curr) { curr->finalize(); } void visitCall(Call* curr) { curr->finalize(); } void visitCallIndirect(CallIndirect* curr) { curr->finalize(); } - void visitGetLocal(GetLocal* curr) { curr->finalize(); } - void visitSetLocal(SetLocal* curr) { curr->finalize(); } - void visitGetGlobal(GetGlobal* curr) { curr->finalize(); } - void visitSetGlobal(SetGlobal* curr) { curr->finalize(); } + void visitLocalGet(LocalGet* curr) { curr->finalize(); } + void visitLocalSet(LocalSet* curr) { curr->finalize(); } + void visitGlobalGet(GlobalGet* curr) { curr->finalize(); } + void visitGlobalSet(GlobalSet* curr) { curr->finalize(); } void visitLoad(Load* curr) { curr->finalize(); } void visitStore(Store* curr) { curr->finalize(); } void visitAtomicRMW(AtomicRMW* curr) { curr->finalize(); } @@ -302,19 +302,19 @@ struct I64Utilities { static Expression* recreateI64(Builder& builder, Index low, Index high) { return recreateI64( - builder, builder.makeGetLocal(low, i32), builder.makeGetLocal(high, i32)); + builder, builder.makeLocalGet(low, i32), builder.makeLocalGet(high, i32)); }; static Expression* getI64High(Builder& builder, Index index) { return builder.makeUnary( WrapInt64, builder.makeBinary(ShrUInt64, - builder.makeGetLocal(index, i64), + builder.makeLocalGet(index, i64), builder.makeConst(Literal(int64_t(32))))); } static Expression* getI64Low(Builder& builder, Index index) { - return builder.makeUnary(WrapInt64, builder.makeGetLocal(index, i64)); + return builder.makeUnary(WrapInt64, builder.makeLocalGet(index, i64)); } }; diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index fe0594b91..6f0bec734 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -50,10 +50,10 @@ Module['BreakId'] = Module['_BinaryenBreakId'](); Module['SwitchId'] = Module['_BinaryenSwitchId'](); Module['CallId'] = Module['_BinaryenCallId'](); Module['CallIndirectId'] = Module['_BinaryenCallIndirectId'](); -Module['GetLocalId'] = Module['_BinaryenGetLocalId'](); -Module['SetLocalId'] = Module['_BinaryenSetLocalId'](); -Module['GetGlobalId'] = Module['_BinaryenGetGlobalId'](); -Module['SetGlobalId'] = Module['_BinaryenSetGlobalId'](); +Module['LocalGetId'] = Module['_BinaryenLocalGetId'](); +Module['LocalSetId'] = Module['_BinaryenLocalSetId'](); +Module['GlobalGetId'] = Module['_BinaryenGlobalGetId'](); +Module['GlobalSetId'] = Module['_BinaryenGlobalSetId'](); Module['LoadId'] = Module['_BinaryenLoadId'](); Module['StoreId'] = Module['_BinaryenStoreId'](); Module['ConstId'] = Module['_BinaryenConstId'](); @@ -233,8 +233,8 @@ Module['LtFloat64'] = Module['_BinaryenLtFloat64'](); Module['LeFloat64'] = Module['_BinaryenLeFloat64'](); Module['GtFloat64'] = Module['_BinaryenGtFloat64'](); Module['GeFloat64'] = Module['_BinaryenGeFloat64'](); -Module['CurrentMemory'] = Module['_BinaryenCurrentMemory'](); -Module['GrowMemory'] = Module['_BinaryenGrowMemory'](); +Module['MemorySize'] = Module['_BinaryenMemorySize'](); +Module['MemoryGrow'] = Module['_BinaryenMemoryGrow'](); Module['AtomicRMWAdd'] = Module['_BinaryenAtomicRMWAdd'](); Module['AtomicRMWSub'] = Module['_BinaryenAtomicRMWSub'](); Module['AtomicRMWAnd'] = Module['_BinaryenAtomicRMWAnd'](); @@ -450,40 +450,32 @@ function wrapModule(module, self) { self['local'] = { 'get': function(index, type) { - return Module['_BinaryenGetLocal'](module, index, type); + return Module['_BinaryenLocalGet'](module, index, type); }, 'set': function(index, value) { - return Module['_BinaryenSetLocal'](module, index, value); + return Module['_BinaryenLocalSet'](module, index, value); }, 'tee': function(index, value) { - return Module['_BinaryenTeeLocal'](module, index, value); + return Module['_BinaryenLocalTee'](module, index, 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); + return Module['_BinaryenGlobalGet'](module, strToStack(name), type); }, 'set': function(name, value) { - return Module['_BinaryenSetGlobal'](module, strToStack(name), value); + return Module['_BinaryenGlobalSet'](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']); - } - self['growMemory'] = self['grow_memory'] = function(value) { - return Module['_BinaryenHost'](module, Module['GrowMemory'], null, i32sToStack([value]), 1); - } - self['memory'] = { + 'size': function() { + return Module['_BinaryenHost'](module, Module['MemorySize']); + }, + 'grow': function(value) { + return Module['_BinaryenHost'](module, Module['MemoryGrow'], null, i32sToStack([value]), 1); + }, 'init': function(segment, dest, offset, size) { return Module['_BinaryenMemoryInit'](module, segment, dest, offset, size); }, @@ -1878,10 +1870,10 @@ function wrapModule(module, self) { return Module['_BinaryenSetStart'](module, start); }; self['getFeatures'] = function() { - return Module['_BinaryenGetFeatures'](module); + return Module['_BinaryenModuleGetFeatures'](module); }; self['setFeatures'] = function(features) { - Module['_BinaryenSetFeatures'](module, features); + Module['_BinaryenModuleSetFeatures'](module, features); }; self['emitText'] = function() { var old = out; @@ -2078,32 +2070,32 @@ Module['getExpressionInfo'] = function(expr) { 'target': Module['_BinaryenCallIndirectGetTarget'](expr), 'operands': getAllNested(expr, Module['_BinaryenCallIndirectGetNumOperands'], Module['_BinaryenCallIndirectGetOperand']) }; - case Module['GetLocalId']: + case Module['LocalGetId']: return { 'id': id, 'type': type, - 'index': Module['_BinaryenGetLocalGetIndex'](expr) + 'index': Module['_BinaryenLocalGetGetIndex'](expr) }; - case Module['SetLocalId']: + case Module['LocalSetId']: return { 'id': id, 'type': type, - 'isTee': Boolean(Module['_BinaryenSetLocalIsTee'](expr)), - 'index': Module['_BinaryenSetLocalGetIndex'](expr), - 'value': Module['_BinaryenSetLocalGetValue'](expr) + 'isTee': Boolean(Module['_BinaryenLocalSetIsTee'](expr)), + 'index': Module['_BinaryenLocalSetGetIndex'](expr), + 'value': Module['_BinaryenLocalSetGetValue'](expr) }; - case Module['GetGlobalId']: + case Module['GlobalGetId']: return { 'id': id, 'type': type, - 'name': UTF8ToString(Module['_BinaryenGetGlobalGetName'](expr)) + 'name': UTF8ToString(Module['_BinaryenGlobalGetGetName'](expr)) }; - case Module['SetGlobalId']: + case Module['GlobalSetId']: return { 'id': id, 'type': type, - 'name': UTF8ToString(Module['_BinaryenSetGlobalGetName'](expr)), - 'value': Module['_BinaryenSetGlobalGetValue'](expr) + 'name': UTF8ToString(Module['_BinaryenGlobalSetGetName'](expr)), + 'value': Module['_BinaryenGlobalSetGetValue'](expr) }; case Module['LoadId']: return { diff --git a/src/passes/AlignmentLowering.cpp b/src/passes/AlignmentLowering.cpp index fc03a8b74..05ec2892f 100644 --- a/src/passes/AlignmentLowering.cpp +++ b/src/passes/AlignmentLowering.cpp @@ -43,13 +43,13 @@ struct AlignmentLowering : public WalkerPass<PostWalker<AlignmentLowering>> { ret = builder.makeBinary( OrInt32, builder.makeLoad( - 1, false, curr->offset, 1, builder.makeGetLocal(temp, i32), i32), + 1, false, curr->offset, 1, builder.makeLocalGet(temp, i32), i32), builder.makeBinary(ShlInt32, builder.makeLoad(1, false, curr->offset + 1, 1, - builder.makeGetLocal(temp, i32), + builder.makeLocalGet(temp, i32), i32), builder.makeConst(Literal(int32_t(8))))); if (curr->signed_) { @@ -62,13 +62,13 @@ struct AlignmentLowering : public WalkerPass<PostWalker<AlignmentLowering>> { builder.makeBinary( OrInt32, builder.makeLoad( - 1, false, curr->offset, 1, builder.makeGetLocal(temp, i32), i32), + 1, false, curr->offset, 1, builder.makeLocalGet(temp, i32), i32), builder.makeBinary(ShlInt32, builder.makeLoad(1, false, curr->offset + 1, 1, - builder.makeGetLocal(temp, i32), + builder.makeLocalGet(temp, i32), i32), builder.makeConst(Literal(int32_t(8))))), builder.makeBinary( @@ -78,7 +78,7 @@ struct AlignmentLowering : public WalkerPass<PostWalker<AlignmentLowering>> { false, curr->offset + 2, 1, - builder.makeGetLocal(temp, i32), + builder.makeLocalGet(temp, i32), i32), builder.makeConst(Literal(int32_t(16)))), builder.makeBinary(ShlInt32, @@ -86,20 +86,20 @@ struct AlignmentLowering : public WalkerPass<PostWalker<AlignmentLowering>> { false, curr->offset + 3, 1, - builder.makeGetLocal(temp, i32), + builder.makeLocalGet(temp, i32), i32), builder.makeConst(Literal(int32_t(24)))))); } else if (curr->align == 2) { ret = builder.makeBinary( OrInt32, builder.makeLoad( - 2, false, curr->offset, 2, builder.makeGetLocal(temp, i32), i32), + 2, false, curr->offset, 2, builder.makeLocalGet(temp, i32), i32), builder.makeBinary(ShlInt32, builder.makeLoad(2, false, curr->offset + 2, 2, - builder.makeGetLocal(temp, i32), + builder.makeLocalGet(temp, i32), i32), builder.makeConst(Literal(int32_t(16))))); } else { @@ -109,7 +109,7 @@ struct AlignmentLowering : public WalkerPass<PostWalker<AlignmentLowering>> { WASM_UNREACHABLE(); } replaceCurrent( - builder.makeBlock({builder.makeSetLocal(temp, curr->ptr), ret})); + builder.makeBlock({builder.makeLocalSet(temp, curr->ptr), ret})); } void visitStore(Store* curr) { @@ -126,23 +126,23 @@ struct AlignmentLowering : public WalkerPass<PostWalker<AlignmentLowering>> { auto tempPtr = builder.addVar(getFunction(), i32); auto tempValue = builder.addVar(getFunction(), i32); auto* block = - builder.makeBlock({builder.makeSetLocal(tempPtr, curr->ptr), - builder.makeSetLocal(tempValue, curr->value)}); + builder.makeBlock({builder.makeLocalSet(tempPtr, curr->ptr), + builder.makeLocalSet(tempValue, curr->value)}); if (curr->bytes == 2) { block->list.push_back( builder.makeStore(1, curr->offset, 1, - builder.makeGetLocal(tempPtr, i32), - builder.makeGetLocal(tempValue, i32), + builder.makeLocalGet(tempPtr, i32), + builder.makeLocalGet(tempValue, i32), i32)); block->list.push_back(builder.makeStore( 1, curr->offset + 1, 1, - builder.makeGetLocal(tempPtr, i32), + builder.makeLocalGet(tempPtr, i32), builder.makeBinary(ShrUInt32, - builder.makeGetLocal(tempValue, i32), + builder.makeLocalGet(tempValue, i32), builder.makeConst(Literal(int32_t(8)))), i32)); } else if (curr->bytes == 4) { @@ -151,34 +151,34 @@ struct AlignmentLowering : public WalkerPass<PostWalker<AlignmentLowering>> { builder.makeStore(1, curr->offset, 1, - builder.makeGetLocal(tempPtr, i32), - builder.makeGetLocal(tempValue, i32), + builder.makeLocalGet(tempPtr, i32), + builder.makeLocalGet(tempValue, i32), i32)); block->list.push_back(builder.makeStore( 1, curr->offset + 1, 1, - builder.makeGetLocal(tempPtr, i32), + builder.makeLocalGet(tempPtr, i32), builder.makeBinary(ShrUInt32, - builder.makeGetLocal(tempValue, i32), + builder.makeLocalGet(tempValue, i32), builder.makeConst(Literal(int32_t(8)))), i32)); block->list.push_back(builder.makeStore( 1, curr->offset + 2, 1, - builder.makeGetLocal(tempPtr, i32), + builder.makeLocalGet(tempPtr, i32), builder.makeBinary(ShrUInt32, - builder.makeGetLocal(tempValue, i32), + builder.makeLocalGet(tempValue, i32), builder.makeConst(Literal(int32_t(16)))), i32)); block->list.push_back(builder.makeStore( 1, curr->offset + 3, 1, - builder.makeGetLocal(tempPtr, i32), + builder.makeLocalGet(tempPtr, i32), builder.makeBinary(ShrUInt32, - builder.makeGetLocal(tempValue, i32), + builder.makeLocalGet(tempValue, i32), builder.makeConst(Literal(int32_t(24)))), i32)); } else if (curr->align == 2) { @@ -186,16 +186,16 @@ struct AlignmentLowering : public WalkerPass<PostWalker<AlignmentLowering>> { builder.makeStore(2, curr->offset, 2, - builder.makeGetLocal(tempPtr, i32), - builder.makeGetLocal(tempValue, i32), + builder.makeLocalGet(tempPtr, i32), + builder.makeLocalGet(tempValue, i32), i32)); block->list.push_back(builder.makeStore( 2, curr->offset + 2, 2, - builder.makeGetLocal(tempPtr, i32), + builder.makeLocalGet(tempPtr, i32), builder.makeBinary(ShrUInt32, - builder.makeGetLocal(tempValue, i32), + builder.makeLocalGet(tempValue, i32), builder.makeConst(Literal(int32_t(16)))), i32)); } else { diff --git a/src/passes/AvoidReinterprets.cpp b/src/passes/AvoidReinterprets.cpp index d9b93b188..5aa1d338b 100644 --- a/src/passes/AvoidReinterprets.cpp +++ b/src/passes/AvoidReinterprets.cpp @@ -35,8 +35,8 @@ static bool canReplaceWithReinterpret(Load* load) { return load->type != unreachable && load->bytes == getTypeSize(load->type); } -static Load* getSingleLoad(LocalGraph* localGraph, GetLocal* get) { - std::set<GetLocal*> seen; +static Load* getSingleLoad(LocalGraph* localGraph, LocalGet* get) { + std::set<LocalGet*> seen; seen.insert(get); while (1) { auto& sets = localGraph->getSetses[get]; @@ -48,7 +48,7 @@ static Load* getSingleLoad(LocalGraph* localGraph, GetLocal* get) { return nullptr; } auto* value = Properties::getFallthrough(set->value); - if (auto* parentGet = value->dynCast<GetLocal>()) { + if (auto* parentGet = value->dynCast<LocalGet>()) { if (seen.count(parentGet)) { // We are in a cycle of gets, in unreachable code. return nullptr; @@ -98,7 +98,7 @@ struct AvoidReinterprets : public WalkerPass<PostWalker<AvoidReinterprets>> { void visitUnary(Unary* curr) { if (isReinterpret(curr)) { if (auto* get = - Properties::getFallthrough(curr->value)->dynCast<GetLocal>()) { + Properties::getFallthrough(curr->value)->dynCast<LocalGet>()) { if (auto* load = getSingleLoad(localGraph, get)) { auto& info = infos[load]; info.reinterpreted = true; @@ -143,14 +143,14 @@ struct AvoidReinterprets : public WalkerPass<PostWalker<AvoidReinterprets>> { if (canReplaceWithReinterpret(load)) { replaceCurrent(makeReinterpretedLoad(load, load->ptr)); } - } else if (auto* get = value->dynCast<GetLocal>()) { + } else if (auto* get = value->dynCast<LocalGet>()) { if (auto* load = getSingleLoad(localGraph, get)) { auto iter = infos.find(load); if (iter != infos.end()) { auto& info = iter->second; // A reinterpret of a get of a load - use the new local. Builder builder(*module); - replaceCurrent(builder.makeGetLocal( + replaceCurrent(builder.makeLocalGet( info.reinterpretedLocal, reinterpretType(load->type))); } } @@ -164,16 +164,16 @@ struct AvoidReinterprets : public WalkerPass<PostWalker<AvoidReinterprets>> { auto& info = iter->second; Builder builder(*module); auto* ptr = curr->ptr; - curr->ptr = builder.makeGetLocal(info.ptrLocal, i32); + curr->ptr = builder.makeLocalGet(info.ptrLocal, i32); // Note that the other load can have its sign set to false - if the // original were an integer, the other is a float anyhow; and if // original were a float, we don't know what sign to use. replaceCurrent(builder.makeBlock( - {builder.makeSetLocal(info.ptrLocal, ptr), - builder.makeSetLocal( + {builder.makeLocalSet(info.ptrLocal, ptr), + builder.makeLocalSet( info.reinterpretedLocal, makeReinterpretedLoad(curr, - builder.makeGetLocal(info.ptrLocal, i32))), + builder.makeLocalGet(info.ptrLocal, i32))), curr})); } } diff --git a/src/passes/CoalesceLocals.cpp b/src/passes/CoalesceLocals.cpp index af13419d3..9bc635f80 100644 --- a/src/passes/CoalesceLocals.cpp +++ b/src/passes/CoalesceLocals.cpp @@ -51,7 +51,7 @@ struct CoalesceLocals void calculateInterferences(); - void calculateInterferences(const LocalSet& locals); + void calculateInterferences(const SetOfLocals& locals); void pickIndicesFromOrder(std::vector<Index>& order, std::vector<Index>& indices); @@ -120,7 +120,7 @@ void CoalesceLocals::increaseBackEdgePriorities() { } for (auto& action : arrivingBlock->contents.actions) { if (action.isSet()) { - auto* set = (*action.origin)->cast<SetLocal>(); + auto* set = (*action.origin)->cast<LocalSet>(); if (auto* get = getCopy(set)) { // this is indeed a copy, add to the cost (default cost is 2, so // this adds 50%, and can mostly break ties) @@ -163,7 +163,7 @@ void CoalesceLocals::calculateInterferences() { } // Params have a value on entry, so mark them as live, as variables // live at the entry expect their zero-init value. - LocalSet start = entry->contents.start; + SetOfLocals start = entry->contents.start; auto numParams = getFunction()->getNumParams(); for (Index i = 0; i < numParams; i++) { start.insert(i); @@ -171,7 +171,7 @@ void CoalesceLocals::calculateInterferences() { calculateInterferences(start); } -void CoalesceLocals::calculateInterferences(const LocalSet& locals) { +void CoalesceLocals::calculateInterferences(const SetOfLocals& locals) { Index size = locals.size(); for (Index i = 0; i < size; i++) { for (Index j = i + 1; j < size; j++) { @@ -358,15 +358,15 @@ void CoalesceLocals::applyIndices(std::vector<Index>& indices, auto& actions = curr->contents.actions; for (auto& action : actions) { if (action.isGet()) { - auto* get = (*action.origin)->cast<GetLocal>(); + auto* get = (*action.origin)->cast<LocalGet>(); get->index = indices[get->index]; } else if (action.isSet()) { - auto* set = (*action.origin)->cast<SetLocal>(); + auto* set = (*action.origin)->cast<LocalSet>(); set->index = indices[set->index]; // in addition, we can optimize out redundant copies and ineffective // sets - GetLocal* get; - if ((get = set->value->dynCast<GetLocal>()) && + LocalGet* get; + if ((get = set->value->dynCast<LocalGet>()) && get->index == set->index) { action.removeCopy(); continue; @@ -378,7 +378,7 @@ void CoalesceLocals::applyIndices(std::vector<Index>& indices, *action.origin = set->value; if (!set->isTee()) { // we need to drop it - Drop* drop = ExpressionManipulator::convert<SetLocal, Drop>(set); + Drop* drop = ExpressionManipulator::convert<LocalSet, Drop>(set); drop->value = *action.origin; *action.origin = drop; } diff --git a/src/passes/CodePushing.cpp b/src/passes/CodePushing.cpp index 88e363541..4eb69b92e 100644 --- a/src/passes/CodePushing.cpp +++ b/src/passes/CodePushing.cpp @@ -60,14 +60,14 @@ struct LocalAnalyzer : public PostWalker<LocalAnalyzer> { Index getNumGets(Index i) { return numGets[i]; } - void visitGetLocal(GetLocal* curr) { + void visitLocalGet(LocalGet* curr) { if (numSets[curr->index] == 0) { sfa[curr->index] = false; } numGets[curr->index]++; } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { numSets[curr->index]++; if (numSets[curr->index] > 1) { sfa[curr->index] = false; @@ -116,8 +116,8 @@ public: } private: - SetLocal* isPushable(Expression* curr) { - auto* set = curr->dynCast<SetLocal>(); + LocalSet* isPushable(Expression* curr) { + auto* set = curr->dynCast<LocalSet>(); if (!set) { return nullptr; } @@ -162,7 +162,7 @@ private: // it is ok to ignore the branching here, that is the crucial point of this // opt cumulativeEffects.branches = false; - std::vector<SetLocal*> toPush; + std::vector<LocalSet*> toPush; Index i = pushPoint - 1; while (1) { auto* pushable = isPushable(list[i]); @@ -223,7 +223,7 @@ private: } // Pushables may need to be scanned more than once, so cache their effects. - std::unordered_map<SetLocal*, EffectAnalyzer> pushableEffects; + std::unordered_map<LocalSet*, EffectAnalyzer> pushableEffects; }; struct CodePushing : public WalkerPass<PostWalker<CodePushing>> { @@ -246,7 +246,7 @@ struct CodePushing : public WalkerPass<PostWalker<CodePushing>> { walk(func->body); } - void visitGetLocal(GetLocal* curr) { numGetsSoFar[curr->index]++; } + void visitLocalGet(LocalGet* curr) { numGetsSoFar[curr->index]++; } void visitBlock(Block* curr) { // Pushing code only makes sense if we are size 3 or above: we need diff --git a/src/passes/ConstHoisting.cpp b/src/passes/ConstHoisting.cpp index 37799e8b8..149ba6504 100644 --- a/src/passes/ConstHoisting.cpp +++ b/src/passes/ConstHoisting.cpp @@ -127,9 +127,9 @@ private: auto type = (*(vec[0]))->type; Builder builder(*getModule()); auto temp = builder.addVar(getFunction(), type); - auto* ret = builder.makeSetLocal(temp, *(vec[0])); + auto* ret = builder.makeLocalSet(temp, *(vec[0])); for (auto item : vec) { - *item = builder.makeGetLocal(temp, type); + *item = builder.makeLocalGet(temp, type); } return ret; } diff --git a/src/passes/DeadArgumentElimination.cpp b/src/passes/DeadArgumentElimination.cpp index ab2e8e5e3..9d60efd42 100644 --- a/src/passes/DeadArgumentElimination.cpp +++ b/src/passes/DeadArgumentElimination.cpp @@ -93,7 +93,7 @@ struct DAEScanner // cfg traversal work - void visitGetLocal(GetLocal* curr) { + void visitLocalGet(LocalGet* curr) { if (currBasicBlock) { auto& localUses = currBasicBlock->contents.localUses; auto index = curr->index; @@ -103,7 +103,7 @@ struct DAEScanner } } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { if (currBasicBlock) { auto& localUses = currBasicBlock->contents.localUses; auto index = curr->index; @@ -294,7 +294,7 @@ struct DAE : public Pass { // makes the parameter value unused, which lets us remove it later. Builder builder(*module); func->body = builder.makeSequence( - builder.makeSetLocal(i, builder.makeConst(value)), func->body); + builder.makeLocalSet(i, builder.makeConst(value)), func->body); // Mark it as unused, which we know it now is (no point to // re-scan just for that). infoMap[name].unusedParams.insert(i); @@ -402,8 +402,8 @@ private: : removedIndex(removedIndex), newIndex(newIndex) { walk(func->body); } - void visitGetLocal(GetLocal* curr) { updateIndex(curr->index); } - void visitSetLocal(SetLocal* curr) { updateIndex(curr->index); } + void visitLocalGet(LocalGet* curr) { updateIndex(curr->index); } + void visitLocalSet(LocalSet* curr) { updateIndex(curr->index); } void updateIndex(Index& index) { if (index == removedIndex) { index = newIndex; diff --git a/src/passes/DeadCodeElimination.cpp b/src/passes/DeadCodeElimination.cpp index c77edf357..da22a7f28 100644 --- a/src/passes/DeadCodeElimination.cpp +++ b/src/passes/DeadCodeElimination.cpp @@ -252,14 +252,14 @@ struct DeadCodeElimination DELEGATE(Call); case Expression::Id::CallIndirectId: DELEGATE(CallIndirect); - case Expression::Id::GetLocalId: - DELEGATE(GetLocal); - case Expression::Id::SetLocalId: - DELEGATE(SetLocal); - case Expression::Id::GetGlobalId: - DELEGATE(GetGlobal); - case Expression::Id::SetGlobalId: - DELEGATE(SetGlobal); + case Expression::Id::LocalGetId: + DELEGATE(LocalGet); + case Expression::Id::LocalSetId: + DELEGATE(LocalSet); + case Expression::Id::GlobalGetId: + DELEGATE(GlobalGet); + case Expression::Id::GlobalSetId: + DELEGATE(GlobalSet); case Expression::Id::LoadId: DELEGATE(Load); case Expression::Id::StoreId: @@ -400,11 +400,11 @@ struct DeadCodeElimination } } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { blockifyReachableOperands({curr->value}, curr->type); } - void visitSetGlobal(SetGlobal* curr) { + void visitGlobalSet(GlobalSet* curr) { blockifyReachableOperands({curr->value}, curr->type); } diff --git a/src/passes/Flatten.cpp b/src/passes/Flatten.cpp index 55f3df6ab..9caf6cae8 100644 --- a/src/passes/Flatten.cpp +++ b/src/passes/Flatten.cpp @@ -95,11 +95,11 @@ struct Flatten } auto*& last = block->list.back(); if (isConcreteType(last->type)) { - last = builder.makeSetLocal(temp, last); + last = builder.makeLocalSet(temp, last); } block->finalize(none); // and we leave just a get of the value - auto* rep = builder.makeGetLocal(temp, type); + auto* rep = builder.makeLocalGet(temp, type); replaceCurrent(rep); // the whole block is now a prelude ourPreludes.push_back(block); @@ -117,15 +117,15 @@ struct Flatten if (isConcreteType(type)) { Index temp = builder.addVar(getFunction(), type); if (isConcreteType(iff->ifTrue->type)) { - iff->ifTrue = builder.makeSetLocal(temp, iff->ifTrue); + iff->ifTrue = builder.makeLocalSet(temp, iff->ifTrue); } if (iff->ifFalse && isConcreteType(iff->ifFalse->type)) { - iff->ifFalse = builder.makeSetLocal(temp, iff->ifFalse); + iff->ifFalse = builder.makeLocalSet(temp, iff->ifFalse); } // the whole if (+any preludes from the condition) is now a prelude prelude = rep; // and we leave just a get of the value - rep = builder.makeGetLocal(temp, type); + rep = builder.makeLocalGet(temp, type); } iff->ifTrue = getPreludesWithExpression(originalIfTrue, iff->ifTrue); if (iff->ifFalse) { @@ -145,9 +145,9 @@ struct Flatten auto type = loop->type; if (isConcreteType(type)) { Index temp = builder.addVar(getFunction(), type); - loop->body = builder.makeSetLocal(temp, loop->body); + loop->body = builder.makeLocalSet(temp, loop->body); // and we leave just a get of the value - rep = builder.makeGetLocal(temp, type); + rep = builder.makeLocalGet(temp, type); // the whole if is now a prelude ourPreludes.push_back(loop); loop->type = none; @@ -165,7 +165,7 @@ struct Flatten ourPreludes.swap(iter->second); } // special handling - if (auto* set = curr->dynCast<SetLocal>()) { + if (auto* set = curr->dynCast<LocalSet>()) { if (set->isTee()) { // we disallow local.tee if (set->value->type == unreachable) { @@ -174,7 +174,7 @@ struct Flatten // use a set in a prelude + a get set->setTee(false); ourPreludes.push_back(set); - replaceCurrent(builder.makeGetLocal(set->index, set->value->type)); + replaceCurrent(builder.makeLocalGet(set->index, set->value->type)); } } } else if (auto* br = curr->dynCast<Break>()) { @@ -183,12 +183,12 @@ struct Flatten if (isConcreteType(type)) { // we are sending a value. use a local instead Index temp = getTempForBreakTarget(br->name, type); - ourPreludes.push_back(builder.makeSetLocal(temp, br->value)); + ourPreludes.push_back(builder.makeLocalSet(temp, br->value)); if (br->condition) { // the value must also flow out ourPreludes.push_back(br); if (isConcreteType(br->type)) { - replaceCurrent(builder.makeGetLocal(temp, type)); + replaceCurrent(builder.makeLocalGet(temp, type)); } else { assert(br->type == unreachable); replaceCurrent(builder.makeUnreachable()); @@ -208,13 +208,13 @@ struct Flatten if (isConcreteType(type)) { // we are sending a value. use a local instead Index temp = builder.addVar(getFunction(), type); - ourPreludes.push_back(builder.makeSetLocal(temp, sw->value)); + ourPreludes.push_back(builder.makeLocalSet(temp, sw->value)); // we don't know which break target will be hit - assign to them all auto names = BranchUtils::getUniqueTargets(sw); for (auto name : names) { ourPreludes.push_back( - builder.makeSetLocal(getTempForBreakTarget(name, type), - builder.makeGetLocal(temp, type))); + builder.makeLocalSet(getTempForBreakTarget(name, type), + builder.makeLocalGet(temp, type))); } sw->value = nullptr; sw->finalize(); @@ -244,8 +244,8 @@ struct Flatten // use a local auto type = curr->type; Index temp = builder.addVar(getFunction(), type); - ourPreludes.push_back(builder.makeSetLocal(temp, curr)); - replaceCurrent(builder.makeGetLocal(temp, type)); + ourPreludes.push_back(builder.makeLocalSet(temp, curr)); + replaceCurrent(builder.makeLocalGet(temp, type)); } } // next, finish up: migrate our preludes if we can diff --git a/src/passes/FuncCastEmulation.cpp b/src/passes/FuncCastEmulation.cpp index ce5332a49..69bc39585 100644 --- a/src/passes/FuncCastEmulation.cpp +++ b/src/passes/FuncCastEmulation.cpp @@ -210,7 +210,7 @@ private: std::vector<Expression*> callOperands; for (Index i = 0; i < params.size(); i++) { callOperands.push_back( - fromABI(builder.makeGetLocal(i, i64), params[i], module)); + fromABI(builder.makeLocalGet(i, i64), params[i], module)); } auto* call = builder.makeCall(name, callOperands, type); std::vector<Type> thunkParams; diff --git a/src/passes/I64ToI32Lowering.cpp b/src/passes/I64ToI32Lowering.cpp index e61e4055e..e893b6296 100644 --- a/src/passes/I64ToI32Lowering.cpp +++ b/src/passes/I64ToI32Lowering.cpp @@ -127,8 +127,8 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { c->value = Literal(uint32_t(value)); c->type = i32; high->init = builder->makeConst(Literal(uint32_t(value >> 32))); - } else if (auto* get = curr->init->dynCast<GetGlobal>()) { - high->init = builder->makeGetGlobal(makeHighName(get->name), i32); + } else if (auto* get = curr->init->dynCast<GlobalGet>()) { + high->init = builder->makeGlobalGet(makeHighName(get->name), i32); } else { WASM_UNREACHABLE(); } @@ -213,10 +213,10 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { if (hasOutParam(func->body)) { TempVar highBits = fetchOutParam(func->body); TempVar lowBits = getTemp(); - SetLocal* setLow = builder->makeSetLocal(lowBits, func->body); - SetGlobal* setHigh = builder->makeSetGlobal( - INT64_TO_32_HIGH_BITS, builder->makeGetLocal(highBits, i32)); - GetLocal* getLow = builder->makeGetLocal(lowBits, i32); + LocalSet* setLow = builder->makeLocalSet(lowBits, func->body); + GlobalSet* setHigh = builder->makeGlobalSet( + INT64_TO_32_HIGH_BITS, builder->makeLocalGet(highBits, i32)); + LocalGet* getLow = builder->makeLocalGet(lowBits, i32); func->body = builder->blockify(setLow, setHigh, getLow); } } @@ -240,7 +240,7 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { args.push_back(e); if (hasOutParam(e)) { TempVar argHighBits = fetchOutParam(e); - args.push_back(builder->makeGetLocal(argHighBits, i32)); + args.push_back(builder->makeLocalGet(argHighBits, i32)); fixed = true; } } @@ -252,10 +252,10 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { TempVar lowBits = getTemp(); TempVar highBits = getTemp(); auto* call = callBuilder(args, i32); - SetLocal* doCall = builder->makeSetLocal(lowBits, call); - SetLocal* setHigh = builder->makeSetLocal( - highBits, builder->makeGetGlobal(INT64_TO_32_HIGH_BITS, i32)); - GetLocal* getLow = builder->makeGetLocal(lowBits, i32); + LocalSet* doCall = builder->makeLocalSet(lowBits, call); + LocalSet* setHigh = builder->makeLocalSet( + highBits, builder->makeGlobalGet(INT64_TO_32_HIGH_BITS, i32)); + LocalGet* getLow = builder->makeLocalGet(lowBits, i32); Block* result = builder->blockify(doCall, setHigh, getLow); setOutParam(result, std::move(highBits)); replaceCurrent(result); @@ -282,7 +282,7 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { }); } - void visitGetLocal(GetLocal* curr) { + void visitLocalGet(LocalGet* curr) { const auto mappedIndex = indexMap[curr->index]; // Need to remap the local into the new naming scheme, regardless of // the type of the local. @@ -292,27 +292,27 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { } curr->type = i32; TempVar highBits = getTemp(); - SetLocal* setHighBits = builder->makeSetLocal( - highBits, builder->makeGetLocal(mappedIndex + 1, i32)); + LocalSet* setHighBits = builder->makeLocalSet( + highBits, builder->makeLocalGet(mappedIndex + 1, i32)); Block* result = builder->blockify(setHighBits, curr); replaceCurrent(result); setOutParam(result, std::move(highBits)); } - void lowerTee(SetLocal* curr) { + void lowerTee(LocalSet* curr) { TempVar highBits = fetchOutParam(curr->value); TempVar tmp = getTemp(); curr->type = i32; - SetLocal* setLow = builder->makeSetLocal(tmp, curr); - SetLocal* setHigh = builder->makeSetLocal( - curr->index + 1, builder->makeGetLocal(highBits, i32)); - GetLocal* getLow = builder->makeGetLocal(tmp, i32); + LocalSet* setLow = builder->makeLocalSet(tmp, curr); + LocalSet* setHigh = builder->makeLocalSet( + curr->index + 1, builder->makeLocalGet(highBits, i32)); + LocalGet* getLow = builder->makeLocalGet(tmp, i32); Block* result = builder->blockify(setLow, setHigh, getLow); replaceCurrent(result); setOutParam(result, std::move(highBits)); } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { const auto mappedIndex = indexMap[curr->index]; // Need to remap the local into the new naming scheme, regardless of // the type of the local. Note that lowerTee depends on this happening. @@ -325,13 +325,13 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { return; } TempVar highBits = fetchOutParam(curr->value); - auto* setHigh = builder->makeSetLocal(mappedIndex + 1, - builder->makeGetLocal(highBits, i32)); + auto* setHigh = builder->makeLocalSet(mappedIndex + 1, + builder->makeLocalGet(highBits, i32)); Block* result = builder->blockify(curr, setHigh); replaceCurrent(result); } - void visitGetGlobal(GetGlobal* curr) { + void visitGlobalGet(GlobalGet* curr) { if (!getFunction()) { return; // if in a global init, skip - we already handled that. } @@ -340,14 +340,14 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { } curr->type = i32; TempVar highBits = getTemp(); - SetLocal* setHighBits = builder->makeSetLocal( - highBits, builder->makeGetGlobal(makeHighName(curr->name), i32)); + LocalSet* setHighBits = builder->makeLocalSet( + highBits, builder->makeGlobalGet(makeHighName(curr->name), i32)); Block* result = builder->blockify(setHighBits, curr); replaceCurrent(result); setOutParam(result, std::move(highBits)); } - void visitSetGlobal(SetGlobal* curr) { + void visitGlobalSet(GlobalSet* curr) { if (!originallyI64Globals.count(curr->name)) { return; } @@ -355,8 +355,8 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { return; } TempVar highBits = fetchOutParam(curr->value); - auto* setHigh = builder->makeSetGlobal( - makeHighName(curr->name), builder->makeGetLocal(highBits, i32)); + auto* setHigh = builder->makeGlobalSet( + makeHighName(curr->name), builder->makeLocalGet(highBits, i32)); replaceCurrent(builder->makeSequence(curr, setHigh)); } @@ -368,35 +368,35 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { TempVar lowBits = getTemp(); TempVar highBits = getTemp(); TempVar ptrTemp = getTemp(); - SetLocal* setPtr = builder->makeSetLocal(ptrTemp, curr->ptr); - SetLocal* loadHigh; + LocalSet* setPtr = builder->makeLocalSet(ptrTemp, curr->ptr); + LocalSet* loadHigh; if (curr->bytes == 8) { - loadHigh = builder->makeSetLocal( + loadHigh = builder->makeLocalSet( highBits, builder->makeLoad(4, curr->signed_, curr->offset + 4, std::min(uint32_t(curr->align), uint32_t(4)), - builder->makeGetLocal(ptrTemp, i32), + builder->makeLocalGet(ptrTemp, i32), i32)); } else if (curr->signed_) { - loadHigh = builder->makeSetLocal( + loadHigh = builder->makeLocalSet( highBits, builder->makeBinary(ShrSInt32, - builder->makeGetLocal(lowBits, i32), + builder->makeLocalGet(lowBits, i32), builder->makeConst(Literal(int32_t(31))))); } else { - loadHigh = builder->makeSetLocal(highBits, + loadHigh = builder->makeLocalSet(highBits, builder->makeConst(Literal(int32_t(0)))); } curr->type = i32; curr->bytes = std::min(curr->bytes, uint8_t(4)); curr->align = std::min(uint32_t(curr->align), uint32_t(4)); - curr->ptr = builder->makeGetLocal(ptrTemp, i32); + curr->ptr = builder->makeLocalGet(ptrTemp, i32); Block* result = builder->blockify(setPtr, - builder->makeSetLocal(lowBits, curr), + builder->makeLocalSet(lowBits, curr), loadHigh, - builder->makeGetLocal(lowBits, i32)); + builder->makeLocalGet(lowBits, i32)); replaceCurrent(result); setOutParam(result, std::move(highBits)); } @@ -414,15 +414,15 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { curr->valueType = i32; if (bytes == 8) { TempVar ptrTemp = getTemp(); - SetLocal* setPtr = builder->makeSetLocal(ptrTemp, curr->ptr); - curr->ptr = builder->makeGetLocal(ptrTemp, i32); + LocalSet* setPtr = builder->makeLocalSet(ptrTemp, curr->ptr); + curr->ptr = builder->makeLocalGet(ptrTemp, i32); curr->finalize(); Store* storeHigh = builder->makeStore(4, curr->offset + 4, std::min(uint32_t(curr->align), uint32_t(4)), - builder->makeGetLocal(ptrTemp, i32), - builder->makeGetLocal(highBits, i32), + builder->makeLocalGet(ptrTemp, i32), + builder->makeLocalGet(highBits, i32), i32); replaceCurrent(builder->blockify(setPtr, curr, storeHigh)); } @@ -446,8 +446,8 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { TempVar highBits = getTemp(); Const* lowVal = builder->makeConst(Literal(int32_t(curr->value.geti64() & 0xffffffff))); - SetLocal* setHigh = - builder->makeSetLocal(highBits, + LocalSet* setHigh = + builder->makeLocalSet(highBits, builder->makeConst(Literal( int32_t(uint64_t(curr->value.geti64()) >> 32)))); Block* result = builder->blockify(setHigh, lowVal); @@ -461,7 +461,7 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { auto* result = builder->makeUnary( EqZInt32, builder->makeBinary( - OrInt32, curr->value, builder->makeGetLocal(highBits, i32))); + OrInt32, curr->value, builder->makeLocalGet(highBits, i32))); replaceCurrent(result); } @@ -469,7 +469,7 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { void lowerExtendUInt32(Unary* curr) { TempVar highBits = getTemp(); Block* result = builder->blockify( - builder->makeSetLocal(highBits, builder->makeConst(Literal(int32_t(0)))), + builder->makeLocalSet(highBits, builder->makeConst(Literal(int32_t(0)))), curr->value); setOutParam(result, std::move(highBits)); replaceCurrent(result); @@ -479,15 +479,15 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { TempVar highBits = getTemp(); TempVar lowBits = getTemp(); - SetLocal* setLow = builder->makeSetLocal(lowBits, curr->value); - SetLocal* setHigh = builder->makeSetLocal( + LocalSet* setLow = builder->makeLocalSet(lowBits, curr->value); + LocalSet* setHigh = builder->makeLocalSet( highBits, builder->makeBinary(ShrSInt32, - builder->makeGetLocal(lowBits, i32), + builder->makeLocalGet(lowBits, i32), builder->makeConst(Literal(int32_t(31))))); Block* result = - builder->blockify(setLow, setHigh, builder->makeGetLocal(lowBits, i32)); + builder->blockify(setLow, setHigh, builder->makeLocalGet(lowBits, i32)); setOutParam(result, std::move(highBits)); replaceCurrent(result); @@ -505,7 +505,7 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { TempVar highBits = getTemp(); Block* result = builder->blockify( builder->makeCall(ABI::wasm2js::SCRATCH_STORE_F64, {curr->value}, none), - builder->makeSetLocal( + builder->makeLocalSet( highBits, builder->makeCall(ABI::wasm2js::SCRATCH_LOAD_I32, {builder->makeConst(Literal(int32_t(1)))}, @@ -529,7 +529,7 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { none), builder->makeCall(ABI::wasm2js::SCRATCH_STORE_I32, {builder->makeConst(Literal(int32_t(1))), - builder->makeGetLocal(highBits, i32)}, + builder->makeLocalGet(highBits, i32)}, none), builder->makeCall(ABI::wasm2js::SCRATCH_LOAD_F64, {}, f64)); replaceCurrent(result); @@ -606,7 +606,7 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { builder->makeUnary( floor, builder->makeBinary(div, - builder->makeGetLocal(f, localType), + builder->makeLocalGet(f, localType), builder->makeConst(u32Max))), builder->makeBinary( sub, builder->makeConst(u32Max), builder->makeConst(litOne))); @@ -616,28 +616,28 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { div, builder->makeBinary( sub, - builder->makeGetLocal(f, localType), + builder->makeLocalGet(f, localType), builder->makeUnary( convert, - builder->makeUnary(trunc, builder->makeGetLocal(f, localType)))), + builder->makeUnary(trunc, builder->makeLocalGet(f, localType)))), builder->makeConst(u32Max))); If* highBitsCalc = builder->makeIf( builder->makeBinary( - gt, builder->makeGetLocal(f, localType), builder->makeConst(litZero)), + gt, builder->makeLocalGet(f, localType), builder->makeConst(litZero)), builder->makeUnary(trunc, gtZeroBranch), builder->makeUnary(trunc, ltZeroBranch)); If* highBitsVal = builder->makeIf( builder->makeBinary( ge, - builder->makeUnary(abs, builder->makeGetLocal(f, localType)), + builder->makeUnary(abs, builder->makeLocalGet(f, localType)), builder->makeConst(litOne)), highBitsCalc, builder->makeConst(Literal(int32_t(0)))); Block* result = builder->blockify( - builder->makeSetLocal(f, curr->value), - builder->makeSetLocal(highBits, highBitsVal), - builder->makeUnary(trunc, builder->makeGetLocal(f, localType))); + builder->makeLocalSet(f, curr->value), + builder->makeLocalSet(highBits, highBitsVal), + builder->makeUnary(trunc, builder->makeLocalGet(f, localType))); setOutParam(result, std::move(highBits)); replaceCurrent(result); } @@ -674,18 +674,18 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { } Expression* result = builder->blockify( - builder->makeSetLocal(lowBits, curr->value), - builder->makeSetLocal(highResult, + builder->makeLocalSet(lowBits, curr->value), + builder->makeLocalSet(highResult, builder->makeConst(Literal(int32_t(0)))), builder->makeBinary( AddFloat64, builder->makeUnary(ConvertUInt32ToFloat64, - builder->makeGetLocal(lowBits, i32)), + builder->makeLocalGet(lowBits, i32)), builder->makeBinary( MulFloat64, builder->makeConst(Literal((double)UINT_MAX + 1)), builder->makeUnary(convertHigh, - builder->makeGetLocal(highBits, i32))))); + builder->makeLocalGet(highBits, i32))))); switch (curr->op) { case ConvertSInt64ToFloat32: @@ -707,24 +707,24 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { TempVar&& second) { TempVar highResult = getTemp(); TempVar firstResult = getTemp(); - SetLocal* setFirst = builder->makeSetLocal( + LocalSet* setFirst = builder->makeLocalSet( firstResult, - builder->makeUnary(op32, builder->makeGetLocal(first, i32))); + builder->makeUnary(op32, builder->makeLocalGet(first, i32))); Binary* check = builder->makeBinary(EqInt32, - builder->makeGetLocal(firstResult, i32), + builder->makeLocalGet(firstResult, i32), builder->makeConst(Literal(int32_t(32)))); If* conditional = builder->makeIf( check, builder->makeBinary( AddInt32, - builder->makeUnary(op32, builder->makeGetLocal(second, i32)), + builder->makeUnary(op32, builder->makeLocalGet(second, i32)), builder->makeConst(Literal(int32_t(32)))), - builder->makeGetLocal(firstResult, i32)); + builder->makeLocalGet(firstResult, i32)); - SetLocal* setHigh = builder->makeSetLocal( + LocalSet* setHigh = builder->makeLocalSet( highResult, builder->makeConst(Literal(int32_t(0)))); setOutParam(result, std::move(highResult)); @@ -734,7 +734,7 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { TempVar highBits = fetchOutParam(curr->value); TempVar lowBits = getTemp(); - SetLocal* setLow = builder->makeSetLocal(lowBits, curr->value); + LocalSet* setLow = builder->makeLocalSet(lowBits, curr->value); Block* result = builder->blockify(setLow); switch (curr->op) { @@ -834,27 +834,27 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { TempVar&& rightHigh) { TempVar lowResult = getTemp(); TempVar highResult = getTemp(); - SetLocal* addLow = builder->makeSetLocal( + LocalSet* addLow = builder->makeLocalSet( lowResult, builder->makeBinary(AddInt32, - builder->makeGetLocal(leftLow, i32), - builder->makeGetLocal(rightLow, i32))); - SetLocal* addHigh = builder->makeSetLocal( + builder->makeLocalGet(leftLow, i32), + builder->makeLocalGet(rightLow, i32))); + LocalSet* addHigh = builder->makeLocalSet( highResult, builder->makeBinary(AddInt32, - builder->makeGetLocal(leftHigh, i32), - builder->makeGetLocal(rightHigh, i32))); - SetLocal* carryBit = builder->makeSetLocal( + builder->makeLocalGet(leftHigh, i32), + builder->makeLocalGet(rightHigh, i32))); + LocalSet* carryBit = builder->makeLocalSet( highResult, builder->makeBinary(AddInt32, - builder->makeGetLocal(highResult, i32), + builder->makeLocalGet(highResult, i32), builder->makeConst(Literal(int32_t(1))))); If* checkOverflow = builder->makeIf(builder->makeBinary(LtUInt32, - builder->makeGetLocal(lowResult, i32), - builder->makeGetLocal(rightLow, i32)), + builder->makeLocalGet(lowResult, i32), + builder->makeLocalGet(rightLow, i32)), carryBit); - GetLocal* getLow = builder->makeGetLocal(lowResult, i32); + LocalGet* getLow = builder->makeLocalGet(lowResult, i32); result = builder->blockify(result, addLow, addHigh, checkOverflow, getLow); setOutParam(result, std::move(highResult)); return result; @@ -868,27 +868,27 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { TempVar lowResult = getTemp(); TempVar highResult = getTemp(); TempVar borrow = getTemp(); - SetLocal* subLow = builder->makeSetLocal( + LocalSet* subLow = builder->makeLocalSet( lowResult, builder->makeBinary(SubInt32, - builder->makeGetLocal(leftLow, i32), - builder->makeGetLocal(rightLow, i32))); - SetLocal* borrowBit = builder->makeSetLocal( + builder->makeLocalGet(leftLow, i32), + builder->makeLocalGet(rightLow, i32))); + LocalSet* borrowBit = builder->makeLocalSet( borrow, builder->makeBinary(LtUInt32, - builder->makeGetLocal(leftLow, i32), - builder->makeGetLocal(rightLow, i32))); - SetLocal* subHigh1 = builder->makeSetLocal( + builder->makeLocalGet(leftLow, i32), + builder->makeLocalGet(rightLow, i32))); + LocalSet* subHigh1 = builder->makeLocalSet( highResult, builder->makeBinary(AddInt32, - builder->makeGetLocal(borrow, i32), - builder->makeGetLocal(rightHigh, i32))); - SetLocal* subHigh2 = builder->makeSetLocal( + builder->makeLocalGet(borrow, i32), + builder->makeLocalGet(rightHigh, i32))); + LocalSet* subHigh2 = builder->makeLocalSet( highResult, builder->makeBinary(SubInt32, - builder->makeGetLocal(leftHigh, i32), - builder->makeGetLocal(highResult, i32))); - GetLocal* getLow = builder->makeGetLocal(lowResult, i32); + builder->makeLocalGet(leftHigh, i32), + builder->makeLocalGet(highResult, i32))); + LocalGet* getLow = builder->makeLocalGet(lowResult, i32); result = builder->blockify(result, subLow, borrowBit, subHigh1, subHigh2, getLow); setOutParam(result, std::move(highResult)); @@ -917,25 +917,25 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { } result = builder->blockify( result, - builder->makeSetLocal( + builder->makeLocalSet( rightHigh, builder->makeBinary(op32, - builder->makeGetLocal(leftHigh, i32), - builder->makeGetLocal(rightHigh, i32))), + builder->makeLocalGet(leftHigh, i32), + builder->makeLocalGet(rightHigh, i32))), builder->makeBinary(op32, - builder->makeGetLocal(leftLow, i32), - builder->makeGetLocal(rightLow, i32))); + builder->makeLocalGet(leftLow, i32), + builder->makeLocalGet(rightLow, i32))); setOutParam(result, std::move(rightHigh)); return result; } Block* makeLargeShl(Index highBits, Index leftLow, Index shift) { return builder->blockify( - builder->makeSetLocal( + builder->makeLocalSet( highBits, builder->makeBinary(ShlInt32, - builder->makeGetLocal(leftLow, i32), - builder->makeGetLocal(shift, i32))), + builder->makeLocalGet(leftLow, i32), + builder->makeLocalGet(shift, i32))), builder->makeConst(Literal(int32_t(0)))); } @@ -947,22 +947,22 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { // lo = leftHigh >> (b - 32) Block* makeLargeShrS(Index highBits, Index leftHigh, Index shift) { return builder->blockify( - builder->makeSetLocal( + builder->makeLocalSet( highBits, builder->makeBinary(ShrSInt32, - builder->makeGetLocal(leftHigh, i32), + builder->makeLocalGet(leftHigh, i32), builder->makeConst(Literal(int32_t(31))))), builder->makeBinary(ShrSInt32, - builder->makeGetLocal(leftHigh, i32), - builder->makeGetLocal(shift, i32))); + builder->makeLocalGet(leftHigh, i32), + builder->makeLocalGet(shift, i32))); } Block* makeLargeShrU(Index highBits, Index leftHigh, Index shift) { return builder->blockify( - builder->makeSetLocal(highBits, builder->makeConst(Literal(int32_t(0)))), + builder->makeLocalSet(highBits, builder->makeConst(Literal(int32_t(0)))), builder->makeBinary(ShrUInt32, - builder->makeGetLocal(leftHigh, i32), - builder->makeGetLocal(shift, i32))); + builder->makeLocalGet(leftHigh, i32), + builder->makeLocalGet(shift, i32))); } Block* makeSmallShl(Index highBits, @@ -975,17 +975,17 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { AndInt32, shiftMask, builder->makeBinary( - ShrUInt32, builder->makeGetLocal(leftLow, i32), widthLessShift)); + ShrUInt32, builder->makeLocalGet(leftLow, i32), widthLessShift)); Binary* shiftHigh = builder->makeBinary(ShlInt32, - builder->makeGetLocal(leftHigh, i32), - builder->makeGetLocal(shift, i32)); + builder->makeLocalGet(leftHigh, i32), + builder->makeLocalGet(shift, i32)); return builder->blockify( - builder->makeSetLocal( + builder->makeLocalSet( highBits, builder->makeBinary(OrInt32, shiftedInBits, shiftHigh)), builder->makeBinary(ShlInt32, - builder->makeGetLocal(leftLow, i32), - builder->makeGetLocal(shift, i32))); + builder->makeLocalGet(leftLow, i32), + builder->makeLocalGet(shift, i32))); } // a >> b where `b` < 32 @@ -1003,17 +1003,17 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { Binary* shiftedInBits = builder->makeBinary( ShlInt32, builder->makeBinary( - AndInt32, shiftMask, builder->makeGetLocal(leftHigh, i32)), + AndInt32, shiftMask, builder->makeLocalGet(leftHigh, i32)), widthLessShift); Binary* shiftLow = builder->makeBinary(ShrUInt32, - builder->makeGetLocal(leftLow, i32), - builder->makeGetLocal(shift, i32)); + builder->makeLocalGet(leftLow, i32), + builder->makeLocalGet(shift, i32)); return builder->blockify( - builder->makeSetLocal( + builder->makeLocalSet( highBits, builder->makeBinary(ShrSInt32, - builder->makeGetLocal(leftHigh, i32), - builder->makeGetLocal(shift, i32))), + builder->makeLocalGet(leftHigh, i32), + builder->makeLocalGet(shift, i32))), builder->makeBinary(OrInt32, shiftedInBits, shiftLow)); } @@ -1026,17 +1026,17 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { Binary* shiftedInBits = builder->makeBinary( ShlInt32, builder->makeBinary( - AndInt32, shiftMask, builder->makeGetLocal(leftHigh, i32)), + AndInt32, shiftMask, builder->makeLocalGet(leftHigh, i32)), widthLessShift); Binary* shiftLow = builder->makeBinary(ShrUInt32, - builder->makeGetLocal(leftLow, i32), - builder->makeGetLocal(shift, i32)); + builder->makeLocalGet(leftLow, i32), + builder->makeLocalGet(shift, i32)); return builder->blockify( - builder->makeSetLocal( + builder->makeLocalSet( highBits, builder->makeBinary(ShrUInt32, - builder->makeGetLocal(leftHigh, i32), - builder->makeGetLocal(shift, i32))), + builder->makeLocalGet(leftHigh, i32), + builder->makeLocalGet(shift, i32))), builder->makeBinary(OrInt32, shiftedInBits, shiftLow)); } @@ -1055,16 +1055,16 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { // low = leftLow << k // where k = shift % 32. shift right is similar. TempVar shift = getTemp(); - SetLocal* setShift = builder->makeSetLocal( + LocalSet* setShift = builder->makeLocalSet( shift, builder->makeBinary(AndInt32, - builder->makeGetLocal(rightLow, i32), + builder->makeLocalGet(rightLow, i32), builder->makeConst(Literal(int32_t(32 - 1))))); Binary* isLargeShift = builder->makeBinary( LeUInt32, builder->makeConst(Literal(int32_t(32))), builder->makeBinary(AndInt32, - builder->makeGetLocal(rightLow, i32), + builder->makeLocalGet(rightLow, i32), builder->makeConst(Literal(int32_t(64 - 1))))); Block* largeShiftBlock; switch (op) { @@ -1084,12 +1084,12 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { SubInt32, builder->makeBinary(ShlInt32, builder->makeConst(Literal(int32_t(1))), - builder->makeGetLocal(shift, i32)), + builder->makeLocalGet(shift, i32)), builder->makeConst(Literal(int32_t(1)))); Binary* widthLessShift = builder->makeBinary(SubInt32, builder->makeConst(Literal(int32_t(32))), - builder->makeGetLocal(shift, i32)); + builder->makeLocalGet(shift, i32)); Block* smallShiftBlock; switch (op) { case ShlInt64: { @@ -1127,11 +1127,11 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { builder->makeBinary( AndInt32, builder->makeBinary(EqInt32, - builder->makeGetLocal(leftLow, i32), - builder->makeGetLocal(rightLow, i32)), + builder->makeLocalGet(leftLow, i32), + builder->makeLocalGet(rightLow, i32)), builder->makeBinary(EqInt32, - builder->makeGetLocal(leftHigh, i32), - builder->makeGetLocal(rightHigh, i32)))); + builder->makeLocalGet(leftHigh, i32), + builder->makeLocalGet(rightHigh, i32)))); } Block* lowerNe(Block* result, @@ -1144,11 +1144,11 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { builder->makeBinary( OrInt32, builder->makeBinary(NeInt32, - builder->makeGetLocal(leftLow, i32), - builder->makeGetLocal(rightLow, i32)), + builder->makeLocalGet(leftLow, i32), + builder->makeLocalGet(rightLow, i32)), builder->makeBinary(NeInt32, - builder->makeGetLocal(leftHigh, i32), - builder->makeGetLocal(rightHigh, i32)))); + builder->makeLocalGet(leftHigh, i32), + builder->makeLocalGet(rightHigh, i32)))); } Block* lowerUComp(BinaryOp op, @@ -1180,14 +1180,14 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { } Binary* compHigh = builder->makeBinary(highOp, - builder->makeGetLocal(leftHigh, i32), - builder->makeGetLocal(rightHigh, i32)); + builder->makeLocalGet(leftHigh, i32), + builder->makeLocalGet(rightHigh, i32)); Binary* eqHigh = builder->makeBinary(EqInt32, - builder->makeGetLocal(leftHigh, i32), - builder->makeGetLocal(rightHigh, i32)); + builder->makeLocalGet(leftHigh, i32), + builder->makeLocalGet(rightHigh, i32)); Binary* compLow = builder->makeBinary(lowOp, - builder->makeGetLocal(leftLow, i32), - builder->makeGetLocal(rightLow, i32)); + builder->makeLocalGet(leftLow, i32), + builder->makeLocalGet(rightLow, i32)); return builder->blockify( result, builder->makeBinary( @@ -1227,15 +1227,15 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { } Binary* compHigh1 = builder->makeBinary(highOp1, - builder->makeGetLocal(leftHigh, i32), - builder->makeGetLocal(rightHigh, i32)); + builder->makeLocalGet(leftHigh, i32), + builder->makeLocalGet(rightHigh, i32)); Binary* compHigh2 = builder->makeBinary(highOp2, - builder->makeGetLocal(leftHigh, i32), - builder->makeGetLocal(rightHigh, i32)); + builder->makeLocalGet(leftHigh, i32), + builder->makeLocalGet(rightHigh, i32)); Binary* compLow = builder->makeBinary(lowOp, - builder->makeGetLocal(leftLow, i32), - builder->makeGetLocal(rightLow, i32)); + builder->makeLocalGet(leftLow, i32), + builder->makeLocalGet(rightLow, i32)); If* lowIf = builder->makeIf(compLow, builder->makeConst(Literal(int32_t(0))), builder->makeConst(Literal(int32_t(1)))); @@ -1291,8 +1291,8 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { TempVar leftHigh = fetchOutParam(curr->left); TempVar rightLow = getTemp(); TempVar rightHigh = fetchOutParam(curr->right); - SetLocal* setRight = builder->makeSetLocal(rightLow, curr->right); - SetLocal* setLeft = builder->makeSetLocal(leftLow, curr->left); + LocalSet* setRight = builder->makeLocalSet(rightLow, curr->right); + LocalSet* setLeft = builder->makeLocalSet(leftLow, curr->left); Block* result = builder->blockify(setLeft, setRight); switch (curr->op) { case AddInt64: { @@ -1403,18 +1403,18 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { TempVar lowBits = getTemp(); TempVar cond = getTemp(); Block* result = builder->blockify( - builder->makeSetLocal(cond, curr->condition), - builder->makeSetLocal( + builder->makeLocalSet(cond, curr->condition), + builder->makeLocalSet( lowBits, builder->makeSelect( - builder->makeGetLocal(cond, i32), curr->ifTrue, curr->ifFalse)), - builder->makeSetLocal( + builder->makeLocalGet(cond, i32), curr->ifTrue, curr->ifFalse)), + builder->makeLocalSet( highBits, builder->makeSelect( - builder->makeGetLocal(cond, i32), - builder->makeGetLocal(fetchOutParam(curr->ifTrue), i32), - builder->makeGetLocal(fetchOutParam(curr->ifFalse), i32))), - builder->makeGetLocal(lowBits, i32)); + builder->makeLocalGet(cond, i32), + builder->makeLocalGet(fetchOutParam(curr->ifTrue), i32), + builder->makeLocalGet(fetchOutParam(curr->ifFalse), i32))), + builder->makeLocalGet(lowBits, i32)); setOutParam(result, std::move(highBits)); replaceCurrent(result); } @@ -1433,10 +1433,10 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { } TempVar lowBits = getTemp(); TempVar highBits = fetchOutParam(curr->value); - SetLocal* setLow = builder->makeSetLocal(lowBits, curr->value); - SetGlobal* setHigh = builder->makeSetGlobal( - INT64_TO_32_HIGH_BITS, builder->makeGetLocal(highBits, i32)); - curr->value = builder->makeGetLocal(lowBits, i32); + LocalSet* setLow = builder->makeLocalSet(lowBits, curr->value); + GlobalSet* setHigh = builder->makeGlobalSet( + INT64_TO_32_HIGH_BITS, builder->makeLocalGet(highBits, i32)); + curr->value = builder->makeLocalGet(lowBits, i32); Block* result = builder->blockify(setLow, setHigh, curr); replaceCurrent(result); } diff --git a/src/passes/Inlining.cpp b/src/passes/Inlining.cpp index 11f452e17..04e82579c 100644 --- a/src/passes/Inlining.cpp +++ b/src/passes/Inlining.cpp @@ -199,10 +199,10 @@ doInlining(Module* module, Function* into, InliningAction& action) { void visitReturn(Return* curr) { replaceCurrent(builder->makeBreak(returnName, curr->value)); } - void visitGetLocal(GetLocal* curr) { + void visitLocalGet(LocalGet* curr) { curr->index = localMapping[curr->index]; } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { curr->index = localMapping[curr->index]; } } updater; @@ -214,13 +214,13 @@ doInlining(Module* module, Function* into, InliningAction& action) { // assign the operands into the params for (Index i = 0; i < from->params.size(); i++) { block->list.push_back( - builder.makeSetLocal(updater.localMapping[i], call->operands[i])); + builder.makeLocalSet(updater.localMapping[i], call->operands[i])); } // zero out the vars (as we may be in a loop, and may depend on their // zero-init value for (Index i = 0; i < from->vars.size(); i++) { block->list.push_back( - builder.makeSetLocal(updater.localMapping[from->getVarIndexBase() + i], + builder.makeLocalSet(updater.localMapping[from->getVarIndexBase() + i], LiteralUtils::makeZero(from->vars[i], *module))); } // generate and update the inlined contents diff --git a/src/passes/InstrumentLocals.cpp b/src/passes/InstrumentLocals.cpp index 45d4d484b..32623a432 100644 --- a/src/passes/InstrumentLocals.cpp +++ b/src/passes/InstrumentLocals.cpp @@ -64,7 +64,7 @@ Name set_f32("set_f32"); Name set_f64("set_f64"); struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { - void visitGetLocal(GetLocal* curr) { + void visitLocalGet(LocalGet* curr) { Builder builder(*getModule()); Name import; switch (curr->type) { @@ -96,7 +96,7 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { curr->type)); } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { Builder builder(*getModule()); Name import; switch (curr->value->type) { diff --git a/src/passes/LegalizeJSInterface.cpp b/src/passes/LegalizeJSInterface.cpp index ad6d0c35b..23cceb4ef 100644 --- a/src/passes/LegalizeJSInterface.cpp +++ b/src/passes/LegalizeJSInterface.cpp @@ -176,7 +176,7 @@ private: legal->params.push_back(i32); } else { call->operands.push_back( - builder.makeGetLocal(legal->params.size(), param)); + builder.makeLocalGet(legal->params.size(), param)); legal->params.push_back(param); } } @@ -186,7 +186,7 @@ private: legal->result = i32; auto index = Builder::addVar(legal, Name(), i64); auto* block = builder.makeBlock(); - block->list.push_back(builder.makeSetLocal(index, call)); + block->list.push_back(builder.makeLocalSet(index, call)); block->list.push_back(builder.makeCall( f->name, {I64Utilities::getI64High(builder, index)}, none)); block->list.push_back(I64Utilities::getI64Low(builder, index)); @@ -233,7 +233,7 @@ private: type->params.push_back(i32); } else { call->operands.push_back( - builder.makeGetLocal(func->params.size(), param)); + builder.makeLocalGet(func->params.size(), param)); type->params.push_back(param); } func->params.push_back(param); diff --git a/src/passes/LocalCSE.cpp b/src/passes/LocalCSE.cpp index d582c8275..f3e03d95d 100644 --- a/src/passes/LocalCSE.cpp +++ b/src/passes/LocalCSE.cpp @@ -114,7 +114,7 @@ struct LocalCSE : public WalkerPass<LinearExecutionWalker<LocalCSE>> { // the loop above - just the values. So here we must check that // sets do not interfere. (Note that due to flattening we // have no risk of tees etc.) - if (auto* set = curr->dynCast<SetLocal>()) { + if (auto* set = curr->dynCast<LocalSet>()) { for (auto& sinkable : usables) { // Check if the index is the same. Make sure to ignore // our own value, which we may have just added! @@ -170,10 +170,10 @@ struct LocalCSE : public WalkerPass<LinearExecutionWalker<LocalCSE>> { } void handle(Expression* curr) { - if (auto* set = curr->dynCast<SetLocal>()) { + if (auto* set = curr->dynCast<LocalSet>()) { // Calculate equivalences equivalences.reset(set->index); - if (auto* get = set->value->dynCast<GetLocal>()) { + if (auto* get = set->value->dynCast<LocalGet>()) { equivalences.add(set->index, get->index); } // consider the value @@ -185,7 +185,7 @@ struct LocalCSE : public WalkerPass<LinearExecutionWalker<LocalCSE>> { // already exists in the table, this is good to reuse auto& info = iter->second; set->value = - Builder(*getModule()).makeGetLocal(info.index, value->type); + Builder(*getModule()).makeLocalGet(info.index, value->type); anotherPass = true; } else { // not in table, add this, maybe we can help others later @@ -193,7 +193,7 @@ struct LocalCSE : public WalkerPass<LinearExecutionWalker<LocalCSE>> { hashed, UsableInfo(value, set->index, getPassOptions()))); } } - } else if (auto* get = curr->dynCast<GetLocal>()) { + } else if (auto* get = curr->dynCast<LocalGet>()) { if (auto* set = equivalences.getEquivalents(get->index)) { // Canonicalize to the lowest index. This lets hashing and comparisons // "just work". @@ -205,7 +205,7 @@ struct LocalCSE : public WalkerPass<LinearExecutionWalker<LocalCSE>> { // A relevant value is a non-trivial one, something we may want to reuse // and are able to. bool isRelevant(Expression* value) { - if (value->is<GetLocal>()) { + if (value->is<LocalGet>()) { return false; // trivial, this is what we optimize to! } if (!isConcreteType(value->type)) { diff --git a/src/passes/LoopInvariantCodeMotion.cpp b/src/passes/LoopInvariantCodeMotion.cpp index b8e00ffce..c4880114d 100644 --- a/src/passes/LoopInvariantCodeMotion.cpp +++ b/src/passes/LoopInvariantCodeMotion.cpp @@ -39,7 +39,7 @@ struct LoopInvariantCodeMotion Pass* create() override { return new LoopInvariantCodeMotion; } - typedef std::unordered_set<SetLocal*> LoopSets; + typedef std::unordered_set<LocalSet*> LoopSets; // main entry point @@ -78,7 +78,7 @@ struct LoopInvariantCodeMotion std::fill(numSetsForIndex.begin(), numSetsForIndex.end(), 0); LoopSets loopSets; { - FindAll<SetLocal> finder(loop); + FindAll<LocalSet> finder(loop); for (auto* set : finder.list) { numSetsForIndex[set->index]++; loopSets.insert(set); @@ -135,7 +135,7 @@ struct LoopInvariantCodeMotion // and must also check if our sets interfere with them. To do so, // assume temporarily that we are moving curr out; see if any sets // remain for its indexes. - FindAll<SetLocal> currSets(curr); + FindAll<LocalSet> currSets(curr); for (auto* set : currSets.list) { assert(numSetsForIndex[set->index] > 0); numSetsForIndex[set->index]--; @@ -205,15 +205,15 @@ struct LoopInvariantCodeMotion // it is beneficial to run this pass later on (but that has downsides // too, as with more nesting moving code is harder - so something // like -O --flatten --licm -O may be best). - if (auto* set = curr->dynCast<SetLocal>()) { + if (auto* set = curr->dynCast<LocalSet>()) { while (1) { - auto* next = set->value->dynCast<SetLocal>(); + auto* next = set->value->dynCast<LocalSet>(); if (!next) { break; } set = next; } - if (set->value->is<GetLocal>() || set->value->is<Const>()) { + if (set->value->is<LocalGet>() || set->value->is<Const>()) { return false; } } @@ -221,7 +221,7 @@ struct LoopInvariantCodeMotion } bool hasGetDependingOnLoopSet(Expression* curr, LoopSets& loopSets) { - FindAll<GetLocal> gets(curr); + FindAll<LocalGet> gets(curr); for (auto* get : gets.list) { auto& sets = localGraph->getSetses[get]; for (auto* set : sets) { diff --git a/src/passes/MergeBlocks.cpp b/src/passes/MergeBlocks.cpp index 973f17eec..bba64c381 100644 --- a/src/passes/MergeBlocks.cpp +++ b/src/passes/MergeBlocks.cpp @@ -476,7 +476,7 @@ struct MergeBlocks : public WalkerPass<PostWalker<MergeBlocks>> { } void visitUnary(Unary* curr) { optimize(curr, curr->value); } - void visitSetLocal(SetLocal* curr) { optimize(curr, curr->value); } + void visitLocalSet(LocalSet* curr) { optimize(curr, curr->value); } void visitLoad(Load* curr) { optimize(curr, curr->ptr); } void visitReturn(Return* curr) { optimize(curr, curr->value); } diff --git a/src/passes/MergeLocals.cpp b/src/passes/MergeLocals.cpp index e8d42e8dd..c20105621 100644 --- a/src/passes/MergeLocals.cpp +++ b/src/passes/MergeLocals.cpp @@ -82,13 +82,13 @@ struct MergeLocals optimizeCopies(); } - std::vector<SetLocal*> copies; + std::vector<LocalSet*> copies; - void visitSetLocal(SetLocal* curr) { - if (auto* get = curr->value->dynCast<GetLocal>()) { + void visitLocalSet(LocalSet* curr) { + if (auto* get = curr->value->dynCast<LocalGet>()) { if (get->index != curr->index) { Builder builder(*getModule()); - auto* trivial = builder.makeTeeLocal(get->index, get); + auto* trivial = builder.makeLocalTee(get->index, get); curr->value = trivial; copies.push_back(curr); } @@ -103,10 +103,10 @@ struct MergeLocals LocalGraph preGraph(getFunction()); preGraph.computeInfluences(); // optimize each copy - std::unordered_map<SetLocal*, SetLocal*> optimizedToCopy, + std::unordered_map<LocalSet*, LocalSet*> optimizedToCopy, optimizedToTrivial; for (auto* copy : copies) { - auto* trivial = copy->value->cast<SetLocal>(); + auto* trivial = copy->value->cast<LocalSet>(); bool canOptimizeToCopy = false; auto& trivialInfluences = preGraph.setInfluences[trivial]; if (!trivialInfluences.empty()) { @@ -215,7 +215,7 @@ struct MergeLocals } // remove the trivial sets for (auto* copy : copies) { - copy->value = copy->value->cast<SetLocal>()->value; + copy->value = copy->value->cast<LocalSet>()->value; } } }; diff --git a/src/passes/OptimizeAddedConstants.cpp b/src/passes/OptimizeAddedConstants.cpp index b8d011cfb..8a72a0cd0 100644 --- a/src/passes/OptimizeAddedConstants.cpp +++ b/src/passes/OptimizeAddedConstants.cpp @@ -76,7 +76,7 @@ public: // load(y, offset=10) // // This is only valid if y does not change in the middle! - if (auto* get = curr->ptr->template dynCast<GetLocal>()) { + if (auto* get = curr->ptr->template dynCast<LocalGet>()) { auto& sets = localGraph->getSetses[get]; if (sets.size() == 1) { auto* set = *sets.begin(); @@ -159,8 +159,8 @@ private: bool tryToOptimizePropagatedAdd(Expression* oneSide, Expression* otherSide, - GetLocal* ptr, - SetLocal* set) { + LocalGet* ptr, + LocalSet* set) { if (auto* c = oneSide->template dynCast<Const>()) { if (otherSide->template is<Const>()) { // Both sides are constant - this is not optimized code, ignore. @@ -191,7 +191,7 @@ private: // dominates the load, and it is ok to replace x with y + 10 there. Index index = -1; bool canReuseIndex = false; - if (auto* get = otherSide->template dynCast<GetLocal>()) { + if (auto* get = otherSide->template dynCast<LocalGet>()) { if (localGraph->isSSA(get->index) && localGraph->isSSA(ptr->index)) { index = get->index; canReuseIndex = true; @@ -213,7 +213,7 @@ private: index = parent->getHelperIndex(set); } curr->offset = result.total; - curr->ptr = Builder(*module).makeGetLocal(index, i32); + curr->ptr = Builder(*module).makeLocalGet(index, i32); return true; } } @@ -298,7 +298,7 @@ struct OptimizeAddedConstants // the expression, but the set in which it is in, as the arm of an add that is // the set's value (the other arm is a constant, and we are not a constant). // We cache these, that is, use a single one for all requests. - Index getHelperIndex(SetLocal* set) { + Index getHelperIndex(LocalSet* set) { auto iter = helperIndexes.find(set); if (iter != helperIndexes.end()) { return iter->second; @@ -307,7 +307,7 @@ struct OptimizeAddedConstants Builder(*getModule()).addVar(getFunction(), i32); } - bool isPropagatable(SetLocal* set) { return propagatable.count(set); } + bool isPropagatable(LocalSet* set) { return propagatable.count(set); } private: bool propagated; @@ -315,7 +315,7 @@ private: std::unique_ptr<LocalGraph> localGraph; // Whether a set is propagatable. - std::set<SetLocal*> propagatable; + std::set<LocalSet*> propagatable; void findPropagatable() { // Conservatively, only propagate if all uses can be removed of the @@ -331,7 +331,7 @@ private: Parents parents(getFunction()->body); for (auto& pair : localGraph->locations) { auto* location = pair.first; - if (auto* set = location->dynCast<SetLocal>()) { + if (auto* set = location->dynCast<LocalSet>()) { if (auto* add = set->value->dynCast<Binary>()) { if (add->op == AddInt32) { if (add->left->is<Const>() || add->right->is<Const>()) { @@ -363,17 +363,17 @@ private: UnneededSetRemover remover(getFunction(), getPassOptions()); } - std::map<SetLocal*, Index> helperIndexes; + std::map<LocalSet*, Index> helperIndexes; void createHelperIndexes() { struct Creator : public PostWalker<Creator> { - std::map<SetLocal*, Index>& helperIndexes; + std::map<LocalSet*, Index>& helperIndexes; Module* module; - Creator(std::map<SetLocal*, Index>& helperIndexes) + Creator(std::map<LocalSet*, Index>& helperIndexes) : helperIndexes(helperIndexes) {} - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { auto iter = helperIndexes.find(curr); if (iter != helperIndexes.end()) { auto index = iter->second; @@ -387,9 +387,9 @@ private: } auto* value = *target; Builder builder(*module); - *target = builder.makeGetLocal(index, i32); + *target = builder.makeLocalGet(index, i32); replaceCurrent( - builder.makeSequence(builder.makeSetLocal(index, value), curr)); + builder.makeSequence(builder.makeLocalSet(index, value), curr)); } } } creator(helperIndexes); diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index 85258dbb8..cf764ac49 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -166,10 +166,10 @@ Index getMaxBits(Expression* curr, LocalInfoProvider* localInfoProvider) { return std::min(Index(32), getMaxBits(unary->value, localInfoProvider)); default: {} } - } else if (auto* set = curr->dynCast<SetLocal>()) { + } else if (auto* set = curr->dynCast<LocalSet>()) { // a tee passes through the value return getMaxBits(set->value, localInfoProvider); - } else if (auto* get = curr->dynCast<GetLocal>()) { + } else if (auto* get = curr->dynCast<LocalGet>()) { return localInfoProvider->getMaxBitsForLocal(get); } else if (auto* load = curr->dynCast<Load>()) { // if signed, then the sign-extension might fill all the bits @@ -226,7 +226,7 @@ struct LocalScanner : PostWalker<LocalScanner> { } } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { auto* func = getFunction(); if (func->isParam(curr->index)) { return; @@ -257,7 +257,7 @@ struct LocalScanner : PostWalker<LocalScanner> { // define this for the templated getMaxBits method. we know nothing here yet // about locals, so return the maxes - Index getMaxBitsForLocal(GetLocal* get) { return getBitsForType(get->type); } + Index getMaxBitsForLocal(LocalGet* get) { return getBitsForType(get->type); } Index getBitsForType(Type type) { switch (type) { @@ -728,9 +728,9 @@ struct OptimizeInstructions return unary; } } - } else if (auto* set = curr->dynCast<SetGlobal>()) { + } else if (auto* set = curr->dynCast<GlobalSet>()) { // optimize out a set of a get - auto* get = set->value->dynCast<GetGlobal>(); + auto* get = set->value->dynCast<GlobalGet>(); if (get && get->name == set->name) { ExpressionManipulator::nop(curr); } @@ -874,7 +874,7 @@ struct OptimizeInstructions return nullptr; } - Index getMaxBitsForLocal(GetLocal* get) { + Index getMaxBitsForLocal(LocalGet* get) { // check what we know about the local return localInfo[get->index].maxBits; } @@ -906,7 +906,7 @@ private: return; } // Prefer a get on the right. - if (binary->left->is<GetLocal>() && !binary->right->is<GetLocal>()) { + if (binary->left->is<LocalGet>() && !binary->right->is<LocalGet>()) { return maybeSwap(); } // Sort by the node id type, if different. @@ -929,8 +929,8 @@ private: return maybeSwap(); } } - if (auto* left = binary->left->dynCast<GetLocal>()) { - auto* right = binary->right->cast<GetLocal>(); + if (auto* left = binary->left->dynCast<LocalGet>()) { + auto* right = binary->right->cast<LocalGet>(); if (left->index > right->index) { return maybeSwap(); } @@ -1270,7 +1270,7 @@ private: if (Properties::getSignExtValue(curr)) { return Properties::getSignExtBits(curr) == bits; } - if (auto* get = curr->dynCast<GetLocal>()) { + if (auto* get = curr->dynCast<LocalGet>()) { // check what we know about the local return localInfo[get->index].signExtedBits == bits; } diff --git a/src/passes/PickLoadSigns.cpp b/src/passes/PickLoadSigns.cpp index f494159a1..c3b5a2ba2 100644 --- a/src/passes/PickLoadSigns.cpp +++ b/src/passes/PickLoadSigns.cpp @@ -51,7 +51,7 @@ struct PickLoadSigns : public WalkerPass<ExpressionStackWalker<PickLoadSigns>> { optimize(); } - void visitGetLocal(GetLocal* curr) { + void visitLocalGet(LocalGet* curr) { // this is a use. check from the context what it is, signed or unsigned, // etc. auto& usage = usages[curr->index]; @@ -81,7 +81,7 @@ struct PickLoadSigns : public WalkerPass<ExpressionStackWalker<PickLoadSigns>> { } } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { if (curr->isTee()) { // we can't modify a tee, the value is used elsewhere return; diff --git a/src/passes/PostEmscripten.cpp b/src/passes/PostEmscripten.cpp index cc4b03a7f..9d2b41094 100644 --- a/src/passes/PostEmscripten.cpp +++ b/src/passes/PostEmscripten.cpp @@ -48,7 +48,7 @@ struct PostEmscripten : public WalkerPass<PostWalker<PostEmscripten>> { replaceCurrent(builder.makeBinary( MulFloat64, localizer.expr, - builder.makeGetLocal(localizer.index, localizer.expr->type))); + builder.makeLocalGet(localizer.index, localizer.expr->type))); } else if (exponent->value == Literal(double(0.5))) { // This is just a square root operation replaceCurrent( diff --git a/src/passes/Precompute.cpp b/src/passes/Precompute.cpp index d5cfdc968..2e8c8fe31 100644 --- a/src/passes/Precompute.cpp +++ b/src/passes/Precompute.cpp @@ -41,7 +41,7 @@ namespace wasm { static const Name NOTPRECOMPUTABLE_FLOW("Binaryen|notprecomputable"); -typedef std::unordered_map<GetLocal*, Literal> GetValues; +typedef std::unordered_map<LocalGet*, Literal> GetValues; // Precomputes an expression. Errors if we hit anything that can't be // precomputed. @@ -80,7 +80,7 @@ public: Flow visitCallIndirect(CallIndirect* curr) { return Flow(NOTPRECOMPUTABLE_FLOW); } - Flow visitGetLocal(GetLocal* curr) { + Flow visitLocalGet(LocalGet* curr) { auto iter = getValues.find(curr); if (iter != getValues.end()) { auto value = iter->second; @@ -90,7 +90,7 @@ public: } return Flow(NOTPRECOMPUTABLE_FLOW); } - Flow visitSetLocal(SetLocal* curr) { + Flow visitLocalSet(LocalSet* curr) { // If we don't need to replace the whole expression, see if there // is a value flowing through a tee. if (!replaceExpression) { @@ -101,14 +101,14 @@ public: } return Flow(NOTPRECOMPUTABLE_FLOW); } - Flow visitGetGlobal(GetGlobal* curr) { + Flow visitGlobalGet(GlobalGet* curr) { auto* global = module->getGlobal(curr->name); if (!global->imported() && !global->mutable_) { return visit(global->init); } return Flow(NOTPRECOMPUTABLE_FLOW); } - Flow visitSetGlobal(SetGlobal* curr) { return Flow(NOTPRECOMPUTABLE_FLOW); } + Flow visitGlobalSet(GlobalSet* curr) { return Flow(NOTPRECOMPUTABLE_FLOW); } Flow visitLoad(Load* curr) { return Flow(NOTPRECOMPUTABLE_FLOW); } Flow visitStore(Store* curr) { return Flow(NOTPRECOMPUTABLE_FLOW); } Flow visitAtomicRMW(AtomicRMW* curr) { return Flow(NOTPRECOMPUTABLE_FLOW); } @@ -296,7 +296,7 @@ private: work.insert(curr); } // the constant value, or none if not a constant - std::unordered_map<SetLocal*, Literal> setValues; + std::unordered_map<LocalSet*, Literal> setValues; // propagate constant values while (!work.empty()) { auto iter = work.begin(); @@ -305,7 +305,7 @@ private: // see if this set or get is actually a constant value, and if so, // mark it as such and add everything it influences to the work list, // as they may be constant too. - if (auto* set = curr->dynCast<SetLocal>()) { + if (auto* set = curr->dynCast<LocalSet>()) { if (setValues[set].isConcrete()) { continue; // already known constant } @@ -317,7 +317,7 @@ private: } } } else { - auto* get = curr->cast<GetLocal>(); + auto* get = curr->cast<LocalGet>(); if (getValues[get].isConcrete()) { continue; // already known constant } diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 73d91b9ce..fb85023f0 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -111,10 +111,10 @@ struct PrintExpressionContents : public Visitor<PrintExpressionContents> { void visitCallIndirect(CallIndirect* curr) { printMedium(o, "call_indirect (type ") << curr->fullType << ')'; } - void visitGetLocal(GetLocal* curr) { + void visitLocalGet(LocalGet* curr) { printMedium(o, "local.get ") << printableLocal(curr->index, currFunction); } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { if (curr->isTee()) { printMedium(o, "local.tee "); } else { @@ -122,11 +122,11 @@ struct PrintExpressionContents : public Visitor<PrintExpressionContents> { } o << printableLocal(curr->index, currFunction); } - void visitGetGlobal(GetGlobal* curr) { + void visitGlobalGet(GlobalGet* curr) { printMedium(o, "global.get "); printName(curr->name, o); } - void visitSetGlobal(SetGlobal* curr) { + void visitGlobalSet(GlobalSet* curr) { printMedium(o, "global.set "); printName(curr->name, o); } @@ -1140,11 +1140,11 @@ struct PrintExpressionContents : public Visitor<PrintExpressionContents> { void visitReturn(Return* curr) { printMedium(o, "return"); } void visitHost(Host* curr) { switch (curr->op) { - case CurrentMemory: - printMedium(o, "current_memory"); + case MemorySize: + printMedium(o, "memory.size"); break; - case GrowMemory: - printMedium(o, "grow_memory"); + case MemoryGrow: + printMedium(o, "memory.grow"); break; } } @@ -1402,24 +1402,24 @@ struct PrintSExpression : public Visitor<PrintSExpression> { printFullLine(curr->target); decIndent(); } - void visitGetLocal(GetLocal* curr) { + void visitLocalGet(LocalGet* curr) { o << '('; PrintExpressionContents(currFunction, o).visit(curr); o << ')'; } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { o << '('; PrintExpressionContents(currFunction, o).visit(curr); incIndent(); printFullLine(curr->value); decIndent(); } - void visitGetGlobal(GetGlobal* curr) { + void visitGlobalGet(GlobalGet* curr) { o << '('; PrintExpressionContents(currFunction, o).visit(curr); o << ')'; } - void visitSetGlobal(SetGlobal* curr) { + void visitGlobalSet(GlobalSet* curr) { o << '('; PrintExpressionContents(currFunction, o).visit(curr); incIndent(); @@ -1600,13 +1600,13 @@ struct PrintSExpression : public Visitor<PrintSExpression> { o << '('; PrintExpressionContents(currFunction, o).visit(curr); switch (curr->op) { - case GrowMemory: { + case MemoryGrow: { incIndent(); printFullLine(curr->operands[0]); decIndent(); break; } - case CurrentMemory: { + case MemorySize: { o << ')'; } } diff --git a/src/passes/RedundantSetElimination.cpp b/src/passes/RedundantSetElimination.cpp index bd0e5b890..d881bd9e2 100644 --- a/src/passes/RedundantSetElimination.cpp +++ b/src/passes/RedundantSetElimination.cpp @@ -69,7 +69,7 @@ struct RedundantSetElimination // cfg traversal work - static void doVisitSetLocal(RedundantSetElimination* self, + static void doVisitLocalSet(RedundantSetElimination* self, Expression** currp) { if (self->currBasicBlock) { self->currBasicBlock->contents.setps.push_back(currp); @@ -160,7 +160,7 @@ struct RedundantSetElimination if (auto* c = value->dynCast<Const>()) { // a constant return getLiteralValue(c->value); - } else if (auto* get = value->dynCast<GetLocal>()) { + } else if (auto* get = value->dynCast<LocalGet>()) { // a copy of whatever that was return currValues[get->index]; } else { @@ -292,7 +292,7 @@ struct RedundantSetElimination auto currValues = curr->contents.start; // we'll modify this as we go auto& setps = curr->contents.setps; for (auto** setp : setps) { - auto* set = (*setp)->cast<SetLocal>(); + auto* set = (*setp)->cast<LocalSet>(); currValues[set->index] = getValue(set->value, currValues); } if (currValues == curr->contents.end) { @@ -328,7 +328,7 @@ struct RedundantSetElimination auto currValues = block->contents.start; // we'll modify this as we go auto& setps = block->contents.setps; for (auto** setp : setps) { - auto* set = (*setp)->cast<SetLocal>(); + auto* set = (*setp)->cast<LocalSet>(); auto oldValue = currValues[set->index]; auto newValue = getValue(set->value, currValues); auto index = set->index; @@ -343,10 +343,10 @@ struct RedundantSetElimination } void remove(Expression** setp) { - auto* set = (*setp)->cast<SetLocal>(); + auto* set = (*setp)->cast<LocalSet>(); auto* value = set->value; if (!set->isTee()) { - auto* drop = ExpressionManipulator::convert<SetLocal, Drop>(set); + auto* drop = ExpressionManipulator::convert<LocalSet, Drop>(set); drop->value = value; drop->finalize(); } else { diff --git a/src/passes/RelooperJumpThreading.cpp b/src/passes/RelooperJumpThreading.cpp index 855e89b7f..8dfc1e0e4 100644 --- a/src/passes/RelooperJumpThreading.cpp +++ b/src/passes/RelooperJumpThreading.cpp @@ -48,7 +48,7 @@ static If* isLabelCheckingIf(Expression* curr, Index labelIndex) { if (!(condition && condition->op == EqInt32)) { return nullptr; } - auto* left = condition->left->dynCast<GetLocal>(); + auto* left = condition->left->dynCast<LocalGet>(); if (!(left && left->index == labelIndex)) { return nullptr; } @@ -59,11 +59,11 @@ static Index getCheckedLabelValue(If* iff) { return iff->condition->cast<Binary>()->right->cast<Const>()->value.geti32(); } -static SetLocal* isLabelSettingSetLocal(Expression* curr, Index labelIndex) { +static LocalSet* isLabelSettingLocalSet(Expression* curr, Index labelIndex) { if (!curr) { return nullptr; } - auto* set = curr->dynCast<SetLocal>(); + auto* set = curr->dynCast<LocalSet>(); if (!set) { return nullptr; } @@ -73,7 +73,7 @@ static SetLocal* isLabelSettingSetLocal(Expression* curr, Index labelIndex) { return set; } -static Index getSetLabelValue(SetLocal* set) { +static Index getSetLabelValue(LocalSet* set) { return set->value->cast<Const>()->value.geti32(); } @@ -93,8 +93,8 @@ struct LabelUseFinder : public PostWalker<LabelUseFinder> { } } - void visitSetLocal(SetLocal* curr) { - if (isLabelSettingSetLocal(curr, labelIndex)) { + void visitLocalSet(LocalSet* curr) { + if (isLabelSettingLocalSet(curr, labelIndex)) { sets[getSetLabelValue(curr)]++; } } @@ -247,7 +247,7 @@ private: Index targetNum; Name targetName; - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { if (curr->index == labelIndex) { if (Index(curr->value->cast<Const>()->value.geti32()) == targetNum) { replaceCurrent(Builder(*getModule()).makeBreak(targetName)); diff --git a/src/passes/RemoveNonJSOps.cpp b/src/passes/RemoveNonJSOps.cpp index dd23aa9bf..a2fe10812 100644 --- a/src/passes/RemoveNonJSOps.cpp +++ b/src/passes/RemoveNonJSOps.cpp @@ -314,7 +314,7 @@ struct RemoveNonJSOpsPass : public WalkerPass<PostWalker<RemoveNonJSOpsPass>> { replaceCurrent(builder->makeCall(functionCall, {curr->value}, curr->type)); } - void visitGetGlobal(GetGlobal* curr) { + void visitGlobalGet(GlobalGet* curr) { neededImportedGlobals.insert(std::make_pair(curr->name, curr->type)); } }; diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index 20811efef..1e67ecec3 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -269,9 +269,9 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { Expression* z; replaceCurrent( z = builder.makeIf( - builder.makeTeeLocal(temp, curr->condition), + builder.makeLocalTee(temp, curr->condition), builder.makeIf(builder.makeBinary(EqInt32, - builder.makeGetLocal(temp, i32), + builder.makeLocalGet(temp, i32), builder.makeConst(Literal(int32_t( curr->targets.size() - 1)))), builder.makeBreak(curr->targets.back()), @@ -297,7 +297,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 local.set - // later down, see visitSetLocal. + // later down, see visitLocalSet. } // override scan to add a pre and a post check task to all nodes @@ -895,7 +895,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { return nullptr; } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { // Sets of an if can be optimized in various ways that remove part of // the if branching, or all of it. // The optimizations we can do here can recurse and call each @@ -929,7 +929,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { // ) // TODO: handle a condition in the br? need to watch for side effects bool optimizeSetIfWithBrArm(Expression** currp) { - auto* set = (*currp)->cast<SetLocal>(); + auto* set = (*currp)->cast<LocalSet>(); auto* iff = set->value->dynCast<If>(); if (!iff || !isConcreteType(iff->type) || !isConcreteType(iff->condition->type)) { @@ -1004,18 +1004,18 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { // merged or eliminated given the outside scope, and we // removed one of the if branches. bool optimizeSetIfWithCopyArm(Expression** currp) { - auto* set = (*currp)->cast<SetLocal>(); + auto* set = (*currp)->cast<LocalSet>(); auto* iff = set->value->dynCast<If>(); if (!iff || !isConcreteType(iff->type) || !isConcreteType(iff->condition->type)) { return false; } Builder builder(*getModule()); - GetLocal* get = iff->ifTrue->dynCast<GetLocal>(); + LocalGet* get = iff->ifTrue->dynCast<LocalGet>(); if (get && get->index == set->index) { builder.flip(iff); } else { - get = iff->ifFalse->dynCast<GetLocal>(); + get = iff->ifFalse->dynCast<LocalGet>(); if (get && get->index != set->index) { get = nullptr; } diff --git a/src/passes/RemoveUnusedModuleElements.cpp b/src/passes/RemoveUnusedModuleElements.cpp index ca0817b20..ec9753367 100644 --- a/src/passes/RemoveUnusedModuleElements.cpp +++ b/src/passes/RemoveUnusedModuleElements.cpp @@ -87,13 +87,13 @@ struct ReachabilityAnalyzer : public PostWalker<ReachabilityAnalyzer> { } void visitCallIndirect(CallIndirect* curr) { usesTable = true; } - void visitGetGlobal(GetGlobal* curr) { + void visitGlobalGet(GlobalGet* curr) { if (reachable.count(ModuleElement(ModuleElementKind::Global, curr->name)) == 0) { queue.emplace_back(ModuleElementKind::Global, curr->name); } } - void visitSetGlobal(SetGlobal* curr) { + void visitGlobalSet(GlobalSet* curr) { if (reachable.count(ModuleElement(ModuleElementKind::Global, curr->name)) == 0) { queue.emplace_back(ModuleElementKind::Global, curr->name); @@ -111,7 +111,7 @@ struct ReachabilityAnalyzer : public PostWalker<ReachabilityAnalyzer> { void visitMemoryCopy(MemoryCopy* curr) { usesMemory = true; } void visitMemoryFill(MemoryFill* curr) { usesMemory = true; } void visitHost(Host* curr) { - if (curr->op == CurrentMemory || curr->op == GrowMemory) { + if (curr->op == MemorySize || curr->op == MemoryGrow) { usesMemory = true; } } diff --git a/src/passes/ReorderLocals.cpp b/src/passes/ReorderLocals.cpp index e5e01af5d..3315d0e02 100644 --- a/src/passes/ReorderLocals.cpp +++ b/src/passes/ReorderLocals.cpp @@ -101,13 +101,13 @@ struct ReorderLocals : public WalkerPass<PostWalker<ReorderLocals>> { ReIndexer(Function* func, std::vector<Index>& oldToNew) : func(func), oldToNew(oldToNew) {} - void visitGetLocal(GetLocal* curr) { + void visitLocalGet(LocalGet* curr) { if (func->isVar(curr->index)) { curr->index = oldToNew[curr->index]; } } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { if (func->isVar(curr->index)) { curr->index = oldToNew[curr->index]; } @@ -129,14 +129,14 @@ struct ReorderLocals : public WalkerPass<PostWalker<ReorderLocals>> { } } - void visitGetLocal(GetLocal* curr) { + void visitLocalGet(LocalGet* curr) { counts[curr->index]++; if (firstUses.count(curr->index) == 0) { firstUses[curr->index] = firstUses.size(); } } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { counts[curr->index]++; if (firstUses.count(curr->index) == 0) { firstUses[curr->index] = firstUses.size(); diff --git a/src/passes/SSAify.cpp b/src/passes/SSAify.cpp index 990a627f6..bcafb2784 100644 --- a/src/passes/SSAify.cpp +++ b/src/passes/SSAify.cpp @@ -61,7 +61,7 @@ namespace wasm { // A set we know is impossible / not in the ast -static SetLocal IMPOSSIBLE_SET; +static LocalSet IMPOSSIBLE_SET; // Tracks assignments to locals, assuming single-assignment form, i.e., // each assignment creates a new variable. @@ -97,7 +97,7 @@ struct SSAify : public Pass { } void createNewIndexes(LocalGraph& graph) { - FindAll<SetLocal> sets(func->body); + FindAll<LocalSet> sets(func->body); for (auto* set : sets.list) { // Indexes already in SSA form do not need to be modified - there is // already just one set for that index. Otherwise, use a new index, unless @@ -108,7 +108,7 @@ struct SSAify : public Pass { } } - bool hasMerges(SetLocal* set, LocalGraph& graph) { + bool hasMerges(LocalSet* set, LocalGraph& graph) { for (auto* get : graph.setInfluences[set]) { if (graph.getSetses[get].size() > 1) { return true; @@ -118,7 +118,7 @@ struct SSAify : public Pass { } void computeGetsAndPhis(LocalGraph& graph) { - FindAll<GetLocal> gets(func->body); + FindAll<LocalGet> gets(func->body); for (auto* get : gets.list) { auto& sets = graph.getSetses[get]; if (sets.size() == 0) { @@ -154,7 +154,7 @@ struct SSAify : public Pass { if (set) { // a set exists, just add a tee of its value auto* value = set->value; - auto* tee = builder.makeTeeLocal(new_, value); + auto* tee = builder.makeLocalTee(new_, value); set->value = tee; // the value may have been something we tracked the location // of. if so, update that, since we moved it into the tee @@ -167,8 +167,8 @@ struct SSAify : public Pass { if (func->isParam(old)) { // we add a set with the proper // param value at the beginning of the function - auto* set = builder.makeSetLocal( - new_, builder.makeGetLocal(old, func->getLocalType(old))); + auto* set = builder.makeLocalSet( + new_, builder.makeLocalGet(old, func->getLocalType(old))); functionPrepends.push_back(set); } else { // this is a zero init, so we don't need to do anything actually diff --git a/src/passes/SafeHeap.cpp b/src/passes/SafeHeap.cpp index 2cc309a92..52b4580b5 100644 --- a/src/passes/SafeHeap.cpp +++ b/src/passes/SafeHeap.cpp @@ -243,10 +243,10 @@ struct SafeHeap : public Pass { func->result = style.type; Builder builder(*module); auto* block = builder.makeBlock(); - block->list.push_back(builder.makeSetLocal( + block->list.push_back(builder.makeLocalSet( 2, builder.makeBinary( - AddInt32, builder.makeGetLocal(0, i32), builder.makeGetLocal(1, i32)))); + AddInt32, builder.makeLocalGet(0, i32), builder.makeLocalGet(1, i32)))); // check for reading past valid memory: if pointer + offset + bytes block->list.push_back(makeBoundsCheck(style.type, builder, 2, style.bytes)); // check proper alignment @@ -256,7 +256,7 @@ struct SafeHeap : public Pass { // do the load auto* load = module->allocator.alloc<Load>(); *load = style; // basically the same as the template we are given! - load->ptr = builder.makeGetLocal(2, i32); + load->ptr = builder.makeLocalGet(2, i32); Expression* last = load; if (load->isAtomic && load->signed_) { // atomic loads cannot be signed, manually sign it @@ -284,10 +284,10 @@ struct SafeHeap : public Pass { func->result = none; Builder builder(*module); auto* block = builder.makeBlock(); - block->list.push_back(builder.makeSetLocal( + block->list.push_back(builder.makeLocalSet( 3, builder.makeBinary( - AddInt32, builder.makeGetLocal(0, i32), builder.makeGetLocal(1, i32)))); + AddInt32, builder.makeLocalGet(0, i32), builder.makeLocalGet(1, i32)))); // check for reading past valid memory: if pointer + offset + bytes block->list.push_back( makeBoundsCheck(style.valueType, builder, 3, style.bytes)); @@ -298,8 +298,8 @@ struct SafeHeap : public Pass { // do the store auto* store = module->allocator.alloc<Store>(); *store = style; // basically the same as the template we are given! - store->ptr = builder.makeGetLocal(3, i32); - store->value = builder.makeGetLocal(2, style.valueType); + store->ptr = builder.makeLocalGet(3, i32); + store->value = builder.makeLocalGet(2, style.valueType); block->list.push_back(store); block->finalize(none); func->body = block; @@ -309,7 +309,7 @@ struct SafeHeap : public Pass { Expression* makeAlignCheck(Address align, Builder& builder, Index local) { return builder.makeIf( builder.makeBinary(AndInt32, - builder.makeGetLocal(local, i32), + builder.makeLocalGet(local, i32), builder.makeConst(Literal(int32_t(align - 1)))), builder.makeCall(alignfault, {}, none)); } @@ -322,15 +322,15 @@ struct SafeHeap : public Pass { builder.makeBinary( OrInt32, builder.makeBinary(upperOp, - builder.makeGetLocal(local, i32), + builder.makeLocalGet(local, i32), builder.makeConst(Literal(int32_t(upperBound)))), builder.makeBinary( GtUInt32, builder.makeBinary(AddInt32, - builder.makeGetLocal(local, i32), + builder.makeLocalGet(local, i32), builder.makeConst(Literal(int32_t(bytes)))), builder.makeLoad( - 4, false, 0, 4, builder.makeGetGlobal(dynamicTopPtr, i32), i32))), + 4, false, 0, 4, builder.makeGlobalGet(dynamicTopPtr, i32), i32))), builder.makeCall(segfault, {}, none)); } }; diff --git a/src/passes/SimplifyGlobals.cpp b/src/passes/SimplifyGlobals.cpp index 12c59fefc..87891352d 100644 --- a/src/passes/SimplifyGlobals.cpp +++ b/src/passes/SimplifyGlobals.cpp @@ -47,7 +47,7 @@ struct GlobalUseScanner : public WalkerPass<PostWalker<GlobalUseScanner>> { GlobalUseScanner* create() override { return new GlobalUseScanner(infos); } - void visitSetGlobal(SetGlobal* curr) { (*infos)[curr->name].written = true; } + void visitGlobalSet(GlobalSet* curr) { (*infos)[curr->name].written = true; } private: GlobalInfoMap* infos; @@ -65,7 +65,7 @@ struct GlobalUseModifier : public WalkerPass<PostWalker<GlobalUseModifier>> { return new GlobalUseModifier(copiedParentMap); } - void visitGetGlobal(GetGlobal* curr) { + void visitGlobalGet(GlobalGet* curr) { auto iter = copiedParentMap->find(curr->name); if (iter != copiedParentMap->end()) { curr->name = iter->second; @@ -112,7 +112,7 @@ struct SimplifyGlobals : public Pass { for (auto& global : module->globals) { auto child = global->name; if (!global->mutable_ && !global->imported()) { - if (auto* get = global->init->dynCast<GetGlobal>()) { + if (auto* get = global->init->dynCast<GlobalGet>()) { auto parent = get->name; if (!module->getGlobal(get->name)->mutable_) { copiedParentMap[child] = parent; diff --git a/src/passes/SimplifyLocals.cpp b/src/passes/SimplifyLocals.cpp index 71fd74f43..6b76faed3 100644 --- a/src/passes/SimplifyLocals.cpp +++ b/src/passes/SimplifyLocals.cpp @@ -117,7 +117,7 @@ struct SimplifyLocals bool firstCycle; // local => # of local.gets for it - GetLocalCounter getCounter; + LocalGetCounter getCounter; static void doNoteNonLinear(SimplifyLocals<allowTee, allowStructure, allowNesting>* self, @@ -216,14 +216,14 @@ struct SimplifyLocals } } - void optimizeGetLocal(GetLocal* curr) { + void optimizeLocalGet(LocalGet* curr) { auto found = sinkables.find(curr->index); if (found != sinkables.end()) { auto* set = (*found->second.item) - ->template cast<SetLocal>(); // the set we may be sinking + ->template cast<LocalSet>(); // the set we may be sinking bool oneUse = firstCycle || getCounter.num[curr->index] == 1; // the set's value may be a get (i.e., the set is a copy) - auto* get = set->value->template dynCast<GetLocal>(); + auto* get = set->value->template dynCast<LocalGet>(); // if nesting is not allowed, and this might cause nesting, check if the // sink would cause such a thing if (!allowNesting) { @@ -232,7 +232,7 @@ struct SimplifyLocals assert(expressionStack.size() >= 2); assert(expressionStack[expressionStack.size() - 1] == curr); auto* parent = expressionStack[expressionStack.size() - 2]; - bool parentIsSet = parent->template is<SetLocal>(); + bool parentIsSet = parent->template is<LocalSet>(); // if the parent of this get is a set, we can sink into the set's // value, it would not be nested. if (!parentIsSet) { @@ -258,7 +258,7 @@ struct SimplifyLocals assert(!set->isTee()); set->setTee(true); } - // reuse the getlocal that is dying + // reuse the local.get that is dying *found->second.item = curr; ExpressionManipulator::nop(curr); sinkables.erase(found); @@ -268,7 +268,7 @@ struct SimplifyLocals void visitDrop(Drop* curr) { // collapse drop-tee into set, which can occur if a get was sunk into a tee - auto* set = curr->value->dynCast<SetLocal>(); + auto* set = curr->value->dynCast<LocalSet>(); if (set) { assert(set->isTee()); set->setTee(false); @@ -355,28 +355,28 @@ struct SimplifyLocals Expression* original = *currp; - GetLocal originalGet; + LocalGet originalGet; - if (auto* get = (*currp)->dynCast<GetLocal>()) { - // Note: no visitor for GetLocal, so that we can handle it here. + if (auto* get = (*currp)->dynCast<LocalGet>()) { + // Note: no visitor for LocalGet, so that we can handle it here. originalGet = *get; original = &originalGet; - self->optimizeGetLocal(get); + self->optimizeLocalGet(get); } - // perform main SetLocal processing here, since we may be the result of - // replaceCurrent, i.e., no visitor for SetLocal, like GetLocal above. - auto* set = (*currp)->dynCast<SetLocal>(); + // perform main LocalSet processing here, since we may be the result of + // replaceCurrent, i.e., no visitor for LocalSet, like LocalGet above. + auto* set = (*currp)->dynCast<LocalSet>(); if (set) { // if we see a set that was already potentially-sinkable, then the // previous store is dead, leave just the value auto found = self->sinkables.find(set->index); if (found != self->sinkables.end()) { - auto* previous = (*found->second.item)->template cast<SetLocal>(); + auto* previous = (*found->second.item)->template cast<LocalSet>(); assert(!previous->isTee()); auto* previousValue = previous->value; - Drop* drop = ExpressionManipulator::convert<SetLocal, Drop>(previous); + Drop* drop = ExpressionManipulator::convert<LocalSet, Drop>(previous); drop->value = previousValue; drop->finalize(); self->sinkables.erase(found); @@ -401,7 +401,7 @@ struct SimplifyLocals } } - bool canSink(SetLocal* set) { + bool canSink(LocalSet* set) { // we can never move a tee if (set->isTee()) { return false; @@ -438,7 +438,7 @@ struct SimplifyLocals } Builder builder(*this->getModule()); auto** item = sinkables.at(goodIndex).item; - auto* set = (*item)->template cast<SetLocal>(); + auto* set = (*item)->template cast<LocalSet>(); block->list[block->list.size() - 1] = set->value; *item = builder.makeNop(); block->finalize(); @@ -506,23 +506,23 @@ struct SimplifyLocals // so we must check for that. for (size_t j = 0; j < breaks.size(); j++) { // move break local.set's value to the break - auto* breakSetLocalPointer = breaks[j].sinkables.at(sharedIndex).item; + auto* breakLocalSetPointer = breaks[j].sinkables.at(sharedIndex).item; auto* brp = breaks[j].brp; auto* br = (*brp)->template cast<Break>(); - auto* set = (*breakSetLocalPointer)->template cast<SetLocal>(); + auto* set = (*breakLocalSetPointer)->template cast<LocalSet>(); if (br->condition) { // TODO: optimize - FindAll<SetLocal> findAll(br->condition); + FindAll<LocalSet> findAll(br->condition); for (auto* otherSet : findAll.list) { if (otherSet == set) { // the set is indeed in the condition, so we can't just move it // but maybe there are no effects? see if, ignoring the set // itself, there is any risk Nop nop; - *breakSetLocalPointer = &nop; + *breakLocalSetPointer = &nop; EffectAnalyzer condition(this->getPassOptions(), br->condition); EffectAnalyzer value(this->getPassOptions(), set); - *breakSetLocalPointer = set; + *breakLocalSetPointer = set; if (condition.invalidates(value)) { // indeed, we can't do this, stop return; @@ -543,24 +543,24 @@ struct SimplifyLocals } // 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; + auto* blockLocalSetPointer = sinkables.at(sharedIndex).item; + auto* value = (*blockLocalSetPointer)->template cast<LocalSet>()->value; block->list[block->list.size() - 1] = value; block->type = value->type; - ExpressionManipulator::nop(*blockSetLocalPointer); + ExpressionManipulator::nop(*blockLocalSetPointer); for (size_t j = 0; j < breaks.size(); j++) { // move break local.set's value to the break - auto* breakSetLocalPointer = breaks[j].sinkables.at(sharedIndex).item; + auto* breakLocalSetPointer = breaks[j].sinkables.at(sharedIndex).item; auto* brp = breaks[j].brp; auto* br = (*brp)->template cast<Break>(); assert(!br->value); // if the break is conditional, then we must set the value here - if the // break is not reached, we must still have the new value in the local - auto* set = (*breakSetLocalPointer)->template cast<SetLocal>(); + auto* set = (*breakLocalSetPointer)->template cast<LocalSet>(); if (br->condition) { br->value = set; set->setTee(true); - *breakSetLocalPointer = + *breakLocalSetPointer = this->getModule()->allocator.template alloc<Nop>(); // in addition, as this is a conditional br that now has a value, it now // returns a value, so it must be dropped @@ -572,9 +572,9 @@ struct SimplifyLocals } } // finally, create a local.set on the block itself - auto* newSetLocal = - Builder(*this->getModule()).makeSetLocal(sharedIndex, block); - this->replaceCurrent(newSetLocal); + auto* newLocalSet = + Builder(*this->getModule()).makeLocalSet(sharedIndex, block); + this->replaceCurrent(newLocalSet); sinkables.clear(); anotherCycle = true; } @@ -657,7 +657,7 @@ struct SimplifyLocals if (iff->ifTrue->type != unreachable) { auto* ifTrueItem = ifTrue.at(goodIndex).item; ifTrueBlock->list[ifTrueBlock->list.size() - 1] = - (*ifTrueItem)->template cast<SetLocal>()->value; + (*ifTrueItem)->template cast<LocalSet>()->value; ExpressionManipulator::nop(*ifTrueItem); ifTrueBlock->finalize(); assert(ifTrueBlock->type != none); @@ -665,7 +665,7 @@ struct SimplifyLocals if (iff->ifFalse->type != unreachable) { auto* ifFalseItem = ifFalse.at(goodIndex).item; ifFalseBlock->list[ifFalseBlock->list.size() - 1] = - (*ifFalseItem)->template cast<SetLocal>()->value; + (*ifFalseItem)->template cast<LocalSet>()->value; ExpressionManipulator::nop(*ifFalseItem); ifFalseBlock->finalize(); assert(ifFalseBlock->type != none); @@ -673,9 +673,9 @@ struct SimplifyLocals iff->finalize(); // update type assert(iff->type != none); // finally, create a local.set on the iff itself - auto* newSetLocal = - Builder(*this->getModule()).makeSetLocal(goodIndex, iff); - *currp = newSetLocal; + auto* newLocalSet = + Builder(*this->getModule()).makeLocalSet(goodIndex, iff); + *currp = newLocalSet; anotherCycle = true; } @@ -722,13 +722,13 @@ struct SimplifyLocals // Update the ifTrue side. Builder builder(*this->getModule()); auto** item = sinkables.at(goodIndex).item; - auto* set = (*item)->template cast<SetLocal>(); + auto* set = (*item)->template cast<LocalSet>(); ifTrueBlock->list[ifTrueBlock->list.size() - 1] = set->value; *item = builder.makeNop(); ifTrueBlock->finalize(); assert(ifTrueBlock->type != none); // Update the ifFalse side. - iff->ifFalse = builder.makeGetLocal(set->index, set->value->type); + iff->ifFalse = builder.makeLocalGet(set->index, set->value->type); iff->finalize(); // update type // Update the get count. getCounter.num[set->index]++; @@ -895,7 +895,7 @@ struct SimplifyLocals // will inhibit us creating an if return value. struct EquivalentOptimizer : public LinearExecutionWalker<EquivalentOptimizer> { - std::vector<Index>* numGetLocals; + std::vector<Index>* numLocalGets; bool removeEquivalentSets; Module* module; @@ -911,13 +911,13 @@ struct SimplifyLocals self->equivalences.clear(); } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { // Remove trivial copies, even through a tee auto* value = curr->value; - while (auto* subSet = value->dynCast<SetLocal>()) { + while (auto* subSet = value->dynCast<LocalSet>()) { value = subSet->value; } - if (auto* get = value->dynCast<GetLocal>()) { + if (auto* get = value->dynCast<LocalGet>()) { if (equivalences.check(curr->index, get->index)) { // This is an unnecessary copy! if (removeEquivalentSets) { @@ -939,7 +939,7 @@ struct SimplifyLocals } } - void visitGetLocal(GetLocal* curr) { + void visitLocalGet(LocalGet* curr) { // Canonicalize gets: if some are equivalent, then we can pick more // then one, and other passes may benefit from having more uniformity. if (auto* set = equivalences.getEquivalents(curr->index)) { @@ -949,7 +949,7 @@ struct SimplifyLocals // get*, as we want to see what is best overall, treating this one as // to be decided upon. auto getNumGetsIgnoringCurr = [&](Index index) { - auto ret = (*numGetLocals)[index]; + auto ret = (*numLocalGets)[index]; if (index == curr->index) { assert(ret >= 1); ret--; @@ -969,9 +969,9 @@ struct SimplifyLocals if (best != curr->index && getNumGetsIgnoringCurr(best) > getNumGetsIgnoringCurr(curr->index)) { // Update the get counts. - (*numGetLocals)[best]++; - assert((*numGetLocals)[curr->index] >= 1); - (*numGetLocals)[curr->index]--; + (*numLocalGets)[best]++; + assert((*numLocalGets)[curr->index] >= 1); + (*numLocalGets)[curr->index]--; // Make the change. curr->index = best; anotherCycle = true; @@ -982,7 +982,7 @@ struct SimplifyLocals EquivalentOptimizer eqOpter; eqOpter.module = this->getModule(); - eqOpter.numGetLocals = &getCounter.num; + eqOpter.numLocalGets = &getCounter.num; eqOpter.removeEquivalentSets = allowStructure; eqOpter.walkFunction(func); diff --git a/src/passes/Souperify.cpp b/src/passes/Souperify.cpp index 6d7176e40..199db727e 100644 --- a/src/passes/Souperify.cpp +++ b/src/passes/Souperify.cpp @@ -79,9 +79,9 @@ struct UseFinder { } // There may be loops of sets with copies between them. - std::unordered_set<SetLocal*> seenSets; + std::unordered_set<LocalSet*> seenSets; - void addSetUses(SetLocal* set, + void addSetUses(LocalSet* set, Graph& graph, LocalGraph& localGraph, std::vector<Expression*>& ret) { @@ -261,7 +261,7 @@ struct Trace { break; } // Add the dependencies. - assert(!node->expr->is<GetLocal>()); + assert(!node->expr->is<LocalGet>()); for (Index i = 0; i < node->values.size(); i++) { add(node->getValue(i), depth); } diff --git a/src/passes/SpillPointers.cpp b/src/passes/SpillPointers.cpp index 6c194eb60..5c3d546ad 100644 --- a/src/passes/SpillPointers.cpp +++ b/src/passes/SpillPointers.cpp @@ -103,7 +103,7 @@ struct SpillPointers } // scan through the block, spilling around the calls // TODO: we can filter on pointerMap everywhere - LocalSet live = liveness.end; + SetOfLocals live = liveness.end; for (int i = int(actions.size()) - 1; i >= 0; i--) { auto& action = actions[i]; if (action.isGet()) { @@ -160,14 +160,14 @@ struct SpillPointers // move the operands into locals, as we must spill after they are executed auto handleOperand = [&](Expression*& operand) { auto temp = builder.addVar(func, operand->type); - auto* set = builder.makeSetLocal(temp, operand); + auto* set = builder.makeLocalSet(temp, operand); block->list.push_back(set); block->finalize(); if (actualPointers.count(&operand) > 0) { // this is something we track, and it's moving - update actualPointers[&operand] = &set->value; } - operand = builder.makeGetLocal(temp, operand->type); + operand = builder.makeLocalGet(temp, operand->type); }; if (call->is<Call>()) { for (auto*& operand : call->cast<Call>()->operands) { @@ -187,8 +187,8 @@ struct SpillPointers builder.makeStore(getTypeSize(ABI::PointerType), pointerMap[index], getTypeSize(ABI::PointerType), - builder.makeGetLocal(spillLocal, ABI::PointerType), - builder.makeGetLocal(index, ABI::PointerType), + builder.makeLocalGet(spillLocal, ABI::PointerType), + builder.makeLocalGet(index, ABI::PointerType), ABI::PointerType)); } // add the (modified) call diff --git a/src/passes/StackIR.cpp b/src/passes/StackIR.cpp index 1f182dbc3..d834655b9 100644 --- a/src/passes/StackIR.cpp +++ b/src/passes/StackIR.cpp @@ -132,7 +132,7 @@ private: localGraph.computeInfluences(); // We maintain a stack of relevant values. This contains: // * a null for each actual value that the value stack would have - // * an index of each SetLocal that *could* be on the value + // * an index of each LocalSet that *could* be on the value // stack at that location. const Index null = -1; std::vector<Index> values; @@ -188,7 +188,7 @@ private: // This is something we should handle, look into it. if (isConcreteType(inst->type)) { bool optimized = false; - if (auto* get = inst->origin->dynCast<GetLocal>()) { + if (auto* get = inst->origin->dynCast<LocalGet>()) { // This is a potential optimization opportunity! See if we // can reach the set. if (values.size() > 0) { @@ -199,7 +199,7 @@ private: if (index == null) { break; } - auto* set = insts[index]->origin->cast<SetLocal>(); + auto* set = insts[index]->origin->cast<LocalSet>(); if (set->index == get->index) { // This might be a proper set-get pair, where the set is // used by this get and nothing else, check that. @@ -238,7 +238,7 @@ private: // This is an actual regular value on the value stack. values.push_back(null); } - } else if (inst->origin->is<SetLocal>() && inst->type == none) { + } else if (inst->origin->is<LocalSet>() && inst->type == none) { // This set is potentially optimizable later, add to stack. values.push_back(i); } diff --git a/src/passes/TrapMode.cpp b/src/passes/TrapMode.cpp index b36427138..df900a125 100644 --- a/src/passes/TrapMode.cpp +++ b/src/passes/TrapMode.cpp @@ -103,7 +103,7 @@ Function* generateBinaryFunc(Module& wasm, Binary* curr) { bool isI64 = type == i64; Builder builder(wasm); Expression* result = builder.makeBinary( - op, builder.makeGetLocal(0, type), builder.makeGetLocal(1, type)); + op, builder.makeLocalGet(0, type), builder.makeLocalGet(1, type)); BinaryOp divSIntOp = isI64 ? DivSInt64 : DivSInt32; UnaryOp eqZOp = isI64 ? EqZInt64 : EqZInt32; Literal minLit = isI64 ? Literal(std::numeric_limits<int64_t>::min()) @@ -117,9 +117,9 @@ Function* generateBinaryFunc(Module& wasm, Binary* curr) { builder.makeBinary( AndInt32, builder.makeBinary( - eqOp, builder.makeGetLocal(0, type), builder.makeConst(minLit)), + eqOp, builder.makeLocalGet(0, type), builder.makeConst(minLit)), builder.makeBinary( - eqOp, builder.makeGetLocal(1, type), builder.makeConst(negLit))), + eqOp, builder.makeLocalGet(1, type), builder.makeConst(negLit))), builder.makeConst(zeroLit), result); } @@ -129,7 +129,7 @@ Function* generateBinaryFunc(Module& wasm, Binary* curr) { func->params.push_back(type); func->result = type; func->body = - builder.makeIf(builder.makeUnary(eqZOp, builder.makeGetLocal(1, type)), + builder.makeIf(builder.makeUnary(eqZOp, builder.makeLocalGet(1, type)), builder.makeConst(zeroLit), result); return func; @@ -190,25 +190,25 @@ Function* generateUnaryFunc(Module& wasm, Unary* curr) { func->name = getUnaryFuncName(curr); func->params.push_back(type); func->result = retType; - func->body = builder.makeUnary(truncOp, builder.makeGetLocal(0, type)); + func->body = builder.makeUnary(truncOp, builder.makeLocalGet(0, type)); // too small XXX this is different than asm.js, which does frem. here we // clamp, which is much simpler/faster, and similar to native builds func->body = builder.makeIf(builder.makeBinary(leOp, - builder.makeGetLocal(0, type), + builder.makeLocalGet(0, type), builder.makeConst(fMin)), builder.makeConst(iMin), func->body); // too big XXX see above func->body = builder.makeIf( builder.makeBinary( - geOp, builder.makeGetLocal(0, type), builder.makeConst(fMax)), + geOp, builder.makeLocalGet(0, type), builder.makeConst(fMax)), // NB: min here as well. anything out of range => to the min builder.makeConst(iMin), func->body); // nan func->body = builder.makeIf( builder.makeBinary( - neOp, builder.makeGetLocal(0, type), builder.makeGetLocal(0, type)), + neOp, builder.makeLocalGet(0, type), builder.makeLocalGet(0, type)), // NB: min here as well. anything invalid => to the min builder.makeConst(iMin), func->body); diff --git a/src/passes/Untee.cpp b/src/passes/Untee.cpp index 713962aeb..79c76b988 100644 --- a/src/passes/Untee.cpp +++ b/src/passes/Untee.cpp @@ -33,7 +33,7 @@ struct Untee : public WalkerPass<PostWalker<Untee>> { Pass* create() override { return new Untee; } - void visitSetLocal(SetLocal* curr) { + void visitLocalSet(LocalSet* curr) { if (curr->isTee()) { if (curr->value->type == unreachable) { // we don't reach the tee, just remove it @@ -42,7 +42,7 @@ struct Untee : public WalkerPass<PostWalker<Untee>> { // a normal tee. replace with set and get Builder builder(*getModule()); replaceCurrent(builder.makeSequence( - curr, builder.makeGetLocal(curr->index, curr->value->type))); + curr, builder.makeLocalGet(curr->index, curr->value->type))); curr->setTee(false); } } diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index 0e01c0370..82d904701 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -84,10 +84,10 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> { case Expression::Id::SwitchId: case Expression::Id::CallId: case Expression::Id::CallIndirectId: - case Expression::Id::SetLocalId: + case Expression::Id::LocalSetId: case Expression::Id::StoreId: case Expression::Id::ReturnId: - case Expression::Id::SetGlobalId: + case Expression::Id::GlobalSetId: case Expression::Id::HostId: case Expression::Id::UnreachableId: return curr; // always needed @@ -106,8 +106,8 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> { return curr; } case Expression::Id::ConstId: - case Expression::Id::GetLocalId: - case Expression::Id::GetGlobalId: { + case Expression::Id::LocalGetId: + case Expression::Id::GlobalGetId: { if (!resultUsed) { return nullptr; } @@ -344,7 +344,7 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> { return; } // a drop of a tee is a set - if (auto* set = curr->value->dynCast<SetLocal>()) { + if (auto* set = curr->value->dynCast<LocalSet>()) { assert(set->isTee()); set->setTee(false); replaceCurrent(set); diff --git a/src/tools/asm2wasm.cpp b/src/tools/asm2wasm.cpp index 0077b9448..cbd72abe0 100644 --- a/src/tools/asm2wasm.cpp +++ b/src/tools/asm2wasm.cpp @@ -237,7 +237,7 @@ int main(int argc, const char* argv[]) { Expression* init; const auto& memBase = options.extra.find("mem base"); if (memBase == options.extra.end()) { - init = Builder(wasm).makeGetGlobal(MEMORY_BASE, i32); + init = Builder(wasm).makeGlobalGet(MEMORY_BASE, i32); } else { init = Builder(wasm).makeConst( Literal(int32_t(atoi(memBase->second.c_str())))); diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index 965cb74fa..f7dd20e76 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -350,22 +350,22 @@ private: // } std::vector<Expression*> contents; contents.push_back( - builder.makeSetLocal(0, builder.makeConst(Literal(uint32_t(5381))))); + builder.makeLocalSet(0, builder.makeConst(Literal(uint32_t(5381))))); for (Index i = 0; i < USABLE_MEMORY; i++) { - contents.push_back(builder.makeSetLocal( + contents.push_back(builder.makeLocalSet( 0, builder.makeBinary( XorInt32, builder.makeBinary( AddInt32, builder.makeBinary(ShlInt32, - builder.makeGetLocal(0, i32), + builder.makeLocalGet(0, i32), builder.makeConst(Literal(uint32_t(5)))), - builder.makeGetLocal(0, i32)), + builder.makeLocalGet(0, i32)), builder.makeLoad( 1, false, i, 1, builder.makeConst(Literal(uint32_t(0))), i32)))); } - contents.push_back(builder.makeGetLocal(0, i32)); + contents.push_back(builder.makeLocalGet(0, i32)); auto* body = builder.makeBlock(contents); auto* hasher = wasm.addFunction(builder.makeFunction( "hashMemory", std::vector<Type>{}, i32, {i32}, body)); @@ -416,7 +416,7 @@ private: auto* func = new Function; func->name = "hangLimitInitializer"; func->result = none; - func->body = builder.makeSetGlobal( + func->body = builder.makeGlobalSet( glob->name, builder.makeConst(Literal(int32_t(HANG_LIMIT)))); wasm.addFunction(func); @@ -445,12 +445,12 @@ private: return builder.makeSequence( builder.makeIf( builder.makeUnary(UnaryOp::EqZInt32, - builder.makeGetGlobal(HANG_LIMIT_GLOBAL, i32)), + builder.makeGlobalGet(HANG_LIMIT_GLOBAL, i32)), makeTrivial(unreachable)), - builder.makeSetGlobal( + builder.makeGlobalSet( HANG_LIMIT_GLOBAL, builder.makeBinary(BinaryOp::SubInt32, - builder.makeGetGlobal(HANG_LIMIT_GLOBAL, i32), + builder.makeGlobalGet(HANG_LIMIT_GLOBAL, i32), builder.makeConst(Literal(int32_t(1)))))); } @@ -462,8 +462,8 @@ private: func->result = type; func->body = builder.makeIf( builder.makeBinary( - op, builder.makeGetLocal(0, type), builder.makeGetLocal(0, type)), - builder.makeGetLocal(0, type), + op, builder.makeLocalGet(0, type), builder.makeLocalGet(0, type)), + builder.makeLocalGet(0, type), builder.makeConst(literal)); wasm.addFunction(func); }; @@ -804,13 +804,13 @@ private: if (oneIn(2)) { return makeConst(type); } else { - return makeGetLocal(type); + return makeLocalGet(type); } } else if (type == none) { if (oneIn(2)) { return makeNop(type); } else { - return makeSetLocal(type); + return makeLocalSet(type); } } assert(type == unreachable); @@ -845,10 +845,10 @@ private: return makeConst(type); } if (choice < 30) { - return makeSetLocal(type); + return makeLocalSet(type); } if (choice < 50) { - return makeGetLocal(type); + return makeLocalGet(type); } if (choice < 60) { return makeBlock(type); @@ -871,14 +871,14 @@ private: &Self::makeBreak, &Self::makeCall, &Self::makeCallIndirect, - &Self::makeGetLocal, - &Self::makeSetLocal, + &Self::makeLocalGet, + &Self::makeLocalSet, &Self::makeLoad, &Self::makeConst, &Self::makeUnary, &Self::makeBinary, &Self::makeSelect, - &Self::makeGetGlobal) + &Self::makeGlobalGet) .add(FeatureSet::SIMD, &Self::makeSIMD); if (type == i32 || type == i64) { options.add(FeatureSet::Atomics, &Self::makeAtomic); @@ -897,7 +897,7 @@ private: } choice = upTo(100); if (choice < 50) { - return makeSetLocal(none); + return makeLocalSet(none); } if (choice < 60) { return makeBlock(none); @@ -920,11 +920,11 @@ private: &Self::makeBreak, &Self::makeCall, &Self::makeCallIndirect, - &Self::makeSetLocal, + &Self::makeLocalSet, &Self::makeStore, &Self::makeDrop, &Self::makeNop, - &Self::makeSetGlobal) + &Self::makeGlobalSet) .add(FeatureSet::BulkMemory, &Self::makeBulkMemory); return (this->*pick(options))(none); } @@ -944,7 +944,7 @@ private: case 5: return makeCallIndirect(unreachable); case 6: - return makeSetLocal(unreachable); + return makeLocalSet(unreachable); case 7: return makeStore(unreachable); case 8: @@ -969,7 +969,7 @@ private: Expression* makeTrivial(Type type) { if (isConcreteType(type)) { if (oneIn(2)) { - return makeGetLocal(type); + return makeLocalGet(type); } else { return makeConst(type); } @@ -1231,15 +1231,15 @@ private: return builder.makeCallIndirect(func->type, target, args, func->result); } - Expression* makeGetLocal(Type type) { + Expression* makeLocalGet(Type type) { auto& locals = typeLocals[type]; if (locals.empty()) { return makeConst(type); } - return builder.makeGetLocal(vectorPick(locals), type); + return builder.makeLocalGet(vectorPick(locals), type); } - Expression* makeSetLocal(Type type) { + Expression* makeLocalSet(Type type) { bool tee = type != none; Type valueType; if (tee) { @@ -1253,21 +1253,21 @@ private: } auto* value = make(valueType); if (tee) { - return builder.makeTeeLocal(vectorPick(locals), value); + return builder.makeLocalTee(vectorPick(locals), value); } else { - return builder.makeSetLocal(vectorPick(locals), value); + return builder.makeLocalSet(vectorPick(locals), value); } } - Expression* makeGetGlobal(Type type) { + Expression* makeGlobalGet(Type type) { auto& globals = globalsByType[type]; if (globals.empty()) { return makeConst(type); } - return builder.makeGetGlobal(vectorPick(globals), type); + return builder.makeGlobalGet(vectorPick(globals), type); } - Expression* makeSetGlobal(Type type) { + Expression* makeGlobalSet(Type type) { assert(type == none); type = getConcreteType(); auto& globals = globalsByType[type]; @@ -1275,7 +1275,7 @@ private: return makeTrivial(none); } auto* value = make(type); - return builder.makeSetGlobal(vectorPick(globals), value); + return builder.makeGlobalSet(vectorPick(globals), value); } Expression* makePointer() { diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp index 293c675d1..af4d0d0b2 100644 --- a/src/tools/wasm-ctor-eval.cpp +++ b/src/tools/wasm-ctor-eval.cpp @@ -133,7 +133,7 @@ public: ModuleUtils::iterDefinedGlobals(wasm, [&](Global* global) { if (!global->init->is<Const>()) { // some constants are ok to use - if (auto* get = global->init->dynCast<GetGlobal>()) { + if (auto* get = global->init->dynCast<GlobalGet>()) { auto name = get->name; auto* import = wasm.getGlobal(name); if (import->module == Name(ENV) && @@ -228,7 +228,7 @@ struct CtorEvalExternalInterface : EvallingModuleInstance::ExternalInterface { // offset 0. if (auto* c = segment.offset->dynCast<Const>()) { start = c->value.getInteger(); - } else if (segment.offset->is<GetGlobal>()) { + } else if (segment.offset->is<GlobalGet>()) { start = 0; } else { WASM_UNREACHABLE(); // wasm spec only allows const and global.get there diff --git a/src/tools/wasm-metadce.cpp b/src/tools/wasm-metadce.cpp index 35fbc6357..c04286f59 100644 --- a/src/tools/wasm-metadce.cpp +++ b/src/tools/wasm-metadce.cpp @@ -154,8 +154,8 @@ struct MetaDCEGraph { InitScanner(MetaDCEGraph* parent, Name parentDceName) : parent(parent), parentDceName(parentDceName) {} - void visitGetGlobal(GetGlobal* curr) { handleGlobal(curr->name); } - void visitSetGlobal(SetGlobal* curr) { handleGlobal(curr->name); } + void visitGlobalGet(GlobalGet* curr) { handleGlobal(curr->name); } + void visitGlobalSet(GlobalSet* curr) { handleGlobal(curr->name); } private: MetaDCEGraph* parent; @@ -223,8 +223,8 @@ struct MetaDCEGraph { ->importIdToDCENode[parent->getFunctionImportId(curr->target)]); } } - void visitGetGlobal(GetGlobal* curr) { handleGlobal(curr->name); } - void visitSetGlobal(SetGlobal* curr) { handleGlobal(curr->name); } + void visitGlobalGet(GlobalGet* curr) { handleGlobal(curr->name); } + void visitGlobalSet(GlobalSet* curr) { handleGlobal(curr->name); } private: MetaDCEGraph* parent; diff --git a/src/wasm-binary.h b/src/wasm-binary.h index fe1b5ddaf..ce3144715 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -421,7 +421,7 @@ enum ASTNodes { End = 0x0b, Br = 0x0c, BrIf = 0x0d, - TableSwitch = 0x0e, // TODO: Rename to BrTable + BrTable = 0x0e, Return = 0x0f, CallFunction = 0x10, @@ -430,11 +430,11 @@ enum ASTNodes { Drop = 0x1a, Select = 0x1b, - GetLocal = 0x20, - SetLocal = 0x21, - TeeLocal = 0x22, - GetGlobal = 0x23, - SetGlobal = 0x24, + LocalGet = 0x20, + LocalSet = 0x21, + LocalTee = 0x22, + GlobalGet = 0x23, + GlobalSet = 0x24, I32LoadMem = 0x28, I64LoadMem = 0x29, @@ -463,8 +463,8 @@ enum ASTNodes { I64StoreMem16 = 0x3d, I64StoreMem32 = 0x3e, - CurrentMemory = 0x3f, - GrowMemory = 0x40, + MemorySize = 0x3f, + MemoryGrow = 0x40, I32Const = 0x41, I64Const = 0x42, @@ -574,13 +574,13 @@ enum ASTNodes { F64Max = 0xa5, F64CopySign = 0xa6, - I32ConvertI64 = 0xa7, // TODO: rename to I32WrapI64 + I32WrapI64 = 0xa7, I32STruncF32 = 0xa8, I32UTruncF32 = 0xa9, I32STruncF64 = 0xaa, I32UTruncF64 = 0xab, - I64STruncI32 = 0xac, // TODO: rename to I64SExtendI32 - I64UTruncI32 = 0xad, // TODO: likewise + I64SExtendI32 = 0xac, + I64UExtendI32 = 0xad, I64STruncF32 = 0xae, I64UTruncF32 = 0xaf, I64STruncF64 = 0xb0, @@ -589,12 +589,12 @@ enum ASTNodes { F32UConvertI32 = 0xb3, F32SConvertI64 = 0xb4, F32UConvertI64 = 0xb5, - F32ConvertF64 = 0xb6, // TODO: rename to F32DemoteI64 + F32DemoteI64 = 0xb6, F64SConvertI32 = 0xb7, F64UConvertI32 = 0xb8, F64SConvertI64 = 0xb9, F64UConvertI64 = 0xba, - F64ConvertF32 = 0xbb, // TODO: rename to F64PromoteF32 + F64PromoteF32 = 0xbb, I32ReinterpretF32 = 0xbc, I64ReinterpretF64 = 0xbd, @@ -1192,10 +1192,10 @@ public: void visitCall(Call* curr); void visitCallIndirect(CallIndirect* curr); - void visitGetLocal(GetLocal* curr); - void visitSetLocal(SetLocal* curr, uint8_t code); - void visitGetGlobal(GetGlobal* curr); - void visitSetGlobal(SetGlobal* curr); + void visitLocalGet(LocalGet* curr); + void visitLocalSet(LocalSet* curr, uint8_t code); + void visitGlobalGet(GlobalGet* curr); + void visitGlobalSet(GlobalSet* curr); void readMemoryAccess(Address& alignment, Address& offset); bool maybeVisitLoad(Expression*& out, uint8_t code, bool isAtomic); bool maybeVisitStore(Expression*& out, uint8_t code, bool isAtomic); diff --git a/src/wasm-builder.h b/src/wasm-builder.h index 505074fd9..0b7326b6e 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -225,34 +225,34 @@ public: return call; } // FunctionType - GetLocal* makeGetLocal(Index index, Type type) { - auto* ret = allocator.alloc<GetLocal>(); + LocalGet* makeLocalGet(Index index, Type type) { + auto* ret = allocator.alloc<LocalGet>(); ret->index = index; ret->type = type; return ret; } - SetLocal* makeSetLocal(Index index, Expression* value) { - auto* ret = allocator.alloc<SetLocal>(); + LocalSet* makeLocalSet(Index index, Expression* value) { + auto* ret = allocator.alloc<LocalSet>(); ret->index = index; ret->value = value; ret->finalize(); return ret; } - SetLocal* makeTeeLocal(Index index, Expression* value) { - auto* ret = allocator.alloc<SetLocal>(); + LocalSet* makeLocalTee(Index index, Expression* value) { + auto* ret = allocator.alloc<LocalSet>(); ret->index = index; ret->value = value; ret->setTee(true); return ret; } - GetGlobal* makeGetGlobal(Name name, Type type) { - auto* ret = allocator.alloc<GetGlobal>(); + GlobalGet* makeGlobalGet(Name name, Type type) { + auto* ret = allocator.alloc<GlobalGet>(); ret->name = name; ret->type = type; return ret; } - SetGlobal* makeSetGlobal(Name name, Expression* value) { - auto* ret = allocator.alloc<SetGlobal>(); + GlobalSet* makeGlobalSet(Name name, Expression* value) { + auto* ret = allocator.alloc<GlobalSet>(); ret->name = name; ret->value = value; ret->finalize(); diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 1de216800..85a50163a 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -1022,9 +1022,9 @@ public: Flow visitCall(Call*) { WASM_UNREACHABLE(); } Flow visitCallIndirect(CallIndirect*) { WASM_UNREACHABLE(); } - Flow visitGetLocal(GetLocal*) { WASM_UNREACHABLE(); } - Flow visitSetLocal(SetLocal*) { WASM_UNREACHABLE(); } - Flow visitSetGlobal(SetGlobal*) { WASM_UNREACHABLE(); } + Flow visitLocalGet(LocalGet*) { WASM_UNREACHABLE(); } + Flow visitLocalSet(LocalSet*) { WASM_UNREACHABLE(); } + Flow visitGlobalSet(GlobalSet*) { WASM_UNREACHABLE(); } Flow visitLoad(Load* curr) { WASM_UNREACHABLE(); } Flow visitStore(Store* curr) { WASM_UNREACHABLE(); } Flow visitHost(Host* curr) { WASM_UNREACHABLE(); } @@ -1049,7 +1049,7 @@ class ConstantExpressionRunner public: ConstantExpressionRunner(GlobalManager& globals) : globals(globals) {} - Flow visitGetGlobal(GetGlobal* curr) { return Flow(globals[curr->name]); } + Flow visitGlobalGet(GlobalGet* curr) { return Flow(globals[curr->name]); } }; // @@ -1432,15 +1432,15 @@ private: index, arguments, curr->type, *instance.self()); } - Flow visitGetLocal(GetLocal* curr) { - NOTE_ENTER("GetLocal"); + Flow visitLocalGet(LocalGet* curr) { + NOTE_ENTER("LocalGet"); auto index = curr->index; NOTE_EVAL1(index); NOTE_EVAL1(scope.locals[index]); return scope.locals[index]; } - Flow visitSetLocal(SetLocal* curr) { - NOTE_ENTER("SetLocal"); + Flow visitLocalSet(LocalSet* curr) { + NOTE_ENTER("LocalSet"); auto index = curr->index; Flow flow = this->visit(curr->value); if (flow.breaking()) { @@ -1453,16 +1453,16 @@ private: return curr->isTee() ? flow : Flow(); } - Flow visitGetGlobal(GetGlobal* curr) { - NOTE_ENTER("GetGlobal"); + Flow visitGlobalGet(GlobalGet* curr) { + NOTE_ENTER("GlobalGet"); auto name = curr->name; NOTE_EVAL1(name); assert(instance.globals.find(name) != instance.globals.end()); NOTE_EVAL1(instance.globals[name]); return instance.globals[name]; } - Flow visitSetGlobal(SetGlobal* curr) { - NOTE_ENTER("SetGlobal"); + Flow visitGlobalSet(GlobalSet* curr) { + NOTE_ENTER("GlobalSet"); auto name = curr->name; Flow flow = this->visit(curr->value); if (flow.breaking()) { @@ -1616,9 +1616,9 @@ private: Flow visitHost(Host* curr) { NOTE_ENTER("Host"); switch (curr->op) { - case CurrentMemory: + case MemorySize: return Literal(int32_t(instance.memorySize)); - case GrowMemory: { + case MemoryGrow: { auto fail = Literal(int32_t(-1)); Flow flow = this->visit(curr->operands[0]); if (flow.breaking()) { diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index c37b1b27d..2e84b2245 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -175,11 +175,11 @@ private: Expression* makeDrop(Element& s); Expression* makeHost(Element& s, HostOp op); Index getLocalIndex(Element& s); - Expression* makeGetLocal(Element& s); - Expression* makeTeeLocal(Element& s); - Expression* makeSetLocal(Element& s); - Expression* makeGetGlobal(Element& s); - Expression* makeSetGlobal(Element& s); + Expression* makeLocalGet(Element& s); + Expression* makeLocalTee(Element& s); + Expression* makeLocalSet(Element& s); + Expression* makeGlobalGet(Element& s); + Expression* makeGlobalSet(Element& s); Expression* makeBlock(Element& s); Expression* makeThenOrElse(Element& s); Expression* makeConst(Element& s, Type type); diff --git a/src/wasm-stack.h b/src/wasm-stack.h index 8b02574eb..9a71681a2 100644 --- a/src/wasm-stack.h +++ b/src/wasm-stack.h @@ -131,10 +131,10 @@ public: void visitSwitch(Switch* curr); void visitCall(Call* curr); void visitCallIndirect(CallIndirect* curr); - void visitGetLocal(GetLocal* curr); - void visitSetLocal(SetLocal* curr); - void visitGetGlobal(GetGlobal* curr); - void visitSetGlobal(SetGlobal* curr); + void visitLocalGet(LocalGet* curr); + void visitLocalSet(LocalSet* curr); + void visitGlobalGet(GlobalGet* curr); + void visitGlobalSet(GlobalSet* curr); void visitLoad(Load* curr); void visitStore(Store* curr); void visitAtomicRMW(AtomicRMW* curr); @@ -611,7 +611,7 @@ void StackWriter<Mode, Parent>::visitSwitch(Switch* curr) { if (justAddToStack(curr)) { return; } - o << int8_t(BinaryConsts::TableSwitch) << U32LEB(curr->targets.size()); + o << int8_t(BinaryConsts::BrTable) << U32LEB(curr->targets.size()); for (auto target : curr->targets) { o << U32LEB(getBreakIndex(target)); } @@ -650,18 +650,18 @@ void StackWriter<Mode, Parent>::visitCallIndirect(CallIndirect* curr) { } template<StackWriterMode Mode, typename Parent> -void StackWriter<Mode, Parent>::visitGetLocal(GetLocal* curr) { +void StackWriter<Mode, Parent>::visitLocalGet(LocalGet* curr) { if (justAddToStack(curr)) { return; } - o << int8_t(BinaryConsts::GetLocal) << U32LEB(mappedLocals[curr->index]); + o << int8_t(BinaryConsts::LocalGet) << U32LEB(mappedLocals[curr->index]); } template<StackWriterMode Mode, typename Parent> -void StackWriter<Mode, Parent>::visitSetLocal(SetLocal* curr) { +void StackWriter<Mode, Parent>::visitLocalSet(LocalSet* curr) { visitChild(curr->value); if (!justAddToStack(curr)) { - o << int8_t(curr->isTee() ? BinaryConsts::TeeLocal : BinaryConsts::SetLocal) + o << int8_t(curr->isTee() ? BinaryConsts::LocalTee : BinaryConsts::LocalSet) << U32LEB(mappedLocals[curr->index]); } if (curr->type == unreachable) { @@ -670,21 +670,21 @@ void StackWriter<Mode, Parent>::visitSetLocal(SetLocal* curr) { } template<StackWriterMode Mode, typename Parent> -void StackWriter<Mode, Parent>::visitGetGlobal(GetGlobal* curr) { +void StackWriter<Mode, Parent>::visitGlobalGet(GlobalGet* curr) { if (justAddToStack(curr)) { return; } - o << int8_t(BinaryConsts::GetGlobal) + o << int8_t(BinaryConsts::GlobalGet) << U32LEB(parent.getGlobalIndex(curr->name)); } template<StackWriterMode Mode, typename Parent> -void StackWriter<Mode, Parent>::visitSetGlobal(SetGlobal* curr) { +void StackWriter<Mode, Parent>::visitGlobalSet(GlobalSet* curr) { visitChild(curr->value); if (justAddToStack(curr)) { return; } - o << int8_t(BinaryConsts::SetGlobal) + o << int8_t(BinaryConsts::GlobalSet) << U32LEB(parent.getGlobalIndex(curr->name)); } @@ -1416,13 +1416,13 @@ void StackWriter<Mode, Parent>::visitUnary(Unary* curr) { o << int8_t(BinaryConsts::F64Sqrt); break; case ExtendSInt32: - o << int8_t(BinaryConsts::I64STruncI32); + o << int8_t(BinaryConsts::I64SExtendI32); break; case ExtendUInt32: - o << int8_t(BinaryConsts::I64UTruncI32); + o << int8_t(BinaryConsts::I64UExtendI32); break; case WrapInt64: - o << int8_t(BinaryConsts::I32ConvertI64); + o << int8_t(BinaryConsts::I32WrapI64); break; case TruncUFloat32ToInt32: o << int8_t(BinaryConsts::I32UTruncF32); @@ -1473,10 +1473,10 @@ void StackWriter<Mode, Parent>::visitUnary(Unary* curr) { o << int8_t(BinaryConsts::F64SConvertI64); break; case DemoteFloat64: - o << int8_t(BinaryConsts::F32ConvertF64); + o << int8_t(BinaryConsts::F32DemoteI64); break; case PromoteFloat32: - o << int8_t(BinaryConsts::F64ConvertF32); + o << int8_t(BinaryConsts::F64PromoteF32); break; case ReinterpretFloat32: o << int8_t(BinaryConsts::I32ReinterpretF32); @@ -2174,10 +2174,10 @@ void StackWriter<Mode, Parent>::visitReturn(Return* curr) { template<StackWriterMode Mode, typename Parent> void StackWriter<Mode, Parent>::visitHost(Host* curr) { switch (curr->op) { - case CurrentMemory: { + case MemorySize: { break; } - case GrowMemory: { + case MemoryGrow: { visitChild(curr->operands[0]); break; } @@ -2186,12 +2186,12 @@ void StackWriter<Mode, Parent>::visitHost(Host* curr) { return; } switch (curr->op) { - case CurrentMemory: { - o << int8_t(BinaryConsts::CurrentMemory); + case MemorySize: { + o << int8_t(BinaryConsts::MemorySize); break; } - case GrowMemory: { - o << int8_t(BinaryConsts::GrowMemory); + case MemoryGrow: { + o << int8_t(BinaryConsts::MemoryGrow); break; } } diff --git a/src/wasm-traversal.h b/src/wasm-traversal.h index 54fbef439..73f57a538 100644 --- a/src/wasm-traversal.h +++ b/src/wasm-traversal.h @@ -44,10 +44,10 @@ template<typename SubType, typename ReturnType = void> struct Visitor { ReturnType visitSwitch(Switch* curr) { return ReturnType(); } ReturnType visitCall(Call* curr) { return ReturnType(); } ReturnType visitCallIndirect(CallIndirect* curr) { return ReturnType(); } - ReturnType visitGetLocal(GetLocal* curr) { return ReturnType(); } - ReturnType visitSetLocal(SetLocal* curr) { return ReturnType(); } - ReturnType visitGetGlobal(GetGlobal* curr) { return ReturnType(); } - ReturnType visitSetGlobal(SetGlobal* curr) { return ReturnType(); } + ReturnType visitLocalGet(LocalGet* curr) { return ReturnType(); } + ReturnType visitLocalSet(LocalSet* curr) { return ReturnType(); } + ReturnType visitGlobalGet(GlobalGet* curr) { return ReturnType(); } + ReturnType visitGlobalSet(GlobalSet* curr) { return ReturnType(); } ReturnType visitLoad(Load* curr) { return ReturnType(); } ReturnType visitStore(Store* curr) { return ReturnType(); } ReturnType visitAtomicRMW(AtomicRMW* curr) { return ReturnType(); } @@ -103,14 +103,14 @@ template<typename SubType, typename ReturnType = void> struct Visitor { DELEGATE(Call); case Expression::Id::CallIndirectId: DELEGATE(CallIndirect); - case Expression::Id::GetLocalId: - DELEGATE(GetLocal); - case Expression::Id::SetLocalId: - DELEGATE(SetLocal); - case Expression::Id::GetGlobalId: - DELEGATE(GetGlobal); - case Expression::Id::SetGlobalId: - DELEGATE(SetGlobal); + case Expression::Id::LocalGetId: + DELEGATE(LocalGet); + case Expression::Id::LocalSetId: + DELEGATE(LocalSet); + case Expression::Id::GlobalGetId: + DELEGATE(GlobalGet); + case Expression::Id::GlobalSetId: + DELEGATE(GlobalSet); case Expression::Id::LoadId: DELEGATE(Load); case Expression::Id::StoreId: @@ -189,10 +189,10 @@ struct OverriddenVisitor { UNIMPLEMENTED(Switch); UNIMPLEMENTED(Call); UNIMPLEMENTED(CallIndirect); - UNIMPLEMENTED(GetLocal); - UNIMPLEMENTED(SetLocal); - UNIMPLEMENTED(GetGlobal); - UNIMPLEMENTED(SetGlobal); + UNIMPLEMENTED(LocalGet); + UNIMPLEMENTED(LocalSet); + UNIMPLEMENTED(GlobalGet); + UNIMPLEMENTED(GlobalSet); UNIMPLEMENTED(Load); UNIMPLEMENTED(Store); UNIMPLEMENTED(AtomicRMW); @@ -249,14 +249,14 @@ struct OverriddenVisitor { DELEGATE(Call); case Expression::Id::CallIndirectId: DELEGATE(CallIndirect); - case Expression::Id::GetLocalId: - DELEGATE(GetLocal); - case Expression::Id::SetLocalId: - DELEGATE(SetLocal); - case Expression::Id::GetGlobalId: - DELEGATE(GetGlobal); - case Expression::Id::SetGlobalId: - DELEGATE(SetGlobal); + case Expression::Id::LocalGetId: + DELEGATE(LocalGet); + case Expression::Id::LocalSetId: + DELEGATE(LocalSet); + case Expression::Id::GlobalGetId: + DELEGATE(GlobalGet); + case Expression::Id::GlobalSetId: + DELEGATE(GlobalSet); case Expression::Id::LoadId: DELEGATE(Load); case Expression::Id::StoreId: @@ -344,16 +344,16 @@ struct UnifiedExpressionVisitor : public Visitor<SubType, ReturnType> { ReturnType visitCallIndirect(CallIndirect* curr) { return static_cast<SubType*>(this)->visitExpression(curr); } - ReturnType visitGetLocal(GetLocal* curr) { + ReturnType visitLocalGet(LocalGet* curr) { return static_cast<SubType*>(this)->visitExpression(curr); } - ReturnType visitSetLocal(SetLocal* curr) { + ReturnType visitLocalSet(LocalSet* curr) { return static_cast<SubType*>(this)->visitExpression(curr); } - ReturnType visitGetGlobal(GetGlobal* curr) { + ReturnType visitGlobalGet(GlobalGet* curr) { return static_cast<SubType*>(this)->visitExpression(curr); } - ReturnType visitSetGlobal(SetGlobal* curr) { + ReturnType visitGlobalSet(GlobalSet* curr) { return static_cast<SubType*>(this)->visitExpression(curr); } ReturnType visitLoad(Load* curr) { @@ -614,17 +614,17 @@ struct Walker : public VisitorType { static void doVisitCallIndirect(SubType* self, Expression** currp) { self->visitCallIndirect((*currp)->cast<CallIndirect>()); } - static void doVisitGetLocal(SubType* self, Expression** currp) { - self->visitGetLocal((*currp)->cast<GetLocal>()); + static void doVisitLocalGet(SubType* self, Expression** currp) { + self->visitLocalGet((*currp)->cast<LocalGet>()); } - static void doVisitSetLocal(SubType* self, Expression** currp) { - self->visitSetLocal((*currp)->cast<SetLocal>()); + static void doVisitLocalSet(SubType* self, Expression** currp) { + self->visitLocalSet((*currp)->cast<LocalSet>()); } - static void doVisitGetGlobal(SubType* self, Expression** currp) { - self->visitGetGlobal((*currp)->cast<GetGlobal>()); + static void doVisitGlobalGet(SubType* self, Expression** currp) { + self->visitGlobalGet((*currp)->cast<GlobalGet>()); } - static void doVisitSetGlobal(SubType* self, Expression** currp) { - self->visitSetGlobal((*currp)->cast<SetGlobal>()); + static void doVisitGlobalSet(SubType* self, Expression** currp) { + self->visitGlobalSet((*currp)->cast<GlobalSet>()); } static void doVisitLoad(SubType* self, Expression** currp) { self->visitLoad((*currp)->cast<Load>()); @@ -772,23 +772,23 @@ struct PostWalker : public Walker<SubType, VisitorType> { } break; } - case Expression::Id::GetLocalId: { + case Expression::Id::LocalGetId: { // TODO: optimize leaves with a direct call? - self->pushTask(SubType::doVisitGetLocal, currp); + self->pushTask(SubType::doVisitLocalGet, currp); break; } - case Expression::Id::SetLocalId: { - self->pushTask(SubType::doVisitSetLocal, currp); - self->pushTask(SubType::scan, &curr->cast<SetLocal>()->value); + case Expression::Id::LocalSetId: { + self->pushTask(SubType::doVisitLocalSet, currp); + self->pushTask(SubType::scan, &curr->cast<LocalSet>()->value); break; } - case Expression::Id::GetGlobalId: { - self->pushTask(SubType::doVisitGetGlobal, currp); + case Expression::Id::GlobalGetId: { + self->pushTask(SubType::doVisitGlobalGet, currp); break; } - case Expression::Id::SetGlobalId: { - self->pushTask(SubType::doVisitSetGlobal, currp); - self->pushTask(SubType::scan, &curr->cast<SetGlobal>()->value); + case Expression::Id::GlobalSetId: { + self->pushTask(SubType::doVisitGlobalSet, currp); + self->pushTask(SubType::scan, &curr->cast<GlobalSet>()->value); break; } case Expression::Id::LoadId: { diff --git a/src/wasm.h b/src/wasm.h index a6b6b83d1..10f00f0b7 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -378,7 +378,7 @@ enum BinaryOp { InvalidBinary }; -enum HostOp { CurrentMemory, GrowMemory }; +enum HostOp { MemorySize, MemoryGrow }; enum AtomicRMWOp { Add, Sub, And, Or, Xor, Xchg }; @@ -449,10 +449,10 @@ public: SwitchId, CallId, CallIndirectId, - GetLocalId, - SetLocalId, - GetGlobalId, - SetGlobalId, + LocalGetId, + LocalSetId, + GlobalGetId, + GlobalSetId, LoadId, StoreId, ConstId, @@ -648,18 +648,18 @@ public: void finalize(); }; -class GetLocal : public SpecificExpression<Expression::GetLocalId> { +class LocalGet : public SpecificExpression<Expression::LocalGetId> { public: - GetLocal() = default; - GetLocal(MixedArena& allocator) {} + LocalGet() = default; + LocalGet(MixedArena& allocator) {} Index index; }; -class SetLocal : public SpecificExpression<Expression::SetLocalId> { +class LocalSet : public SpecificExpression<Expression::LocalSetId> { public: - SetLocal() = default; - SetLocal(MixedArena& allocator) {} + LocalSet() = default; + LocalSet(MixedArena& allocator) {} void finalize(); @@ -670,18 +670,18 @@ public: void setTee(bool is); }; -class GetGlobal : public SpecificExpression<Expression::GetGlobalId> { +class GlobalGet : public SpecificExpression<Expression::GlobalGetId> { public: - GetGlobal() = default; - GetGlobal(MixedArena& allocator) {} + GlobalGet() = default; + GlobalGet(MixedArena& allocator) {} Name name; }; -class SetGlobal : public SpecificExpression<Expression::SetGlobalId> { +class GlobalSet : public SpecificExpression<Expression::GlobalSetId> { public: - SetGlobal() = default; - SetGlobal(MixedArena& allocator) {} + GlobalSet() = default; + GlobalSet(MixedArena& allocator) {} Name name; Expression* value; diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 8d0581312..d8ce18de5 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1798,8 +1798,8 @@ Expression* WasmBinaryBuilder::popNonVoidExpression() { auto type = block->list[0]->type; if (isConcreteType(type)) { auto local = builder.addVar(currFunction, type); - block->list[0] = builder.makeSetLocal(local, block->list[0]); - block->list.push_back(builder.makeGetLocal(local, type)); + block->list[0] = builder.makeLocalSet(local, block->list[0]); + block->list.push_back(builder.makeLocalGet(local, type)); } else { assert(type == unreachable); // nothing to do here - unreachable anyhow @@ -2109,7 +2109,7 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) { case BinaryConsts::BrIf: visitBreak((curr = allocator.alloc<Break>())->cast<Break>(), code); break; // code distinguishes br from br_if - case BinaryConsts::TableSwitch: + case BinaryConsts::BrTable: visitSwitch((curr = allocator.alloc<Switch>())->cast<Switch>()); break; case BinaryConsts::CallFunction: @@ -2119,19 +2119,19 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) { visitCallIndirect( (curr = allocator.alloc<CallIndirect>())->cast<CallIndirect>()); break; - case BinaryConsts::GetLocal: - visitGetLocal((curr = allocator.alloc<GetLocal>())->cast<GetLocal>()); + case BinaryConsts::LocalGet: + visitLocalGet((curr = allocator.alloc<LocalGet>())->cast<LocalGet>()); break; - case BinaryConsts::TeeLocal: - case BinaryConsts::SetLocal: - visitSetLocal((curr = allocator.alloc<SetLocal>())->cast<SetLocal>(), + case BinaryConsts::LocalTee: + case BinaryConsts::LocalSet: + visitLocalSet((curr = allocator.alloc<LocalSet>())->cast<LocalSet>(), code); break; - case BinaryConsts::GetGlobal: - visitGetGlobal((curr = allocator.alloc<GetGlobal>())->cast<GetGlobal>()); + case BinaryConsts::GlobalGet: + visitGlobalGet((curr = allocator.alloc<GlobalGet>())->cast<GlobalGet>()); break; - case BinaryConsts::SetGlobal: - visitSetGlobal((curr = allocator.alloc<SetGlobal>())->cast<SetGlobal>()); + case BinaryConsts::GlobalSet: + visitGlobalSet((curr = allocator.alloc<GlobalSet>())->cast<GlobalSet>()); break; case BinaryConsts::Select: visitSelect((curr = allocator.alloc<Select>())->cast<Select>()); @@ -2302,8 +2302,8 @@ void WasmBinaryBuilder::pushBlockElements(Block* curr, Builder builder(wasm); auto* item = curr->list[consumable]->cast<Drop>()->value; auto temp = builder.addVar(currFunction, item->type); - curr->list[consumable] = builder.makeSetLocal(temp, item); - curr->list.push_back(builder.makeGetLocal(temp, item->type)); + curr->list[consumable] = builder.makeLocalSet(temp, item); + curr->list.push_back(builder.makeLocalGet(temp, item->type)); } } @@ -2544,9 +2544,9 @@ void WasmBinaryBuilder::visitCallIndirect(CallIndirect* curr) { curr->finalize(); } -void WasmBinaryBuilder::visitGetLocal(GetLocal* curr) { +void WasmBinaryBuilder::visitLocalGet(LocalGet* curr) { if (debug) { - std::cerr << "zz node: GetLocal " << pos << std::endl; + std::cerr << "zz node: LocalGet " << pos << std::endl; } requireFunctionContext("local.get"); curr->index = getU32LEB(); @@ -2557,9 +2557,9 @@ void WasmBinaryBuilder::visitGetLocal(GetLocal* curr) { curr->finalize(); } -void WasmBinaryBuilder::visitSetLocal(SetLocal* curr, uint8_t code) { +void WasmBinaryBuilder::visitLocalSet(LocalSet* curr, uint8_t code) { if (debug) { - std::cerr << "zz node: Set|TeeLocal" << std::endl; + std::cerr << "zz node: Set|LocalTee" << std::endl; } requireFunctionContext("local.set outside of function"); curr->index = getU32LEB(); @@ -2568,22 +2568,22 @@ void WasmBinaryBuilder::visitSetLocal(SetLocal* curr, uint8_t code) { } curr->value = popNonVoidExpression(); curr->type = curr->value->type; - curr->setTee(code == BinaryConsts::TeeLocal); + curr->setTee(code == BinaryConsts::LocalTee); curr->finalize(); } -void WasmBinaryBuilder::visitGetGlobal(GetGlobal* curr) { +void WasmBinaryBuilder::visitGlobalGet(GlobalGet* curr) { if (debug) { - std::cerr << "zz node: GetGlobal " << pos << std::endl; + std::cerr << "zz node: GlobalGet " << pos << std::endl; } auto index = getU32LEB(); curr->name = getGlobalName(index); curr->type = wasm.getGlobal(curr->name)->type; } -void WasmBinaryBuilder::visitSetGlobal(SetGlobal* curr) { +void WasmBinaryBuilder::visitGlobalSet(GlobalSet* curr) { if (debug) { - std::cerr << "zz node: SetGlobal" << std::endl; + std::cerr << "zz node: GlobalSet" << std::endl; } auto index = getU32LEB(); curr->name = getGlobalName(index); @@ -3177,15 +3177,15 @@ bool WasmBinaryBuilder::maybeVisitUnary(Expression*& out, uint8_t code) { curr->op = ConvertSInt64ToFloat64; break; - case BinaryConsts::I64STruncI32: + case BinaryConsts::I64SExtendI32: curr = allocator.alloc<Unary>(); curr->op = ExtendSInt32; break; - case BinaryConsts::I64UTruncI32: + case BinaryConsts::I64UExtendI32: curr = allocator.alloc<Unary>(); curr->op = ExtendUInt32; break; - case BinaryConsts::I32ConvertI64: + case BinaryConsts::I32WrapI64: curr = allocator.alloc<Unary>(); curr->op = WrapInt64; break; @@ -3232,11 +3232,11 @@ bool WasmBinaryBuilder::maybeVisitUnary(Expression*& out, uint8_t code) { curr->op = TruncFloat64; break; - case BinaryConsts::F32ConvertF64: + case BinaryConsts::F32DemoteI64: curr = allocator.alloc<Unary>(); curr->op = DemoteFloat64; break; - case BinaryConsts::F64ConvertF32: + case BinaryConsts::F64PromoteF32: curr = allocator.alloc<Unary>(); curr->op = PromoteFloat32; break; @@ -4191,14 +4191,14 @@ void WasmBinaryBuilder::visitReturn(Return* curr) { bool WasmBinaryBuilder::maybeVisitHost(Expression*& out, uint8_t code) { Host* curr; switch (code) { - case BinaryConsts::CurrentMemory: { + case BinaryConsts::MemorySize: { curr = allocator.alloc<Host>(); - curr->op = CurrentMemory; + curr->op = MemorySize; break; } - case BinaryConsts::GrowMemory: { + case BinaryConsts::MemoryGrow: { curr = allocator.alloc<Host>(); - curr->op = GrowMemory; + curr->op = MemoryGrow; curr->operands.resize(1); curr->operands[0] = popNonVoidExpression(); break; @@ -4211,7 +4211,7 @@ bool WasmBinaryBuilder::maybeVisitHost(Expression*& out, uint8_t code) { } auto reserved = getU32LEB(); if (reserved != 0) { - throwError("Invalid reserved field on grow_memory/current_memory"); + throwError("Invalid reserved field on memory.grow/memory.size"); } curr->finalize(); out = curr; diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp index cd27c2821..383902971 100644 --- a/src/wasm/wasm-emscripten.cpp +++ b/src/wasm/wasm-emscripten.cpp @@ -89,7 +89,7 @@ Expression* EmscriptenGlueGenerator::generateLoadStackPointer() { if (!stackPointer) { Fatal() << "stack pointer global not found"; } - return builder.makeGetGlobal(stackPointer->name, i32); + return builder.makeGlobalGet(stackPointer->name, i32); } Expression* @@ -107,7 +107,7 @@ EmscriptenGlueGenerator::generateStoreStackPointer(Expression* value) { if (!stackPointer) { Fatal() << "stack pointer global not found"; } - return builder.makeSetGlobal(stackPointer->name, value); + return builder.makeGlobalSet(stackPointer->name, value); } void EmscriptenGlueGenerator::generateStackSaveFunction() { @@ -125,18 +125,18 @@ void EmscriptenGlueGenerator::generateStackAllocFunction() { Function* function = builder.makeFunction(STACK_ALLOC, std::move(params), i32, {{"1", i32}}); Expression* loadStack = generateLoadStackPointer(); - GetLocal* getSizeArg = builder.makeGetLocal(0, i32); + LocalGet* getSizeArg = builder.makeLocalGet(0, i32); Binary* sub = builder.makeBinary(SubInt32, loadStack, getSizeArg); const static uint32_t bitAlignment = 16; const static uint32_t bitMask = bitAlignment - 1; Const* subConst = builder.makeConst(Literal(~bitMask)); Binary* maskedSub = builder.makeBinary(AndInt32, sub, subConst); - SetLocal* teeStackLocal = builder.makeTeeLocal(1, maskedSub); + LocalSet* teeStackLocal = builder.makeLocalTee(1, maskedSub); Expression* storeStack = generateStoreStackPointer(teeStackLocal); Block* block = builder.makeBlock(); block->list.push_back(storeStack); - GetLocal* getStackLocal2 = builder.makeGetLocal(1, i32); + LocalGet* getStackLocal2 = builder.makeLocalGet(1, i32); block->list.push_back(getStackLocal2); block->type = i32; function->body = block; @@ -148,7 +148,7 @@ void EmscriptenGlueGenerator::generateStackRestoreFunction() { std::vector<NameType> params{{"0", i32}}; Function* function = builder.makeFunction(STACK_RESTORE, std::move(params), none, {}); - GetLocal* getArg = builder.makeGetLocal(0, i32); + LocalGet* getArg = builder.makeLocalGet(0, i32); Expression* store = generateStoreStackPointer(getArg); function->body = store; @@ -224,8 +224,8 @@ Function* EmscriptenGlueGenerator::generateAssignGOTEntriesFunction() { Name getter(std::string("g$") + g->base.c_str()); ensureFunctionImport(&wasm, getter, "i"); Expression* call = builder.makeCall(getter, {}, i32); - SetGlobal* setGlobal = builder.makeSetGlobal(g->name, call); - block->list.push_back(setGlobal); + GlobalSet* globalSet = builder.makeGlobalSet(g->name, call); + block->list.push_back(globalSet); } for (Global* g : gotFuncEntries) { @@ -250,8 +250,8 @@ Function* EmscriptenGlueGenerator::generateAssignGOTEntriesFunction() { .c_str()); ensureFunctionImport(&wasm, getter, "i"); Expression* call = builder.makeCall(getter, {}, i32); - SetGlobal* setGlobal = builder.makeSetGlobal(g->name, call); - block->list.push_back(setGlobal); + GlobalSet* globalSet = builder.makeGlobalSet(g->name, call); + block->list.push_back(globalSet); } wasm.addFunction(assignFunc); @@ -304,7 +304,7 @@ Function* EmscriptenGlueGenerator::generateMemoryGrowthFunction() { Function* growFunction = builder.makeFunction(name, std::move(params), i32, {}); growFunction->body = - builder.makeHost(GrowMemory, Name(), {builder.makeGetLocal(0, i32)}); + builder.makeHost(MemoryGrow, Name(), {builder.makeLocalGet(0, i32)}); addExportedFunction(wasm, growFunction); @@ -351,10 +351,10 @@ void EmscriptenGlueGenerator::generateDynCallThunk(std::string sig) { } Function* f = builder.makeFunction(name, std::move(params), funcType->result, {}); - Expression* fptr = builder.makeGetLocal(0, i32); + Expression* fptr = builder.makeLocalGet(0, i32); std::vector<Expression*> args; for (unsigned i = 0; i < funcType->params.size(); ++i) { - args.push_back(builder.makeGetLocal(i + 1, funcType->params[i])); + args.push_back(builder.makeLocalGet(i + 1, funcType->params[i])); } Expression* call = builder.makeCallIndirect(funcType, fptr, args); f->body = call; @@ -378,7 +378,7 @@ void EmscriptenGlueGenerator::generateDynCallThunks() { struct RemoveStackPointer : public PostWalker<RemoveStackPointer> { RemoveStackPointer(Global* stackPointer) : stackPointer(stackPointer) {} - void visitGetGlobal(GetGlobal* curr) { + void visitGlobalGet(GlobalGet* curr) { if (getModule()->getGlobalOrNull(curr->name) == stackPointer) { needStackSave = true; if (!builder) { @@ -388,7 +388,7 @@ struct RemoveStackPointer : public PostWalker<RemoveStackPointer> { } } - void visitSetGlobal(SetGlobal* curr) { + void visitGlobalSet(GlobalSet* curr) { if (getModule()->getGlobalOrNull(curr->name) == stackPointer) { needStackRestore = true; if (!builder) { @@ -505,14 +505,14 @@ struct AsmConstWalker : public LinearExecutionWalker<AsmConstWalker> { std::map<std::string, Address> ids; std::set<std::string> allSigs; // last sets in the current basic block, per index - std::map<Index, SetLocal*> sets; + std::map<Index, LocalSet*> sets; AsmConstWalker(Module& _wasm) : wasm(_wasm), segmentOffsets(getSegmentOffsets(wasm)) {} void noteNonLinear(Expression* curr); - void visitSetLocal(SetLocal* curr); + void visitLocalSet(LocalSet* curr); void visitCall(Call* curr); void visitTable(Table* curr); @@ -534,7 +534,7 @@ void AsmConstWalker::noteNonLinear(Expression* curr) { sets.clear(); } -void AsmConstWalker::visitSetLocal(SetLocal* curr) { sets[curr->index] = curr; } +void AsmConstWalker::visitLocalSet(LocalSet* curr) { sets[curr->index] = curr; } void AsmConstWalker::visitCall(Call* curr) { auto* import = wasm.getFunction(curr->target); @@ -545,7 +545,7 @@ void AsmConstWalker::visitCall(Call* curr) { auto sig = fixupNameWithSig(curr->target, baseSig); auto* arg = curr->operands[0]; while (!arg->dynCast<Const>()) { - if (auto* get = arg->dynCast<GetLocal>()) { + if (auto* get = arg->dynCast<LocalGet>()) { // The argument may be a local.get, in which case, the last set in this // basic block has the value. auto* set = sets[get->index]; @@ -697,7 +697,7 @@ struct EmJsWalker : public PostWalker<EmJsWalker> { if (block && block->list.size() > 0) { value = block->list[0]; // first item may be a set of a local that we get later - auto* set = value->dynCast<SetLocal>(); + auto* set = value->dynCast<LocalSet>(); if (set) { value = block->list[1]; } @@ -706,7 +706,7 @@ struct EmJsWalker : public PostWalker<EmJsWalker> { value = ret->value; } // if it's a get of that set, use that value - if (auto* get = value->dynCast<GetLocal>()) { + if (auto* get = value->dynCast<LocalGet>()) { if (set && get->index == set->index) { value = set->value; } diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 6e9986bb1..b93165716 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -917,9 +917,9 @@ Expression* SExpressionWasmBuilder::makeHost(Element& s, HostOp op) { auto ret = allocator.alloc<Host>(); ret->op = op; parseCallOperands(s, 1, s.size(), ret); - if (ret->op == HostOp::GrowMemory) { + if (ret->op == HostOp::MemoryGrow) { if (ret->operands.size() != 1) { - throw ParseException("grow_memory needs one operand"); + throw ParseException("memory.grow needs one operand"); } } else { if (ret->operands.size() != 0) { @@ -949,15 +949,15 @@ Index SExpressionWasmBuilder::getLocalIndex(Element& s) { return ret; } -Expression* SExpressionWasmBuilder::makeGetLocal(Element& s) { - auto ret = allocator.alloc<GetLocal>(); +Expression* SExpressionWasmBuilder::makeLocalGet(Element& s) { + auto ret = allocator.alloc<LocalGet>(); ret->index = getLocalIndex(*s[1]); ret->type = currFunction->getLocalType(ret->index); return ret; } -Expression* SExpressionWasmBuilder::makeTeeLocal(Element& s) { - auto ret = allocator.alloc<SetLocal>(); +Expression* SExpressionWasmBuilder::makeLocalTee(Element& s) { + auto ret = allocator.alloc<LocalSet>(); ret->index = getLocalIndex(*s[1]); ret->value = parseExpression(s[2]); ret->setTee(true); @@ -965,8 +965,8 @@ Expression* SExpressionWasmBuilder::makeTeeLocal(Element& s) { return ret; } -Expression* SExpressionWasmBuilder::makeSetLocal(Element& s) { - auto ret = allocator.alloc<SetLocal>(); +Expression* SExpressionWasmBuilder::makeLocalSet(Element& s) { + auto ret = allocator.alloc<LocalSet>(); ret->index = getLocalIndex(*s[1]); ret->value = parseExpression(s[2]); ret->setTee(false); @@ -974,8 +974,8 @@ Expression* SExpressionWasmBuilder::makeSetLocal(Element& s) { return ret; } -Expression* SExpressionWasmBuilder::makeGetGlobal(Element& s) { - auto ret = allocator.alloc<GetGlobal>(); +Expression* SExpressionWasmBuilder::makeGlobalGet(Element& s) { + auto ret = allocator.alloc<GlobalGet>(); ret->name = getGlobalName(*s[1]); auto* global = wasm.getGlobalOrNull(ret->name); if (!global) { @@ -985,8 +985,8 @@ Expression* SExpressionWasmBuilder::makeGetGlobal(Element& s) { return ret; } -Expression* SExpressionWasmBuilder::makeSetGlobal(Element& s) { - auto ret = allocator.alloc<SetGlobal>(); +Expression* SExpressionWasmBuilder::makeGlobalSet(Element& s) { + auto ret = allocator.alloc<GlobalSet>(); ret->name = getGlobalName(*s[1]); if (wasm.getGlobalOrNull(ret->name) && !wasm.getGlobalOrNull(ret->name)->mutable_) { diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 7467f1f15..01fe7e976 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -259,10 +259,10 @@ public: void visitCall(Call* curr); void visitCallIndirect(CallIndirect* curr); void visitConst(Const* curr); - void visitGetLocal(GetLocal* curr); - void visitSetLocal(SetLocal* curr); - void visitGetGlobal(GetGlobal* curr); - void visitSetGlobal(SetGlobal* curr); + void visitLocalGet(LocalGet* curr); + void visitLocalSet(LocalSet* curr); + void visitGlobalGet(GlobalGet* curr); + void visitGlobalSet(GlobalSet* curr); void visitLoad(Load* curr); void visitStore(Store* curr); void visitAtomicRMW(AtomicRMW* curr); @@ -624,7 +624,7 @@ void FunctionValidator::visitConst(Const* curr) { "all used features should be allowed"); } -void FunctionValidator::visitGetLocal(GetLocal* curr) { +void FunctionValidator::visitLocalGet(LocalGet* curr) { shouldBeTrue(curr->index < getFunction()->getNumLocals(), curr, "local.get index must be small enough"); @@ -637,7 +637,7 @@ void FunctionValidator::visitGetLocal(GetLocal* curr) { "local.get must have proper type"); } -void FunctionValidator::visitSetLocal(SetLocal* curr) { +void FunctionValidator::visitLocalSet(LocalSet* curr) { shouldBeTrue(curr->index < getFunction()->getNumLocals(), curr, "local.set index must be small enough"); @@ -653,7 +653,7 @@ void FunctionValidator::visitSetLocal(SetLocal* curr) { } } -void FunctionValidator::visitGetGlobal(GetGlobal* curr) { +void FunctionValidator::visitGlobalGet(GlobalGet* curr) { if (!info.validateGlobally) { return; } @@ -662,7 +662,7 @@ void FunctionValidator::visitGetGlobal(GetGlobal* curr) { "global.get name must be valid"); } -void FunctionValidator::visitSetGlobal(SetGlobal* curr) { +void FunctionValidator::visitGlobalSet(GlobalSet* curr) { if (!info.validateGlobally) { return; } @@ -1490,19 +1490,21 @@ void FunctionValidator::visitReturn(Return* curr) { } void FunctionValidator::visitHost(Host* curr) { + shouldBeTrue( + getModule()->memory.exists, curr, "Memory operations require a memory"); switch (curr->op) { - case GrowMemory: { + case MemoryGrow: { shouldBeEqual(curr->operands.size(), size_t(1), curr, - "grow_memory must have 1 operand"); + "memory.grow must have 1 operand"); shouldBeEqualOrFirstIsUnreachable(curr->operands[0]->type, i32, curr, - "grow_memory must have i32 operand"); + "memory.grow must have i32 operand"); break; } - case CurrentMemory: + case MemorySize: break; } } @@ -1563,7 +1565,7 @@ void FunctionValidator::visitFunction(Function* curr) { } static bool checkOffset(Expression* curr, Address add, Address max) { - if (curr->is<GetGlobal>()) { + if (curr->is<GlobalGet>()) { return true; } auto* c = curr->dynCast<Const>(); @@ -1761,7 +1763,8 @@ static void validateGlobals(Module& module, ValidationInfo& info) { "all used types should be allowed"); info.shouldBeTrue( curr->init != nullptr, curr->name, "global init must be non-null"); - info.shouldBeTrue(curr->init->is<Const>() || curr->init->is<GetGlobal>(), + assert(curr->init); + info.shouldBeTrue(curr->init->is<Const>() || curr->init->is<GlobalGet>(), curr->name, "global init must be valid"); if (!info.shouldBeEqual(curr->type, diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index bf12c22d4..6afc22309 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -102,13 +102,13 @@ const char* getExpressionName(Expression* curr) { return "call"; case Expression::Id::CallIndirectId: return "call_indirect"; - case Expression::Id::GetLocalId: + case Expression::Id::LocalGetId: return "local.get"; - case Expression::Id::SetLocalId: + case Expression::Id::LocalSetId: return "local.set"; - case Expression::Id::GetGlobalId: + case Expression::Id::GlobalGetId: return "global.get"; - case Expression::Id::SetGlobalId: + case Expression::Id::GlobalSetId: return "global.set"; case Expression::Id::LoadId: return "load"; @@ -427,9 +427,9 @@ bool FunctionType::operator==(FunctionType& b) { } bool FunctionType::operator!=(FunctionType& b) { return !(*this == b); } -bool SetLocal::isTee() { return type != none; } +bool LocalSet::isTee() { return type != none; } -void SetLocal::setTee(bool is) { +void LocalSet::setTee(bool is) { if (is) { type = value->type; } else { @@ -438,7 +438,7 @@ void SetLocal::setTee(bool is) { finalize(); // type may need to be unreachable } -void SetLocal::finalize() { +void LocalSet::finalize() { if (value->type == unreachable) { type = unreachable; } else if (isTee()) { @@ -448,7 +448,7 @@ void SetLocal::finalize() { } } -void SetGlobal::finalize() { +void GlobalSet::finalize() { if (value->type == unreachable) { type = unreachable; } @@ -797,11 +797,11 @@ void Drop::finalize() { void Host::finalize() { switch (op) { - case CurrentMemory: { + case MemorySize: { type = i32; break; } - case GrowMemory: { + case MemoryGrow: { // if the single operand is not reachable, so are we if (operands[0]->type == unreachable) { type = unreachable; diff --git a/src/wasm2js.h b/src/wasm2js.h index 2ed531b8d..259ef47f3 100644 --- a/src/wasm2js.h +++ b/src/wasm2js.h @@ -404,7 +404,7 @@ Ref Wasm2JSBuilder::processWasm(Module* wasm, Name funcName) { std::move(params), i32, std::move(vars), - builder.makeReturn(builder.makeGetGlobal( + builder.makeReturn(builder.makeGlobalGet( INT64_TO_32_HIGH_BITS, i32))))); auto e = new Export(); e->name = WASM_FETCH_HIGH_BITS; @@ -547,7 +547,7 @@ void Wasm2JSBuilder::addTable(Ref ast, Module* wasm) { Ref index; if (auto* c = offset->dynCast<Const>()) { index = ValueBuilder::makeInt(c->value.geti32() + i); - } else if (auto* get = offset->dynCast<GetGlobal>()) { + } else if (auto* get = offset->dynCast<GlobalGet>()) { index = ValueBuilder::makeBinary( ValueBuilder::makeName(stringToIString(asmangle(get->name.str))), PLUS, @@ -578,7 +578,7 @@ void Wasm2JSBuilder::addExports(Ref ast, Module* wasm) { Ref growDesc = ValueBuilder::makeObject(); ValueBuilder::appendToObjectWithQuotes(descs, IString("grow"), growDesc); ValueBuilder::appendToObjectWithQuotes( - growDesc, IString("value"), ValueBuilder::makeName(WASM_GROW_MEMORY)); + growDesc, IString("value"), ValueBuilder::makeName(WASM_MEMORY_GROW)); Ref bufferDesc = ValueBuilder::makeObject(); Ref bufferGetter = ValueBuilder::makeFunction(IString("")); bufferGetter[3]->push_back( @@ -630,7 +630,7 @@ void Wasm2JSBuilder::addGlobal(Ref ast, Global* global) { ast->push_back(theVar); ValueBuilder::appendToVar( theVar, fromName(global->name, NameScope::Top), theValue); - } else if (auto* get = global->init->dynCast<GetGlobal>()) { + } else if (auto* get = global->init->dynCast<GlobalGet>()) { Ref theVar = ValueBuilder::makeVar(); ast->push_back(theVar); ValueBuilder::appendToVar( @@ -991,23 +991,23 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, visit(value, EXPRESSION_RESULT)); } - Ref visitGetLocal(GetLocal* curr) { + Ref visitLocalGet(LocalGet* curr) { return ValueBuilder::makeName( fromName(func->getLocalNameOrGeneric(curr->index), NameScope::Local)); } - Ref visitSetLocal(SetLocal* curr) { + Ref visitLocalSet(LocalSet* curr) { return makeSetVar(curr, curr->value, func->getLocalNameOrGeneric(curr->index), NameScope::Local); } - Ref visitGetGlobal(GetGlobal* curr) { + Ref visitGlobalGet(GlobalGet* curr) { return ValueBuilder::makeName(fromName(curr->name, NameScope::Top)); } - Ref visitSetGlobal(SetGlobal* curr) { + Ref visitGlobalSet(GlobalSet* curr) { return makeSetVar(curr, curr->value, curr->name, NameScope::Top); } @@ -1092,10 +1092,10 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, sequenceAppend(ret, visitAndAssign(curr->ptr, ptr)); ScopedTemp value(curr->value->type, parent, func); sequenceAppend(ret, visitAndAssign(curr->value, value)); - GetLocal getPtr; + LocalGet getPtr; getPtr.index = func->getLocalIndex(ptr.getName()); getPtr.type = i32; - GetLocal getValue; + LocalGet getValue; getValue.index = func->getLocalIndex(value.getName()); getValue.type = curr->value->type; Store fakeStore = *curr; @@ -1584,18 +1584,18 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, } Ref visitHost(Host* curr) { - if (curr->op == HostOp::GrowMemory) { + if (curr->op == HostOp::MemoryGrow) { if (module->memory.exists && module->memory.max > module->memory.initial) { return ValueBuilder::makeCall( - WASM_GROW_MEMORY, + WASM_MEMORY_GROW, makeAsmCoercion(visit(curr->operands[0], EXPRESSION_RESULT), wasmToAsmType(curr->operands[0]->type))); } else { return ValueBuilder::makeCall(ABORT_FUNC); } - } else if (curr->op == HostOp::CurrentMemory) { - return ValueBuilder::makeCall(WASM_CURRENT_MEMORY); + } else if (curr->op == HostOp::MemorySize) { + return ValueBuilder::makeCall(WASM_MEMORY_SIZE); } WASM_UNREACHABLE(); // TODO } @@ -1623,10 +1623,10 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, } void Wasm2JSBuilder::addMemoryGrowthFuncs(Ref ast, Module* wasm) { - Ref growMemoryFunc = ValueBuilder::makeFunction(WASM_GROW_MEMORY); - ValueBuilder::appendArgumentToFunction(growMemoryFunc, IString("pagesToAdd")); + Ref memoryGrowFunc = ValueBuilder::makeFunction(WASM_MEMORY_GROW); + ValueBuilder::appendArgumentToFunction(memoryGrowFunc, IString("pagesToAdd")); - growMemoryFunc[3]->push_back( + memoryGrowFunc[3]->push_back( ValueBuilder::makeStatement(ValueBuilder::makeBinary( ValueBuilder::makeName(IString("pagesToAdd")), SET, @@ -1634,15 +1634,15 @@ void Wasm2JSBuilder::addMemoryGrowthFuncs(Ref ast, Module* wasm) { AsmType::ASM_INT)))); Ref oldPages = ValueBuilder::makeVar(); - growMemoryFunc[3]->push_back(oldPages); + memoryGrowFunc[3]->push_back(oldPages); ValueBuilder::appendToVar( oldPages, IString("oldPages"), - makeAsmCoercion(ValueBuilder::makeCall(WASM_CURRENT_MEMORY), + makeAsmCoercion(ValueBuilder::makeCall(WASM_MEMORY_SIZE), AsmType::ASM_INT)); Ref newPages = ValueBuilder::makeVar(); - growMemoryFunc[3]->push_back(newPages); + memoryGrowFunc[3]->push_back(newPages); ValueBuilder::appendToVar( newPages, IString("newPages"), @@ -1653,7 +1653,7 @@ void Wasm2JSBuilder::addMemoryGrowthFuncs(Ref ast, Module* wasm) { AsmType::ASM_INT)); Ref block = ValueBuilder::makeBlock(); - growMemoryFunc[3]->push_back(ValueBuilder::makeIf( + memoryGrowFunc[3]->push_back(ValueBuilder::makeIf( ValueBuilder::makeBinary( ValueBuilder::makeBinary(ValueBuilder::makeName(IString("oldPages")), LT, @@ -1735,19 +1735,19 @@ void Wasm2JSBuilder::addMemoryGrowthFuncs(Ref ast, Module* wasm) { ValueBuilder::makeName(IString("newBuffer")))); } - growMemoryFunc[3]->push_back( + memoryGrowFunc[3]->push_back( ValueBuilder::makeReturn(ValueBuilder::makeName(IString("oldPages")))); - Ref currentMemoryFunc = ValueBuilder::makeFunction(WASM_CURRENT_MEMORY); - currentMemoryFunc[3]->push_back(ValueBuilder::makeReturn( + Ref memorySizeFunc = ValueBuilder::makeFunction(WASM_MEMORY_SIZE); + memorySizeFunc[3]->push_back(ValueBuilder::makeReturn( makeAsmCoercion(ValueBuilder::makeBinary( ValueBuilder::makeDot(ValueBuilder::makeName(BUFFER), IString("byteLength")), DIV, ValueBuilder::makeInt(Memory::kPageSize)), AsmType::ASM_INT))); - ast->push_back(growMemoryFunc); - ast->push_back(currentMemoryFunc); + ast->push_back(memoryGrowFunc); + ast->push_back(memorySizeFunc); } // Wasm2JSGlue emits the core of the module - the functions etc. that would @@ -1973,7 +1973,7 @@ void Wasm2JSGlue::emitMemory( ; return std::to_string(c->value.getInteger()); } - if (auto* get = segment.offset->template dynCast<GetGlobal>()) { + if (auto* get = segment.offset->template dynCast<GlobalGet>()) { auto internalName = get->name; auto importedName = wasm.getGlobal(internalName)->base; return accessGlobal(asmangle(importedName.str)); diff --git a/test/binaryen.js/emit_asmjs.js b/test/binaryen.js/emit_asmjs.js index c7cd5c717..1faf58308 100644 --- a/test/binaryen.js/emit_asmjs.js +++ b/test/binaryen.js/emit_asmjs.js @@ -2,7 +2,7 @@ var module = new Binaryen.Module(); var signature = module.addFunctionType("ii", Binaryen.i32, [ Binaryen.i32 ]); -module.addFunction("main", signature, [], module.getLocal(0, Binaryen.i32)); +module.addFunction("main", signature, [], module.local.get(0, Binaryen.i32)); module.addFunctionExport("main", "main"); diff --git a/test/binaryen.js/hello-world.js b/test/binaryen.js/hello-world.js index 2a9a56ed0..03cfb4163 100644 --- a/test/binaryen.js/hello-world.js +++ b/test/binaryen.js/hello-world.js @@ -11,8 +11,8 @@ var iii = module.addFunctionType('iii', Binaryen.i32, [Binaryen.i32, Binaryen.i3 // Start to create the function, starting with the contents: Get the 0 and // 1 arguments, and add them, then return them -var left = module.getLocal(0, Binaryen.i32); -var right = module.getLocal(1, Binaryen.i32); +var left = module.local.get(0, Binaryen.i32); +var right = module.local.get(1, Binaryen.i32); var add = module.i32.add(left, right); var ret = module.return(add); diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index a798c4092..38ce32876 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -81,10 +81,10 @@ function test_ids() { console.log("BinaryenSwitchId: " + Binaryen.SwitchId); console.log("BinaryenCallId: " + Binaryen.CallId); console.log("BinaryenCallIndirectId: " + Binaryen.CallIndirectId); - console.log("BinaryenGetLocalId: " + Binaryen.GetLocalId); - console.log("BinaryenSetLocalId: " + Binaryen.SetLocalId); - console.log("BinaryenGetGlobalId: " + Binaryen.GetGlobalId); - console.log("BinaryenSetGlobalId: " + Binaryen.SetGlobalId); + console.log("BinaryenLocalGetId: " + Binaryen.LocalGetId); + console.log("BinaryenLocalSetId: " + Binaryen.LocalSetId); + console.log("BinaryenGlobalGetId: " + Binaryen.GlobalGetId); + console.log("BinaryenGlobalSetId: " + Binaryen.GlobalSetId); console.log("BinaryenLoadId: " + Binaryen.LoadId); console.log("BinaryenStoreId: " + Binaryen.StoreId); console.log("BinaryenConstId: " + Binaryen.ConstId); @@ -383,9 +383,9 @@ function test_core() { module.i32.eqz( // check the output type of the call node module.callIndirect(makeInt32(2449), [ makeInt32(13), makeInt64(37, 0), makeFloat32(1.3), makeFloat64(3.7) ], "iiIfF") ), - module.drop(module.getLocal(0, Binaryen.i32)), - module.setLocal(0, makeInt32(101)), - module.drop(module.teeLocal(0, makeInt32(102))), + module.drop(module.local.get(0, Binaryen.i32)), + module.local.set(0, makeInt32(101)), + module.drop(module.local.tee(0, makeInt32(102))), module.i32.load(0, 0, makeInt32(1)), module.i64.load16_s(2, 1, makeInt32(8)), module.f32.load(0, 0, makeInt32(2)), @@ -688,8 +688,8 @@ function test_binaries() { { // create a module and write it to binary module = new Binaryen.Module(); var iii = module.addFunctionType("iii", Binaryen.i32, [ Binaryen.i32, Binaryen.i32 ]); - var x = module.getLocal(0, Binaryen.i32), - y = module.getLocal(1, Binaryen.i32); + var x = module.local.get(0, Binaryen.i32), + y = module.local.get(1, Binaryen.i32); var add = module.i32.add(x, y); var adder = module.addFunction("adder", iii, [], add); var initExpr = module.i32.const(3); @@ -738,7 +738,7 @@ function test_nonvalid() { var v = module.addFunctionType("v", Binaryen.None, []); var func = module.addFunction("func", v, [ Binaryen.i32 ], - module.setLocal(0, makeInt64(1234, 0)) // wrong type! + module.local.set(0, makeInt64(1234, 0)) // wrong type! ); console.log(module.emitText()); @@ -760,8 +760,8 @@ function test_parsing() { // create a module and write it to text module = new Binaryen.Module(); var iii = module.addFunctionType("iii", Binaryen.i32, [ Binaryen.i32, Binaryen.i32 ]); - var x = module.getLocal(0, Binaryen.i32), - y = module.getLocal(1, Binaryen.i32); + var x = module.local.get(0, Binaryen.i32), + y = module.local.get(1, Binaryen.i32); var add = module.i32.add(x, y); var adder = module.addFunction("adder", iii, [], add); var initExpr = module.i32.const(3); diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index fb937e39d..e68efda08 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -22,10 +22,10 @@ BinaryenBreakId: 4 BinaryenSwitchId: 5 BinaryenCallId: 6 BinaryenCallIndirectId: 7 -BinaryenGetLocalId: 8 -BinaryenSetLocalId: 9 -BinaryenGetGlobalId: 10 -BinaryenSetGlobalId: 11 +BinaryenLocalGetId: 8 +BinaryenLocalSetId: 9 +BinaryenGlobalGetId: 10 +BinaryenGlobalSetId: 11 BinaryenLoadId: 12 BinaryenStoreId: 13 BinaryenConstId: 14 @@ -3227,12 +3227,12 @@ int main() { expressions[623] = BinaryenCallIndirect(the_module, expressions[618], operands, 4, "iiIfF"); } expressions[624] = BinaryenUnary(the_module, 20, expressions[623]); - expressions[625] = BinaryenGetLocal(the_module, 0, 1); + expressions[625] = BinaryenLocalGet(the_module, 0, 1); expressions[626] = BinaryenDrop(the_module, expressions[625]); expressions[627] = BinaryenConst(the_module, BinaryenLiteralInt32(101)); - expressions[628] = BinaryenSetLocal(the_module, 0, expressions[627]); + expressions[628] = BinaryenLocalSet(the_module, 0, expressions[627]); expressions[629] = BinaryenConst(the_module, BinaryenLiteralInt32(102)); - expressions[630] = BinaryenTeeLocal(the_module, 0, expressions[629]); + expressions[630] = BinaryenLocalTee(the_module, 0, expressions[629]); expressions[631] = BinaryenDrop(the_module, expressions[630]); expressions[632] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); expressions[633] = BinaryenLoad(the_module, 4, 1, 0, 0, 1, expressions[632]); @@ -3390,8 +3390,8 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} functionTypes[3] = BinaryenAddFunctionType(the_module, NULL, 0, paramTypes, 0); } BinaryenModuleAutoDrop(the_module); - BinaryenSetFeatures(the_module, 61); - BinaryenGetFeatures(the_module); + BinaryenModuleSetFeatures(the_module, 61); + BinaryenModuleGetFeatures(the_module); BinaryenModuleValidate(the_module); BinaryenModulePrint(the_module); (module diff --git a/test/binaryen.js/sieve.js b/test/binaryen.js/sieve.js index 8f31e9cd8..41dd0ddd3 100644 --- a/test/binaryen.js/sieve.js +++ b/test/binaryen.js/sieve.js @@ -14,13 +14,13 @@ var body = module.block( module.if( module.i32.lt_u( module.i32.mul( - module.current_memory(), + module.memory.size(), module.i32.const(65536) ), module.local.get(0, Binaryen.i32) ), module.drop( - module.grow_memory( + module.memory.grow( module.i32.sub( module.i32.div_u( module.i32.add( @@ -29,7 +29,7 @@ var body = module.block( ), module.i32.const(65536) ), - module.current_memory() + module.memory.size() ) ) ) diff --git a/test/binaryen.js/sieve.js.txt b/test/binaryen.js/sieve.js.txt index 2d9fc8ef2..888b6b06d 100644 --- a/test/binaryen.js/sieve.js.txt +++ b/test/binaryen.js/sieve.js.txt @@ -7,13 +7,13 @@ (if (i32.lt_u (i32.mul - (current_memory) + (memory.size) (i32.const 65536) ) (local.get $0) ) (drop - (grow_memory + (memory.grow (i32.sub (i32.div_u (i32.add @@ -22,7 +22,7 @@ ) (i32.const 65536) ) - (current_memory) + (memory.size) ) ) ) @@ -65,13 +65,13 @@ optimized: (if (i32.lt_u (i32.shl - (current_memory) + (memory.size) (i32.const 16) ) (local.get $0) ) (drop - (grow_memory + (memory.grow (i32.sub (i32.div_u (i32.add @@ -80,7 +80,7 @@ optimized: ) (i32.const 65536) ) - (current_memory) + (memory.size) ) ) ) diff --git a/test/binaryen.js/validation_errors.js b/test/binaryen.js/validation_errors.js index 58eed0e08..e2ee01adb 100644 --- a/test/binaryen.js/validation_errors.js +++ b/test/binaryen.js/validation_errors.js @@ -4,7 +4,7 @@ var func = mod.addFunction("test", funcType, [], mod.block("", [ mod.drop( - mod.getGlobal("missing", Binaryen.i32) + mod.global.get("missing", Binaryen.i32) ) ]) ); @@ -18,7 +18,7 @@ var func = mod.addFunction("test", funcType, [], mod.block("", [ mod.drop( - mod.getLocal(0, Binaryen.i32) + mod.local.get(0, Binaryen.i32) ) ]) ); diff --git a/test/example/c-api-hello-world.c b/test/example/c-api-hello-world.c index 4cb86b5a6..066799de6 100644 --- a/test/example/c-api-hello-world.c +++ b/test/example/c-api-hello-world.c @@ -11,8 +11,8 @@ int main() { BinaryenFunctionTypeRef iii = BinaryenAddFunctionType(module, "iii", BinaryenTypeInt32(), params, 2); // Get the 0 and 1 arguments, and add them - BinaryenExpressionRef x = BinaryenGetLocal(module, 0, BinaryenTypeInt32()), - y = BinaryenGetLocal(module, 1, BinaryenTypeInt32()); + BinaryenExpressionRef x = BinaryenLocalGet(module, 0, BinaryenTypeInt32()), + y = BinaryenLocalGet(module, 1, BinaryenTypeInt32()); BinaryenExpressionRef add = BinaryenBinary(module, BinaryenAddInt32(), x, y); // Create the add function diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 1359385eb..0efafde52 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -452,9 +452,9 @@ void test_core() { BinaryenUnary(module, BinaryenEqZInt32(), // check the output type of the call node BinaryenCallIndirect(module, makeInt32(module, 2449), callOperands4b, 4, "iiIfF") ), - BinaryenDrop(module, BinaryenGetLocal(module, 0, BinaryenTypeInt32())), - BinaryenSetLocal(module, 0, makeInt32(module, 101)), - BinaryenDrop(module, BinaryenTeeLocal(module, 0, makeInt32(module, 102))), + BinaryenDrop(module, BinaryenLocalGet(module, 0, BinaryenTypeInt32())), + BinaryenLocalSet(module, 0, makeInt32(module, 101)), + BinaryenDrop(module, BinaryenLocalTee(module, 0, makeInt32(module, 102))), BinaryenLoad(module, 4, 0, 0, 0, BinaryenTypeInt32(), makeInt32(module, 1)), BinaryenLoad(module, 2, 1, 2, 1, BinaryenTypeInt64(), makeInt32(module, 8)), BinaryenLoad(module, 4, 0, 0, 0, BinaryenTypeFloat32(), makeInt32(module, 2)), @@ -528,8 +528,8 @@ void test_core() { BinaryenFeatureSignExt() | BinaryenFeatureSIMD128(); - BinaryenSetFeatures(module, features); - assert(BinaryenGetFeatures(module) == features); + BinaryenModuleSetFeatures(module, features); + assert(BinaryenModuleGetFeatures(module) == features); // Verify it validates assert(BinaryenModuleValidate(module)); @@ -765,8 +765,8 @@ void test_binaries() { BinaryenModuleRef module = BinaryenModuleCreate(); BinaryenType params[2] = { BinaryenTypeInt32(), BinaryenTypeInt32() }; BinaryenFunctionTypeRef iii = BinaryenAddFunctionType(module, "iii", BinaryenTypeInt32(), params, 2); - BinaryenExpressionRef x = BinaryenGetLocal(module, 0, BinaryenTypeInt32()), - y = BinaryenGetLocal(module, 1, BinaryenTypeInt32()); + BinaryenExpressionRef x = BinaryenLocalGet(module, 0, BinaryenTypeInt32()), + y = BinaryenLocalGet(module, 1, BinaryenTypeInt32()); BinaryenExpressionRef add = BinaryenBinary(module, BinaryenAddInt32(), x, y); BinaryenFunctionRef adder = BinaryenAddFunction(module, "adder", iii, NULL, 0, add); BinaryenSetDebugInfo(1); // include names section @@ -816,7 +816,7 @@ void test_nonvalid() { BinaryenFunctionTypeRef v = BinaryenAddFunctionType(module, "v", BinaryenTypeNone(), NULL, 0); BinaryenType localTypes[] = { BinaryenTypeInt32() }; BinaryenFunctionRef func = BinaryenAddFunction(module, "func", v, localTypes, 1, - BinaryenSetLocal(module, 0, makeInt64(module, 1234)) // wrong type! + BinaryenLocalSet(module, 0, makeInt64(module, 1234)) // wrong type! ); BinaryenModulePrint(module); diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index 9b5c10a05..5a4055ddb 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -3195,12 +3195,12 @@ int main() { expressions[624] = BinaryenCallIndirect(the_module, expressions[623], operands, 4, "iiIfF"); } expressions[625] = BinaryenUnary(the_module, 20, expressions[624]); - expressions[626] = BinaryenGetLocal(the_module, 0, 1); + expressions[626] = BinaryenLocalGet(the_module, 0, 1); expressions[627] = BinaryenDrop(the_module, expressions[626]); expressions[628] = BinaryenConst(the_module, BinaryenLiteralInt32(101)); - expressions[629] = BinaryenSetLocal(the_module, 0, expressions[628]); + expressions[629] = BinaryenLocalSet(the_module, 0, expressions[628]); expressions[630] = BinaryenConst(the_module, BinaryenLiteralInt32(102)); - expressions[631] = BinaryenTeeLocal(the_module, 0, expressions[630]); + expressions[631] = BinaryenLocalTee(the_module, 0, expressions[630]); expressions[632] = BinaryenDrop(the_module, expressions[631]); expressions[633] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); expressions[634] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[633]); @@ -3319,8 +3319,8 @@ int main() { functionTypes[3] = BinaryenAddFunctionType(the_module, NULL, 0, paramTypes, 0); } BinaryenModuleAutoDrop(the_module); - BinaryenSetFeatures(the_module, 61); - BinaryenGetFeatures(the_module); + BinaryenModuleSetFeatures(the_module, 61); + BinaryenModuleGetFeatures(the_module); BinaryenModuleValidate(the_module); BinaryenModulePrint(the_module); (module diff --git a/test/example/c-api-relooper-unreachable-if.cpp b/test/example/c-api-relooper-unreachable-if.cpp index 3acc65d56..5f7b2e874 100644 --- a/test/example/c-api-relooper-unreachable-if.cpp +++ b/test/example/c-api-relooper-unreachable-if.cpp @@ -20,7 +20,7 @@ int main() { BinaryenSetMemory(the_module, 256, 256, "memory", segments, segmentPassive, segmentOffsets, segmentSizes, 0, 0); } the_relooper = RelooperCreate(the_module); - expressions[1] = BinaryenGetLocal(the_module, 0, 1); + expressions[1] = BinaryenLocalGet(the_module, 0, 1); expressions[2] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[3] = BinaryenStore(the_module, 4, 0, 0, expressions[2], expressions[1], 1); expressions[4] = BinaryenReturn(the_module, expressions[0]); @@ -35,7 +35,7 @@ int main() { } expressions[6] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[7] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[6]); - expressions[8] = BinaryenSetLocal(the_module, 0, expressions[7]); + expressions[8] = BinaryenLocalSet(the_module, 0, expressions[7]); relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[8]); RelooperAddBranch(relooperBlocks[1], relooperBlocks[0], expressions[0], expressions[0]); expressions[9] = RelooperRenderAndDispose(the_relooper, relooperBlocks[1], 1); @@ -45,7 +45,7 @@ int main() { } BinaryenAddFunctionExport(the_module, "tinycore::eh_personality", "tinycore::eh_personality"); the_relooper = RelooperCreate(the_module); - expressions[10] = BinaryenGetLocal(the_module, 0, 1); + expressions[10] = BinaryenLocalGet(the_module, 0, 1); expressions[11] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[12] = BinaryenStore(the_module, 4, 0, 0, expressions[11], expressions[10], 1); expressions[13] = BinaryenReturn(the_module, expressions[0]); @@ -56,7 +56,7 @@ int main() { relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[14]); expressions[15] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[16] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[15]); - expressions[17] = BinaryenSetLocal(the_module, 0, expressions[16]); + expressions[17] = BinaryenLocalSet(the_module, 0, expressions[16]); relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[17]); RelooperAddBranch(relooperBlocks[1], relooperBlocks[0], expressions[0], expressions[0]); expressions[18] = RelooperRenderAndDispose(the_relooper, relooperBlocks[1], 1); @@ -84,7 +84,7 @@ int main() { } expressions[21] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[22] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[21]); - expressions[23] = BinaryenSetLocal(the_module, 0, expressions[22]); + expressions[23] = BinaryenLocalSet(the_module, 0, expressions[22]); relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[23]); RelooperAddBranch(relooperBlocks[2], relooperBlocks[0], expressions[0], expressions[0]); expressions[24] = RelooperRenderAndDispose(the_relooper, relooperBlocks[2], 1); @@ -94,7 +94,7 @@ int main() { } BinaryenAddFunctionExport(the_module, "tinycore::panic_fmt", "tinycore::panic_fmt"); the_relooper = RelooperCreate(the_module); - expressions[25] = BinaryenGetLocal(the_module, 0, 1); + expressions[25] = BinaryenLocalGet(the_module, 0, 1); expressions[26] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[27] = BinaryenStore(the_module, 4, 0, 0, expressions[26], expressions[25], 1); expressions[28] = BinaryenReturn(the_module, expressions[0]); @@ -105,7 +105,7 @@ int main() { relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[29]); expressions[30] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[31] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[30]); - expressions[32] = BinaryenSetLocal(the_module, 0, expressions[31]); + expressions[32] = BinaryenLocalSet(the_module, 0, expressions[31]); relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[32]); RelooperAddBranch(relooperBlocks[1], relooperBlocks[0], expressions[0], expressions[0]); expressions[33] = RelooperRenderAndDispose(the_relooper, relooperBlocks[1], 1); @@ -115,7 +115,7 @@ int main() { } BinaryenAddFunctionExport(the_module, "tinycore::rust_eh_register_frames", "tinycore::rust_eh_register_frames"); the_relooper = RelooperCreate(the_module); - expressions[34] = BinaryenGetLocal(the_module, 0, 1); + expressions[34] = BinaryenLocalGet(the_module, 0, 1); expressions[35] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[36] = BinaryenStore(the_module, 4, 0, 0, expressions[35], expressions[34], 1); expressions[37] = BinaryenReturn(the_module, expressions[0]); @@ -126,7 +126,7 @@ int main() { relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[38]); expressions[39] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[40] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[39]); - expressions[41] = BinaryenSetLocal(the_module, 0, expressions[40]); + expressions[41] = BinaryenLocalSet(the_module, 0, expressions[40]); relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[41]); RelooperAddBranch(relooperBlocks[1], relooperBlocks[0], expressions[0], expressions[0]); expressions[42] = RelooperRenderAndDispose(the_relooper, relooperBlocks[1], 1); @@ -136,16 +136,16 @@ int main() { } BinaryenAddFunctionExport(the_module, "tinycore::rust_eh_unregister_frames", "tinycore::rust_eh_unregister_frames"); the_relooper = RelooperCreate(the_module); - expressions[43] = BinaryenGetLocal(the_module, 0, 1); - expressions[44] = BinaryenSetLocal(the_module, 1, expressions[43]); - expressions[45] = BinaryenGetLocal(the_module, 1, 1); - expressions[46] = BinaryenSetLocal(the_module, 2, expressions[45]); + expressions[43] = BinaryenLocalGet(the_module, 0, 1); + expressions[44] = BinaryenLocalSet(the_module, 1, expressions[43]); + expressions[45] = BinaryenLocalGet(the_module, 1, 1); + expressions[46] = BinaryenLocalSet(the_module, 2, expressions[45]); { BinaryenType paramTypes[] = { 1 }; functionTypes[2] = BinaryenAddFunctionType(the_module, "print_i32", 0, paramTypes, 1); } BinaryenAddFunctionImport(the_module, "print_i32", "spectest", "print", functionTypes[2]); - expressions[47] = BinaryenGetLocal(the_module, 2, 1); + expressions[47] = BinaryenLocalGet(the_module, 2, 1); { BinaryenExpressionRef operands[] = { expressions[47] }; expressions[48] = BinaryenCall(the_module, "print_i32", operands, 1, 0); @@ -155,7 +155,7 @@ int main() { expressions[49] = BinaryenBlock(the_module, "bb0", children, 3, BinaryenTypeAuto()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[49]); - expressions[50] = BinaryenGetLocal(the_module, 3, 1); + expressions[50] = BinaryenLocalGet(the_module, 3, 1); expressions[51] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[52] = BinaryenStore(the_module, 4, 0, 0, expressions[51], expressions[50], 1); expressions[53] = BinaryenReturn(the_module, expressions[0]); @@ -171,7 +171,7 @@ int main() { } expressions[55] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[56] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[55]); - expressions[57] = BinaryenSetLocal(the_module, 3, expressions[56]); + expressions[57] = BinaryenLocalSet(the_module, 3, expressions[56]); relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[57]); RelooperAddBranch(relooperBlocks[2], relooperBlocks[0], expressions[0], expressions[0]); expressions[58] = RelooperRenderAndDispose(the_relooper, relooperBlocks[2], 4); @@ -182,28 +182,28 @@ int main() { BinaryenAddFunctionExport(the_module, "wasm::print_i32", "wasm::print_i32"); the_relooper = RelooperCreate(the_module); expressions[59] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - expressions[60] = BinaryenSetLocal(the_module, 0, expressions[59]); - expressions[61] = BinaryenGetLocal(the_module, 0, 1); - expressions[62] = BinaryenSetLocal(the_module, 2, expressions[61]); - expressions[63] = BinaryenGetLocal(the_module, 2, 1); + expressions[60] = BinaryenLocalSet(the_module, 0, expressions[59]); + expressions[61] = BinaryenLocalGet(the_module, 0, 1); + expressions[62] = BinaryenLocalSet(the_module, 2, expressions[61]); + expressions[63] = BinaryenLocalGet(the_module, 2, 1); expressions[64] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); expressions[65] = BinaryenUnary(the_module, 22, expressions[63]); expressions[66] = BinaryenUnary(the_module, 22, expressions[64]); expressions[67] = BinaryenBinary(the_module, 25, expressions[65], expressions[66]); - expressions[68] = BinaryenSetLocal(the_module, 8, expressions[67]); - expressions[69] = BinaryenGetLocal(the_module, 8, 2); + expressions[68] = BinaryenLocalSet(the_module, 8, expressions[67]); + expressions[69] = BinaryenLocalGet(the_module, 8, 2); expressions[70] = BinaryenUnary(the_module, 24, expressions[69]); expressions[71] = BinaryenConst(the_module, BinaryenLiteralInt64(32)); - expressions[72] = BinaryenGetLocal(the_module, 8, 2); + expressions[72] = BinaryenLocalGet(the_module, 8, 2); expressions[73] = BinaryenBinary(the_module, 36, expressions[72], expressions[71]); expressions[74] = BinaryenUnary(the_module, 24, expressions[73]); expressions[75] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[76] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[75]); expressions[77] = BinaryenConst(the_module, BinaryenLiteralInt32(128)); expressions[78] = BinaryenBinary(the_module, 1, expressions[76], expressions[77]); - expressions[79] = BinaryenTeeLocal(the_module, 3, expressions[78]); + expressions[79] = BinaryenLocalTee(the_module, 3, expressions[78]); expressions[80] = BinaryenStore(the_module, 4, 0, 0, expressions[75], expressions[79], 1); - expressions[81] = BinaryenGetLocal(the_module, 3, 1); + expressions[81] = BinaryenLocalGet(the_module, 3, 1); expressions[82] = BinaryenStore(the_module, 4, 0, 0, expressions[81], expressions[70], 1); expressions[83] = BinaryenStore(the_module, 4, 4, 0, expressions[81], expressions[74], 1); { @@ -211,24 +211,24 @@ int main() { expressions[84] = BinaryenBlock(the_module, "bb0", children, 6, BinaryenTypeAuto()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[84]); - expressions[85] = BinaryenGetLocal(the_module, 3, 1); + expressions[85] = BinaryenLocalGet(the_module, 3, 1); expressions[86] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[85]); - expressions[87] = BinaryenSetLocal(the_module, 1, expressions[86]); - expressions[88] = BinaryenGetLocal(the_module, 1, 1); - expressions[89] = BinaryenSetLocal(the_module, 4, expressions[88]); - expressions[90] = BinaryenGetLocal(the_module, 4, 1); - expressions[91] = BinaryenSetLocal(the_module, 5, expressions[90]); - expressions[92] = BinaryenGetLocal(the_module, 6, 1); + expressions[87] = BinaryenLocalSet(the_module, 1, expressions[86]); + expressions[88] = BinaryenLocalGet(the_module, 1, 1); + expressions[89] = BinaryenLocalSet(the_module, 4, expressions[88]); + expressions[90] = BinaryenLocalGet(the_module, 4, 1); + expressions[91] = BinaryenLocalSet(the_module, 5, expressions[90]); + expressions[92] = BinaryenLocalGet(the_module, 6, 1); expressions[93] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[94] = BinaryenStore(the_module, 4, 0, 0, expressions[93], expressions[92], 1); - expressions[95] = BinaryenGetLocal(the_module, 5, 1); + expressions[95] = BinaryenLocalGet(the_module, 5, 1); expressions[96] = BinaryenReturn(the_module, expressions[95]); { BinaryenExpressionRef children[] = { expressions[87], expressions[89], expressions[91], expressions[94], expressions[96] }; expressions[97] = BinaryenBlock(the_module, "bb1", children, 5, BinaryenTypeAuto()); } relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[97]); - expressions[98] = BinaryenGetLocal(the_module, 3, 1); + expressions[98] = BinaryenLocalGet(the_module, 3, 1); expressions[99] = BinaryenLoad(the_module, 4, 0, 8, 0, 1, expressions[98]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[99], expressions[0]); expressions[100] = BinaryenUnreachable(the_module); @@ -240,7 +240,7 @@ int main() { } expressions[101] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[102] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[101]); - expressions[103] = BinaryenSetLocal(the_module, 6, expressions[102]); + expressions[103] = BinaryenLocalSet(the_module, 6, expressions[102]); relooperBlocks[3] = RelooperAddBlock(the_relooper, expressions[103]); RelooperAddBranch(relooperBlocks[3], relooperBlocks[0], expressions[0], expressions[0]); expressions[104] = RelooperRenderAndDispose(the_relooper, relooperBlocks[3], 7); @@ -250,37 +250,37 @@ int main() { } BinaryenAddFunctionExport(the_module, "real_main", "real_main"); the_relooper = RelooperCreate(the_module); - expressions[105] = BinaryenGetLocal(the_module, 0, 1); - expressions[106] = BinaryenSetLocal(the_module, 2, expressions[105]); + expressions[105] = BinaryenLocalGet(the_module, 0, 1); + expressions[106] = BinaryenLocalSet(the_module, 2, expressions[105]); { BinaryenExpressionRef operands[] = { 0 }; expressions[107] = BinaryenCall(the_module, "real_main", operands, 0, 1); } - expressions[108] = BinaryenSetLocal(the_module, 4, expressions[107]); + expressions[108] = BinaryenLocalSet(the_module, 4, expressions[107]); { BinaryenExpressionRef children[] = { expressions[106], expressions[108] }; expressions[109] = BinaryenBlock(the_module, "bb0", children, 2, BinaryenTypeAuto()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[109]); - expressions[110] = BinaryenGetLocal(the_module, 4, 1); + expressions[110] = BinaryenLocalGet(the_module, 4, 1); expressions[111] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); expressions[112] = BinaryenUnary(the_module, 22, expressions[110]); expressions[113] = BinaryenUnary(the_module, 22, expressions[111]); expressions[114] = BinaryenBinary(the_module, 25, expressions[112], expressions[113]); - expressions[115] = BinaryenSetLocal(the_module, 11, expressions[114]); - expressions[116] = BinaryenGetLocal(the_module, 11, 2); + expressions[115] = BinaryenLocalSet(the_module, 11, expressions[114]); + expressions[116] = BinaryenLocalGet(the_module, 11, 2); expressions[117] = BinaryenUnary(the_module, 24, expressions[116]); expressions[118] = BinaryenConst(the_module, BinaryenLiteralInt64(32)); - expressions[119] = BinaryenGetLocal(the_module, 11, 2); + expressions[119] = BinaryenLocalGet(the_module, 11, 2); expressions[120] = BinaryenBinary(the_module, 36, expressions[119], expressions[118]); expressions[121] = BinaryenUnary(the_module, 24, expressions[120]); expressions[122] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[123] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[122]); expressions[124] = BinaryenConst(the_module, BinaryenLiteralInt32(128)); expressions[125] = BinaryenBinary(the_module, 1, expressions[123], expressions[124]); - expressions[126] = BinaryenTeeLocal(the_module, 5, expressions[125]); + expressions[126] = BinaryenLocalTee(the_module, 5, expressions[125]); expressions[127] = BinaryenStore(the_module, 4, 0, 0, expressions[122], expressions[126], 1); - expressions[128] = BinaryenGetLocal(the_module, 5, 1); + expressions[128] = BinaryenLocalGet(the_module, 5, 1); expressions[129] = BinaryenStore(the_module, 4, 0, 0, expressions[128], expressions[117], 1); expressions[130] = BinaryenStore(the_module, 4, 4, 0, expressions[128], expressions[121], 1); { @@ -288,12 +288,12 @@ int main() { expressions[131] = BinaryenBlock(the_module, "bb1", children, 4, BinaryenTypeAuto()); } relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[131]); - expressions[132] = BinaryenGetLocal(the_module, 5, 1); + expressions[132] = BinaryenLocalGet(the_module, 5, 1); expressions[133] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[132]); - expressions[134] = BinaryenSetLocal(the_module, 3, expressions[133]); - expressions[135] = BinaryenGetLocal(the_module, 3, 1); - expressions[136] = BinaryenSetLocal(the_module, 6, expressions[135]); - expressions[137] = BinaryenGetLocal(the_module, 6, 1); + expressions[134] = BinaryenLocalSet(the_module, 3, expressions[133]); + expressions[135] = BinaryenLocalGet(the_module, 3, 1); + expressions[136] = BinaryenLocalSet(the_module, 6, expressions[135]); + expressions[137] = BinaryenLocalGet(the_module, 6, 1); { BinaryenExpressionRef operands[] = { expressions[137] }; expressions[138] = BinaryenCall(the_module, "wasm::print_i32", operands, 1, 0); @@ -303,14 +303,14 @@ int main() { expressions[139] = BinaryenBlock(the_module, "bb2", children, 3, BinaryenTypeAuto()); } relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[139]); - expressions[140] = BinaryenGetLocal(the_module, 3, 1); - expressions[141] = BinaryenSetLocal(the_module, 7, expressions[140]); - expressions[142] = BinaryenGetLocal(the_module, 7, 1); - expressions[143] = BinaryenSetLocal(the_module, 8, expressions[142]); - expressions[144] = BinaryenGetLocal(the_module, 9, 1); + expressions[140] = BinaryenLocalGet(the_module, 3, 1); + expressions[141] = BinaryenLocalSet(the_module, 7, expressions[140]); + expressions[142] = BinaryenLocalGet(the_module, 7, 1); + expressions[143] = BinaryenLocalSet(the_module, 8, expressions[142]); + expressions[144] = BinaryenLocalGet(the_module, 9, 1); expressions[145] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[146] = BinaryenStore(the_module, 4, 0, 0, expressions[145], expressions[144], 1); - expressions[147] = BinaryenGetLocal(the_module, 8, 1); + expressions[147] = BinaryenLocalGet(the_module, 8, 1); expressions[148] = BinaryenReturn(the_module, expressions[147]); { BinaryenExpressionRef children[] = { expressions[141], expressions[143], expressions[146], expressions[148] }; @@ -318,7 +318,7 @@ int main() { } relooperBlocks[3] = RelooperAddBlock(the_relooper, expressions[149]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[0]); - expressions[150] = BinaryenGetLocal(the_module, 5, 1); + expressions[150] = BinaryenLocalGet(the_module, 5, 1); expressions[151] = BinaryenLoad(the_module, 4, 0, 8, 0, 1, expressions[150]); RelooperAddBranch(relooperBlocks[1], relooperBlocks[2], expressions[151], expressions[0]); expressions[152] = BinaryenUnreachable(the_module); @@ -331,7 +331,7 @@ int main() { } expressions[153] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[154] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[153]); - expressions[155] = BinaryenSetLocal(the_module, 9, expressions[154]); + expressions[155] = BinaryenLocalSet(the_module, 9, expressions[154]); relooperBlocks[5] = RelooperAddBlock(the_relooper, expressions[155]); RelooperAddBranch(relooperBlocks[5], relooperBlocks[0], expressions[0], expressions[0]); expressions[156] = RelooperRenderAndDispose(the_relooper, relooperBlocks[5], 10); @@ -372,33 +372,33 @@ int main() { } BinaryenSetStart(the_module, functions[8]); the_relooper = RelooperCreate(the_module); - expressions[165] = BinaryenGetLocal(the_module, 0, 1); - expressions[166] = BinaryenSetLocal(the_module, 2, expressions[165]); - expressions[167] = BinaryenGetLocal(the_module, 1, 1); - expressions[168] = BinaryenSetLocal(the_module, 3, expressions[167]); - expressions[169] = BinaryenGetLocal(the_module, 2, 1); - expressions[170] = BinaryenSetLocal(the_module, 4, expressions[169]); - expressions[171] = BinaryenGetLocal(the_module, 3, 1); - expressions[172] = BinaryenSetLocal(the_module, 5, expressions[171]); - expressions[173] = BinaryenGetLocal(the_module, 4, 1); - expressions[174] = BinaryenGetLocal(the_module, 5, 1); + expressions[165] = BinaryenLocalGet(the_module, 0, 1); + expressions[166] = BinaryenLocalSet(the_module, 2, expressions[165]); + expressions[167] = BinaryenLocalGet(the_module, 1, 1); + expressions[168] = BinaryenLocalSet(the_module, 3, expressions[167]); + expressions[169] = BinaryenLocalGet(the_module, 2, 1); + expressions[170] = BinaryenLocalSet(the_module, 4, expressions[169]); + expressions[171] = BinaryenLocalGet(the_module, 3, 1); + expressions[172] = BinaryenLocalSet(the_module, 5, expressions[171]); + expressions[173] = BinaryenLocalGet(the_module, 4, 1); + expressions[174] = BinaryenLocalGet(the_module, 5, 1); expressions[175] = BinaryenUnary(the_module, 22, expressions[173]); expressions[176] = BinaryenUnary(the_module, 22, expressions[174]); expressions[177] = BinaryenBinary(the_module, 25, expressions[175], expressions[176]); - expressions[178] = BinaryenSetLocal(the_module, 10, expressions[177]); - expressions[179] = BinaryenGetLocal(the_module, 10, 2); + expressions[178] = BinaryenLocalSet(the_module, 10, expressions[177]); + expressions[179] = BinaryenLocalGet(the_module, 10, 2); expressions[180] = BinaryenUnary(the_module, 24, expressions[179]); expressions[181] = BinaryenConst(the_module, BinaryenLiteralInt64(32)); - expressions[182] = BinaryenGetLocal(the_module, 10, 2); + expressions[182] = BinaryenLocalGet(the_module, 10, 2); expressions[183] = BinaryenBinary(the_module, 36, expressions[182], expressions[181]); expressions[184] = BinaryenUnary(the_module, 24, expressions[183]); expressions[185] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[186] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[185]); expressions[187] = BinaryenConst(the_module, BinaryenLiteralInt32(128)); expressions[188] = BinaryenBinary(the_module, 1, expressions[186], expressions[187]); - expressions[189] = BinaryenTeeLocal(the_module, 6, expressions[188]); + expressions[189] = BinaryenLocalTee(the_module, 6, expressions[188]); expressions[190] = BinaryenStore(the_module, 4, 0, 0, expressions[185], expressions[189], 1); - expressions[191] = BinaryenGetLocal(the_module, 6, 1); + expressions[191] = BinaryenLocalGet(the_module, 6, 1); expressions[192] = BinaryenStore(the_module, 4, 0, 0, expressions[191], expressions[180], 1); expressions[193] = BinaryenStore(the_module, 4, 4, 0, expressions[191], expressions[184], 1); { @@ -406,20 +406,20 @@ int main() { expressions[194] = BinaryenBlock(the_module, "bb0", children, 8, BinaryenTypeAuto()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[194]); - expressions[195] = BinaryenGetLocal(the_module, 6, 1); + expressions[195] = BinaryenLocalGet(the_module, 6, 1); expressions[196] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[195]); - expressions[197] = BinaryenSetLocal(the_module, 7, expressions[196]); - expressions[198] = BinaryenGetLocal(the_module, 8, 1); + expressions[197] = BinaryenLocalSet(the_module, 7, expressions[196]); + expressions[198] = BinaryenLocalGet(the_module, 8, 1); expressions[199] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[200] = BinaryenStore(the_module, 4, 0, 0, expressions[199], expressions[198], 1); - expressions[201] = BinaryenGetLocal(the_module, 7, 1); + expressions[201] = BinaryenLocalGet(the_module, 7, 1); expressions[202] = BinaryenReturn(the_module, expressions[201]); { BinaryenExpressionRef children[] = { expressions[197], expressions[200], expressions[202] }; expressions[203] = BinaryenBlock(the_module, "bb1", children, 3, BinaryenTypeAuto()); } relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[203]); - expressions[204] = BinaryenGetLocal(the_module, 6, 1); + expressions[204] = BinaryenLocalGet(the_module, 6, 1); expressions[205] = BinaryenLoad(the_module, 4, 0, 8, 0, 1, expressions[204]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[205], expressions[0]); expressions[206] = BinaryenUnreachable(the_module); @@ -431,7 +431,7 @@ int main() { } expressions[207] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[208] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[207]); - expressions[209] = BinaryenSetLocal(the_module, 8, expressions[208]); + expressions[209] = BinaryenLocalSet(the_module, 8, expressions[208]); relooperBlocks[3] = RelooperAddBlock(the_relooper, expressions[209]); RelooperAddBranch(relooperBlocks[3], relooperBlocks[0], expressions[0], expressions[0]); expressions[210] = RelooperRenderAndDispose(the_relooper, relooperBlocks[3], 9); @@ -441,17 +441,17 @@ int main() { } BinaryenAddFunctionExport(the_module, "_isize_as_tinycore::Add_::add", "_isize_as_tinycore::Add_::add"); the_relooper = RelooperCreate(the_module); - expressions[211] = BinaryenGetLocal(the_module, 0, 1); - expressions[212] = BinaryenSetLocal(the_module, 1, expressions[211]); - expressions[213] = BinaryenGetLocal(the_module, 1, 1); - expressions[214] = BinaryenSetLocal(the_module, 2, expressions[213]); - expressions[215] = BinaryenGetLocal(the_module, 2, 1); + expressions[211] = BinaryenLocalGet(the_module, 0, 1); + expressions[212] = BinaryenLocalSet(the_module, 1, expressions[211]); + expressions[213] = BinaryenLocalGet(the_module, 1, 1); + expressions[214] = BinaryenLocalSet(the_module, 2, expressions[213]); + expressions[215] = BinaryenLocalGet(the_module, 2, 1); expressions[216] = BinaryenUnary(the_module, 20, expressions[215]); - expressions[217] = BinaryenSetLocal(the_module, 3, expressions[216]); - expressions[218] = BinaryenGetLocal(the_module, 4, 1); + expressions[217] = BinaryenLocalSet(the_module, 3, expressions[216]); + expressions[218] = BinaryenLocalGet(the_module, 4, 1); expressions[219] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[220] = BinaryenStore(the_module, 4, 0, 0, expressions[219], expressions[218], 1); - expressions[221] = BinaryenGetLocal(the_module, 3, 1); + expressions[221] = BinaryenLocalGet(the_module, 3, 1); expressions[222] = BinaryenReturn(the_module, expressions[221]); { BinaryenExpressionRef children[] = { expressions[212], expressions[214], expressions[217], expressions[220], expressions[222] }; @@ -464,7 +464,7 @@ int main() { } expressions[224] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[225] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[224]); - expressions[226] = BinaryenSetLocal(the_module, 4, expressions[225]); + expressions[226] = BinaryenLocalSet(the_module, 4, expressions[225]); relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[226]); RelooperAddBranch(relooperBlocks[1], relooperBlocks[0], expressions[0], expressions[0]); expressions[227] = RelooperRenderAndDispose(the_relooper, relooperBlocks[1], 5); @@ -474,22 +474,22 @@ int main() { } BinaryenAddFunctionExport(the_module, "_bool_as_tinycore::Not_::not", "_bool_as_tinycore::Not_::not"); the_relooper = RelooperCreate(the_module); - expressions[228] = BinaryenGetLocal(the_module, 0, 1); - expressions[229] = BinaryenSetLocal(the_module, 2, expressions[228]); - expressions[230] = BinaryenGetLocal(the_module, 1, 1); - expressions[231] = BinaryenSetLocal(the_module, 3, expressions[230]); - expressions[232] = BinaryenGetLocal(the_module, 2, 1); - expressions[233] = BinaryenSetLocal(the_module, 4, expressions[232]); - expressions[234] = BinaryenGetLocal(the_module, 3, 1); - expressions[235] = BinaryenSetLocal(the_module, 5, expressions[234]); - expressions[236] = BinaryenGetLocal(the_module, 4, 1); - expressions[237] = BinaryenGetLocal(the_module, 5, 1); + expressions[228] = BinaryenLocalGet(the_module, 0, 1); + expressions[229] = BinaryenLocalSet(the_module, 2, expressions[228]); + expressions[230] = BinaryenLocalGet(the_module, 1, 1); + expressions[231] = BinaryenLocalSet(the_module, 3, expressions[230]); + expressions[232] = BinaryenLocalGet(the_module, 2, 1); + expressions[233] = BinaryenLocalSet(the_module, 4, expressions[232]); + expressions[234] = BinaryenLocalGet(the_module, 3, 1); + expressions[235] = BinaryenLocalSet(the_module, 5, expressions[234]); + expressions[236] = BinaryenLocalGet(the_module, 4, 1); + expressions[237] = BinaryenLocalGet(the_module, 5, 1); expressions[238] = BinaryenBinary(the_module, 15, expressions[236], expressions[237]); - expressions[239] = BinaryenSetLocal(the_module, 6, expressions[238]); - expressions[240] = BinaryenGetLocal(the_module, 7, 1); + expressions[239] = BinaryenLocalSet(the_module, 6, expressions[238]); + expressions[240] = BinaryenLocalGet(the_module, 7, 1); expressions[241] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[242] = BinaryenStore(the_module, 4, 0, 0, expressions[241], expressions[240], 1); - expressions[243] = BinaryenGetLocal(the_module, 6, 1); + expressions[243] = BinaryenLocalGet(the_module, 6, 1); expressions[244] = BinaryenReturn(the_module, expressions[243]); { BinaryenExpressionRef children[] = { expressions[229], expressions[231], expressions[233], expressions[235], expressions[239], expressions[242], expressions[244] }; @@ -502,7 +502,7 @@ int main() { } expressions[246] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[247] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[246]); - expressions[248] = BinaryenSetLocal(the_module, 7, expressions[247]); + expressions[248] = BinaryenLocalSet(the_module, 7, expressions[247]); relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[248]); RelooperAddBranch(relooperBlocks[1], relooperBlocks[0], expressions[0], expressions[0]); expressions[249] = RelooperRenderAndDispose(the_relooper, relooperBlocks[1], 8); @@ -512,22 +512,22 @@ int main() { } BinaryenAddFunctionExport(the_module, "_i16_as_tinycore::PartialEq_::eq", "_i16_as_tinycore::PartialEq_::eq"); the_relooper = RelooperCreate(the_module); - expressions[250] = BinaryenGetLocal(the_module, 0, 1); - expressions[251] = BinaryenSetLocal(the_module, 2, expressions[250]); - expressions[252] = BinaryenGetLocal(the_module, 1, 1); - expressions[253] = BinaryenSetLocal(the_module, 3, expressions[252]); - expressions[254] = BinaryenGetLocal(the_module, 2, 2); - expressions[255] = BinaryenSetLocal(the_module, 4, expressions[254]); - expressions[256] = BinaryenGetLocal(the_module, 3, 2); - expressions[257] = BinaryenSetLocal(the_module, 5, expressions[256]); - expressions[258] = BinaryenGetLocal(the_module, 4, 2); - expressions[259] = BinaryenGetLocal(the_module, 5, 2); + expressions[250] = BinaryenLocalGet(the_module, 0, 1); + expressions[251] = BinaryenLocalSet(the_module, 2, expressions[250]); + expressions[252] = BinaryenLocalGet(the_module, 1, 1); + expressions[253] = BinaryenLocalSet(the_module, 3, expressions[252]); + expressions[254] = BinaryenLocalGet(the_module, 2, 2); + expressions[255] = BinaryenLocalSet(the_module, 4, expressions[254]); + expressions[256] = BinaryenLocalGet(the_module, 3, 2); + expressions[257] = BinaryenLocalSet(the_module, 5, expressions[256]); + expressions[258] = BinaryenLocalGet(the_module, 4, 2); + expressions[259] = BinaryenLocalGet(the_module, 5, 2); expressions[260] = BinaryenBinary(the_module, 40, expressions[258], expressions[259]); - expressions[261] = BinaryenSetLocal(the_module, 6, expressions[260]); - expressions[262] = BinaryenGetLocal(the_module, 7, 1); + expressions[261] = BinaryenLocalSet(the_module, 6, expressions[260]); + expressions[262] = BinaryenLocalGet(the_module, 7, 1); expressions[263] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[264] = BinaryenStore(the_module, 4, 0, 0, expressions[263], expressions[262], 1); - expressions[265] = BinaryenGetLocal(the_module, 6, 1); + expressions[265] = BinaryenLocalGet(the_module, 6, 1); expressions[266] = BinaryenReturn(the_module, expressions[265]); { BinaryenExpressionRef children[] = { expressions[251], expressions[253], expressions[255], expressions[257], expressions[261], expressions[264], expressions[266] }; @@ -540,7 +540,7 @@ int main() { } expressions[268] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[269] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[268]); - expressions[270] = BinaryenSetLocal(the_module, 7, expressions[269]); + expressions[270] = BinaryenLocalSet(the_module, 7, expressions[269]); relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[270]); RelooperAddBranch(relooperBlocks[1], relooperBlocks[0], expressions[0], expressions[0]); expressions[271] = RelooperRenderAndDispose(the_relooper, relooperBlocks[1], 8); diff --git a/test/example/c-api-unused-mem.cpp b/test/example/c-api-unused-mem.cpp index 49d116fdc..d625e2b51 100644 --- a/test/example/c-api-unused-mem.cpp +++ b/test/example/c-api-unused-mem.cpp @@ -26,7 +26,7 @@ int main() { expressions[1] = BinaryenBlock(the_module, "bb0", children, 0, BinaryenTypeAuto()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[1]); - expressions[2] = BinaryenGetLocal(the_module, 0, 1); + expressions[2] = BinaryenLocalGet(the_module, 0, 1); expressions[3] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[4] = BinaryenStore(the_module, 4, 0, 0, expressions[3], expressions[2], 1); expressions[5] = BinaryenReturn(the_module, expressions[0]); @@ -42,7 +42,7 @@ int main() { } expressions[7] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); expressions[8] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[7]); - expressions[9] = BinaryenSetLocal(the_module, 0, expressions[8]); + expressions[9] = BinaryenLocalSet(the_module, 0, expressions[8]); relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[9]); RelooperAddBranch(relooperBlocks[2], relooperBlocks[0], expressions[0], expressions[0]); expressions[10] = RelooperRenderAndDispose(the_relooper, relooperBlocks[2], 1); diff --git a/test/example/cpp-threads.cpp b/test/example/cpp-threads.cpp index 4a41249e7..07c3049d8 100644 --- a/test/example/cpp-threads.cpp +++ b/test/example/cpp-threads.cpp @@ -16,8 +16,8 @@ void worker() { BinaryenFunctionTypeRef iii = BinaryenAddFunctionType(module, "iii", BinaryenTypeInt32(), params, 2); // Get the 0 and 1 arguments, and add them - BinaryenExpressionRef x = BinaryenGetLocal(module, 0, BinaryenTypeInt32()), - y = BinaryenGetLocal(module, 1, BinaryenTypeInt32()); + BinaryenExpressionRef x = BinaryenLocalGet(module, 0, BinaryenTypeInt32()), + y = BinaryenLocalGet(module, 1, BinaryenTypeInt32()); BinaryenExpressionRef add = BinaryenBinary(module, BinaryenAddInt32(), x, y); BinaryenExpressionRef ret = BinaryenReturn(module, add); diff --git a/test/example/cpp-unit.cpp b/test/example/cpp-unit.cpp index f51ca72b6..e6189d9d1 100644 --- a/test/example/cpp-unit.cpp +++ b/test/example/cpp-unit.cpp @@ -10,7 +10,7 @@ using namespace wasm; int main() { // Some optimizations assume that the cost of a get is zero, e.g. local-cse. - GetLocal get; + LocalGet get; assert(CostAnalyzer(&get).cost == 0); std::cout << "Success.\n"; diff --git a/test/example/relooper-fuzz.c b/test/example/relooper-fuzz.c index 7d8e5aec0..5691c5660 100644 --- a/test/example/relooper-fuzz.c +++ b/test/example/relooper-fuzz.c @@ -70,7 +70,7 @@ int main() { BinaryenExpressionRef args[] = { BinaryenConst(module, BinaryenLiteralInt32(0)) }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; b0 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenTypeAuto())); } @@ -80,7 +80,7 @@ int main() { BinaryenExpressionRef args[] = { BinaryenConst(module, BinaryenLiteralInt32(1)) }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; b1 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenTypeAuto())); } @@ -90,7 +90,7 @@ int main() { BinaryenExpressionRef args[] = { BinaryenConst(module, BinaryenLiteralInt32(2)) }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; b2 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenTypeAuto())); } @@ -100,7 +100,7 @@ int main() { BinaryenExpressionRef args[] = { BinaryenConst(module, BinaryenLiteralInt32(3)) }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; b3 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenTypeAuto())); } @@ -110,7 +110,7 @@ int main() { BinaryenExpressionRef args[] = { BinaryenConst(module, BinaryenLiteralInt32(4)) }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; b4 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenTypeAuto())); } @@ -120,7 +120,7 @@ int main() { BinaryenExpressionRef args[] = { BinaryenConst(module, BinaryenLiteralInt32(5)) }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; b5 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenTypeAuto())); } @@ -130,7 +130,7 @@ int main() { BinaryenExpressionRef args[] = { BinaryenConst(module, BinaryenLiteralInt32(6)) }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; b6 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenTypeAuto())); } @@ -140,7 +140,7 @@ int main() { BinaryenExpressionRef args[] = { BinaryenConst(module, BinaryenLiteralInt32(7)) }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; b7 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenTypeAuto())); } @@ -150,7 +150,7 @@ int main() { BinaryenExpressionRef args[] = { BinaryenConst(module, BinaryenLiteralInt32(8)) }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; b8 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenTypeAuto())); } @@ -159,7 +159,7 @@ int main() { BinaryenEqInt32(), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(2)) ), BinaryenConst(module, BinaryenLiteralInt32(0)) @@ -175,7 +175,7 @@ int main() { BinaryenEqInt32(), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(2)) ), BinaryenConst(module, BinaryenLiteralInt32(0)) @@ -187,7 +187,7 @@ int main() { BinaryenEqInt32(), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(3)) ), BinaryenConst(module, BinaryenLiteralInt32(0)) @@ -197,7 +197,7 @@ int main() { BinaryenEqInt32(), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(3)) ), BinaryenConst(module, BinaryenLiteralInt32(1)) @@ -209,7 +209,7 @@ int main() { BinaryenEqInt32(), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(2)) ), BinaryenConst(module, BinaryenLiteralInt32(0)) diff --git a/test/example/relooper-fuzz1.c b/test/example/relooper-fuzz1.c index 5b6b7f450..55271356c 100644 --- a/test/example/relooper-fuzz1.c +++ b/test/example/relooper-fuzz1.c @@ -84,7 +84,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -100,7 +100,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -116,7 +116,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -132,7 +132,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -148,7 +148,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -164,7 +164,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -180,7 +180,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -196,7 +196,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -212,7 +212,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -228,7 +228,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -241,7 +241,7 @@ int main() { BinaryenEqInt32(), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(4)) ), BinaryenConst(module, BinaryenLiteralInt32(0)) @@ -251,7 +251,7 @@ int main() { BinaryenEqInt32(), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(4)) ), BinaryenConst(module, BinaryenLiteralInt32(2)) @@ -263,7 +263,7 @@ int main() { BinaryenEqInt32(), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(2)) ), BinaryenConst(module, BinaryenLiteralInt32(0)) @@ -277,7 +277,7 @@ int main() { BinaryenEqInt32(), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(3)) ), BinaryenConst(module, BinaryenLiteralInt32(0)) diff --git a/test/example/relooper-fuzz2.c b/test/example/relooper-fuzz2.c index 66ffcef36..4d5af6759 100644 --- a/test/example/relooper-fuzz2.c +++ b/test/example/relooper-fuzz2.c @@ -84,7 +84,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -99,7 +99,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -114,7 +114,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -122,7 +122,7 @@ int main() { BinaryenBlock(module, NULL, list, 2, BinaryenTypeNone()), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(2)) ) ); @@ -136,7 +136,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -144,7 +144,7 @@ int main() { BinaryenBlock(module, NULL, list, 2, BinaryenTypeNone()), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(1)) ) ); @@ -158,7 +158,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -173,7 +173,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -181,7 +181,7 @@ int main() { BinaryenBlock(module, NULL, list, 2, BinaryenTypeNone()), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(1)) ) ); @@ -195,7 +195,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -203,7 +203,7 @@ int main() { BinaryenBlock(module, NULL, list, 2, BinaryenTypeNone()), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(3)) ) ); @@ -217,7 +217,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -232,7 +232,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -313,7 +313,7 @@ int main() { BinaryenEqInt32(), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(2)) ), BinaryenConst(module, BinaryenLiteralInt32(0)) @@ -407,7 +407,7 @@ int main() { BinaryenEqInt32(), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(2)) ), BinaryenConst(module, BinaryenLiteralInt32(0)) diff --git a/test/example/relooper-merge1.c b/test/example/relooper-merge1.c index df08e60b5..320e73efa 100644 --- a/test/example/relooper-merge1.c +++ b/test/example/relooper-merge1.c @@ -84,7 +84,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -92,7 +92,7 @@ int main() { BinaryenBlock(module, NULL, list, 2, BinaryenTypeNone()), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(1)) ) ); @@ -106,7 +106,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -121,7 +121,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -136,7 +136,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -150,7 +150,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; diff --git a/test/example/relooper-merge2.c b/test/example/relooper-merge2.c index 2784b4e71..9387d572b 100644 --- a/test/example/relooper-merge2.c +++ b/test/example/relooper-merge2.c @@ -84,7 +84,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -92,7 +92,7 @@ int main() { BinaryenBlock(module, NULL, list, 2, BinaryenTypeNone()), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(1)) ) ); @@ -106,7 +106,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -121,7 +121,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -136,7 +136,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -150,7 +150,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; diff --git a/test/example/relooper-merge3.c b/test/example/relooper-merge3.c index a992c0d47..1bb650391 100644 --- a/test/example/relooper-merge3.c +++ b/test/example/relooper-merge3.c @@ -84,7 +84,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -92,7 +92,7 @@ int main() { BinaryenBlock(module, NULL, list, 2, BinaryenTypeNone()), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(1)) ) ); @@ -106,7 +106,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -121,7 +121,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -136,7 +136,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -150,7 +150,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; diff --git a/test/example/relooper-merge4.c b/test/example/relooper-merge4.c index d8d78d082..86ba272f2 100644 --- a/test/example/relooper-merge4.c +++ b/test/example/relooper-merge4.c @@ -84,7 +84,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -92,7 +92,7 @@ int main() { BinaryenBlock(module, NULL, list, 2, BinaryenTypeNone()), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(1)) ) ); @@ -106,7 +106,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -121,7 +121,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -136,7 +136,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -150,7 +150,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; diff --git a/test/example/relooper-merge5.c b/test/example/relooper-merge5.c index 8c4c25ad0..67048159f 100644 --- a/test/example/relooper-merge5.c +++ b/test/example/relooper-merge5.c @@ -84,7 +84,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -92,7 +92,7 @@ int main() { BinaryenBlock(module, NULL, list, 2, BinaryenTypeNone()), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(1)) ) ); @@ -106,7 +106,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -121,7 +121,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -136,7 +136,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -150,7 +150,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; diff --git a/test/example/relooper-merge6.c b/test/example/relooper-merge6.c index 7576a6c1e..d51504d68 100644 --- a/test/example/relooper-merge6.c +++ b/test/example/relooper-merge6.c @@ -84,7 +84,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -92,7 +92,7 @@ int main() { BinaryenBlock(module, NULL, list, 2, BinaryenTypeNone()), BinaryenBinary(module, BinaryenRemUInt32(), - BinaryenGetLocal(module, 0, BinaryenTypeInt32()), + BinaryenLocalGet(module, 0, BinaryenTypeInt32()), BinaryenConst(module, BinaryenLiteralInt32(1)) ) ); @@ -106,7 +106,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -121,7 +121,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -136,7 +136,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; @@ -150,7 +150,7 @@ int main() { }; BinaryenExpressionRef list[] = { BinaryenCall(module, "print", args, 1, BinaryenTypeNone()), - BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenLocalSet(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenTypeInt32())) }; diff --git a/test/grow_memory.wast b/test/grow_memory.wast index 263c90515..002247713 100644 --- a/test/grow_memory.wast +++ b/test/grow_memory.wast @@ -6,12 +6,12 @@ (export "grow" (func $0)) (export "current" (func $1)) (func $0 (; 0 ;) (type $0) (param $var$0 i32) (result i32) - (grow_memory + (memory.grow (local.get $var$0) ) ) (func $1 (; 1 ;) (type $1) (result i32) - (current_memory) + (memory.size) ) ) diff --git a/test/grow_memory.wast.from-wast b/test/grow_memory.wast.from-wast index 634368962..383591320 100644 --- a/test/grow_memory.wast.from-wast +++ b/test/grow_memory.wast.from-wast @@ -6,11 +6,11 @@ (export "grow" (func $0)) (export "current" (func $1)) (func $0 (; 0 ;) (type $0) (param $var$0 i32) (result i32) - (grow_memory + (memory.grow (local.get $var$0) ) ) (func $1 (; 1 ;) (type $1) (result i32) - (current_memory) + (memory.size) ) ) diff --git a/test/grow_memory.wast.fromBinary b/test/grow_memory.wast.fromBinary index f822a95f6..706495c97 100644 --- a/test/grow_memory.wast.fromBinary +++ b/test/grow_memory.wast.fromBinary @@ -6,12 +6,12 @@ (export "grow" (func $0)) (export "current" (func $1)) (func $0 (; 0 ;) (type $0) (param $0 i32) (result i32) - (grow_memory + (memory.grow (local.get $0) ) ) (func $1 (; 1 ;) (type $1) (result i32) - (current_memory) + (memory.size) ) ) diff --git a/test/grow_memory.wast.fromBinary.noDebugInfo b/test/grow_memory.wast.fromBinary.noDebugInfo index f822a95f6..706495c97 100644 --- a/test/grow_memory.wast.fromBinary.noDebugInfo +++ b/test/grow_memory.wast.fromBinary.noDebugInfo @@ -6,12 +6,12 @@ (export "grow" (func $0)) (export "current" (func $1)) (func $0 (; 0 ;) (type $0) (param $0 i32) (result i32) - (grow_memory + (memory.grow (local.get $0) ) ) (func $1 (; 1 ;) (type $1) (result i32) - (current_memory) + (memory.size) ) ) diff --git a/test/lld/duplicate_imports.wast.out b/test/lld/duplicate_imports.wast.out index be9d7f77a..3a9798679 100644 --- a/test/lld/duplicate_imports.wast.out +++ b/test/lld/duplicate_imports.wast.out @@ -61,7 +61,7 @@ ) ) (func $__growWasmMemory (; 9 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/lld/em_asm.wast.mem.out b/test/lld/em_asm.wast.mem.out index 2aac1ef36..4e16c7feb 100644 --- a/test/lld/em_asm.wast.mem.out +++ b/test/lld/em_asm.wast.mem.out @@ -217,7 +217,7 @@ ) ) (func $__growWasmMemory (; 11 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/lld/em_asm.wast.out b/test/lld/em_asm.wast.out index 5917fb187..43d68677b 100644 --- a/test/lld/em_asm.wast.out +++ b/test/lld/em_asm.wast.out @@ -218,7 +218,7 @@ ) ) (func $__growWasmMemory (; 11 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/lld/em_asm_O0.wast.out b/test/lld/em_asm_O0.wast.out index cb5cc1961..7fc057079 100644 --- a/test/lld/em_asm_O0.wast.out +++ b/test/lld/em_asm_O0.wast.out @@ -78,7 +78,7 @@ ) ) (func $__growWasmMemory (; 8 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/lld/em_asm_table.wast.out b/test/lld/em_asm_table.wast.out index 50f24876e..a3ce87bba 100644 --- a/test/lld/em_asm_table.wast.out +++ b/test/lld/em_asm_table.wast.out @@ -41,7 +41,7 @@ ) ) (func $__growWasmMemory (; 5 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/lld/em_js_O0.wast.out b/test/lld/em_js_O0.wast.out index 02d4fed07..697a5082f 100644 --- a/test/lld/em_js_O0.wast.out +++ b/test/lld/em_js_O0.wast.out @@ -37,7 +37,7 @@ ) ) (func $__growWasmMemory (; 3 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/lld/hello_world.wast.mem.out b/test/lld/hello_world.wast.mem.out index 834f4945a..b3c6ad55c 100644 --- a/test/lld/hello_world.wast.mem.out +++ b/test/lld/hello_world.wast.mem.out @@ -57,7 +57,7 @@ ) ) (func $__growWasmMemory (; 7 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/lld/hello_world.wast.out b/test/lld/hello_world.wast.out index 67fd6428b..b20f4e6ca 100644 --- a/test/lld/hello_world.wast.out +++ b/test/lld/hello_world.wast.out @@ -58,7 +58,7 @@ ) ) (func $__growWasmMemory (; 7 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/lld/init.wast.out b/test/lld/init.wast.out index 645f78f67..7b5f43de2 100644 --- a/test/lld/init.wast.out +++ b/test/lld/init.wast.out @@ -70,7 +70,7 @@ ) ) (func $__growWasmMemory (; 8 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/lld/recursive.wast.out b/test/lld/recursive.wast.out index 8f81cdc91..18b9c7db0 100644 --- a/test/lld/recursive.wast.out +++ b/test/lld/recursive.wast.out @@ -115,7 +115,7 @@ ) ) (func $__growWasmMemory (; 8 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/lld/reserved_func_ptr.wast.out b/test/lld/reserved_func_ptr.wast.out index 3ddf2f0ce..0244ee522 100644 --- a/test/lld/reserved_func_ptr.wast.out +++ b/test/lld/reserved_func_ptr.wast.out @@ -142,7 +142,7 @@ ) ) (func $__growWasmMemory (; 8 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/memorygrowth-minimal.fromasm b/test/memorygrowth-minimal.fromasm index 39dc3622b..fdc4bf41d 100644 --- a/test/memorygrowth-minimal.fromasm +++ b/test/memorygrowth-minimal.fromasm @@ -4,7 +4,7 @@ (import "env" "__memory_base" (global $__memory_base i32)) (export "__growWasmMemory" (func $__growWasmMemory)) (func $__growWasmMemory (; 0 ;) (; has Stack IR ;) (param $0 i32) (result i32) - (grow_memory + (memory.grow (local.get $0) ) ) diff --git a/test/memorygrowth-minimal.fromasm.clamp b/test/memorygrowth-minimal.fromasm.clamp index 39dc3622b..fdc4bf41d 100644 --- a/test/memorygrowth-minimal.fromasm.clamp +++ b/test/memorygrowth-minimal.fromasm.clamp @@ -4,7 +4,7 @@ (import "env" "__memory_base" (global $__memory_base i32)) (export "__growWasmMemory" (func $__growWasmMemory)) (func $__growWasmMemory (; 0 ;) (; has Stack IR ;) (param $0 i32) (result i32) - (grow_memory + (memory.grow (local.get $0) ) ) diff --git a/test/memorygrowth-minimal.fromasm.clamp.no-opts b/test/memorygrowth-minimal.fromasm.clamp.no-opts index 7a07ac465..70f1600f3 100644 --- a/test/memorygrowth-minimal.fromasm.clamp.no-opts +++ b/test/memorygrowth-minimal.fromasm.clamp.no-opts @@ -5,7 +5,7 @@ (import "env" "__table_base" (global $__table_base i32)) (export "__growWasmMemory" (func $__growWasmMemory)) (func $__growWasmMemory (; 0 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/memorygrowth-minimal.fromasm.imprecise b/test/memorygrowth-minimal.fromasm.imprecise index 95377f497..1c70223ec 100644 --- a/test/memorygrowth-minimal.fromasm.imprecise +++ b/test/memorygrowth-minimal.fromasm.imprecise @@ -2,7 +2,7 @@ (import "env" "memory" (memory $memory 256)) (export "__growWasmMemory" (func $__growWasmMemory)) (func $__growWasmMemory (; 0 ;) (; has Stack IR ;) (param $0 i32) (result i32) - (grow_memory + (memory.grow (local.get $0) ) ) diff --git a/test/memorygrowth-minimal.fromasm.imprecise.no-opts b/test/memorygrowth-minimal.fromasm.imprecise.no-opts index 7a07ac465..70f1600f3 100644 --- a/test/memorygrowth-minimal.fromasm.imprecise.no-opts +++ b/test/memorygrowth-minimal.fromasm.imprecise.no-opts @@ -5,7 +5,7 @@ (import "env" "__table_base" (global $__table_base i32)) (export "__growWasmMemory" (func $__growWasmMemory)) (func $__growWasmMemory (; 0 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/memorygrowth-minimal.fromasm.no-opts b/test/memorygrowth-minimal.fromasm.no-opts index 7a07ac465..70f1600f3 100644 --- a/test/memorygrowth-minimal.fromasm.no-opts +++ b/test/memorygrowth-minimal.fromasm.no-opts @@ -5,7 +5,7 @@ (import "env" "__table_base" (global $__table_base i32)) (export "__growWasmMemory" (func $__growWasmMemory)) (func $__growWasmMemory (; 0 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm index 349fddb52..13231d482 100644 --- a/test/memorygrowth.fromasm +++ b/test/memorygrowth.fromasm @@ -51,7 +51,7 @@ (export "dynCall_iiii" (func $lb)) (export "dynCall_vi" (func $mb)) (func $__growWasmMemory (; 12 ;) (; has Stack IR ;) (param $0 i32) (result i32) - (grow_memory + (memory.grow (local.get $0) ) ) diff --git a/test/memorygrowth.fromasm.clamp b/test/memorygrowth.fromasm.clamp index 349fddb52..13231d482 100644 --- a/test/memorygrowth.fromasm.clamp +++ b/test/memorygrowth.fromasm.clamp @@ -51,7 +51,7 @@ (export "dynCall_iiii" (func $lb)) (export "dynCall_vi" (func $mb)) (func $__growWasmMemory (; 12 ;) (; has Stack IR ;) (param $0 i32) (result i32) - (grow_memory + (memory.grow (local.get $0) ) ) diff --git a/test/memorygrowth.fromasm.clamp.no-opts b/test/memorygrowth.fromasm.clamp.no-opts index 4ab38f888..f18677923 100644 --- a/test/memorygrowth.fromasm.clamp.no-opts +++ b/test/memorygrowth.fromasm.clamp.no-opts @@ -79,7 +79,7 @@ (export "dynCall_iiii" (func $lb)) (export "dynCall_vi" (func $mb)) (func $__growWasmMemory (; 12 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/memorygrowth.fromasm.imprecise b/test/memorygrowth.fromasm.imprecise index bf7be5678..d6011b1c7 100644 --- a/test/memorygrowth.fromasm.imprecise +++ b/test/memorygrowth.fromasm.imprecise @@ -49,7 +49,7 @@ (export "dynCall_iiii" (func $lb)) (export "dynCall_vi" (func $mb)) (func $__growWasmMemory (; 12 ;) (; has Stack IR ;) (param $0 i32) (result i32) - (grow_memory + (memory.grow (local.get $0) ) ) diff --git a/test/memorygrowth.fromasm.imprecise.no-opts b/test/memorygrowth.fromasm.imprecise.no-opts index 9a0b46da0..ef39f5e2e 100644 --- a/test/memorygrowth.fromasm.imprecise.no-opts +++ b/test/memorygrowth.fromasm.imprecise.no-opts @@ -79,7 +79,7 @@ (export "dynCall_iiii" (func $lb)) (export "dynCall_vi" (func $mb)) (func $__growWasmMemory (; 12 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/memorygrowth.fromasm.no-opts b/test/memorygrowth.fromasm.no-opts index 4ab38f888..f18677923 100644 --- a/test/memorygrowth.fromasm.no-opts +++ b/test/memorygrowth.fromasm.no-opts @@ -79,7 +79,7 @@ (export "dynCall_iiii" (func $lb)) (export "dynCall_vi" (func $mb)) (func $__growWasmMemory (; 12 ;) (param $newSize i32) (result i32) - (grow_memory + (memory.grow (local.get $newSize) ) ) diff --git a/test/passes/O4_disable-bulk-memory.txt b/test/passes/O4_disable-bulk-memory.txt index 1b01f1c28..455d8101d 100644 --- a/test/passes/O4_disable-bulk-memory.txt +++ b/test/passes/O4_disable-bulk-memory.txt @@ -66,14 +66,14 @@ ) (i32.shl (local.tee $2 - (current_memory) + (memory.size) ) (i32.const 16) ) ) (if (i32.lt_s - (grow_memory + (memory.grow (select (local.get $2) (local.tee $3 @@ -101,7 +101,7 @@ ) (if (i32.lt_s - (grow_memory + (memory.grow (local.get $3) ) (i32.const 0) diff --git a/test/passes/O4_disable-bulk-memory.wast b/test/passes/O4_disable-bulk-memory.wast index cdea2da96..9a8c38b49 100644 --- a/test/passes/O4_disable-bulk-memory.wast +++ b/test/passes/O4_disable-bulk-memory.wast @@ -224,7 +224,7 @@ ) ) (local.set $5 - (current_memory) + (memory.size) ) (if (i32.gt_u @@ -269,14 +269,14 @@ ) (if (i32.lt_s - (grow_memory + (memory.grow (local.get $3) ) (i32.const 0) ) (if (i32.lt_s - (grow_memory + (memory.grow (local.get $2) ) (i32.const 0) diff --git a/test/passes/dce.wast b/test/passes/dce.wast index 3d12a4989..0d3b04557 100644 --- a/test/passes/dce.wast +++ b/test/passes/dce.wast @@ -481,7 +481,7 @@ (func $unreachable-brs-3 (result i32) (block $label$0 (result i32) (br $label$0 - (grow_memory + (memory.grow (br $label$0 (i32.const 18) ) diff --git a/test/passes/duplicate-function-elimination_optimize-level=1.txt b/test/passes/duplicate-function-elimination_optimize-level=1.txt index 4ed278af8..baebf9ea8 100644 --- a/test/passes/duplicate-function-elimination_optimize-level=1.txt +++ b/test/passes/duplicate-function-elimination_optimize-level=1.txt @@ -1017,7 +1017,7 @@ (memory $0 0) (func $erase (; 0 ;) (type $0) (drop - (current_memory) + (memory.size) ) ) ) @@ -1026,7 +1026,7 @@ (memory $0 0) (func $erase (; 0 ;) (type $0) (drop - (grow_memory + (memory.grow (i32.const 10) ) ) @@ -1037,14 +1037,14 @@ (memory $0 0) (func $keep (; 0 ;) (type $0) (drop - (grow_memory + (memory.grow (i32.const 10) ) ) ) (func $other (; 1 ;) (type $0) (drop - (grow_memory + (memory.grow (i32.const 11) ) ) @@ -1055,12 +1055,12 @@ (memory $0 0) (func $keep (; 0 ;) (type $0) (drop - (current_memory) + (memory.size) ) ) (func $other (; 1 ;) (type $0) (drop - (grow_memory + (memory.grow (i32.const 10) ) ) diff --git a/test/passes/duplicate-function-elimination_optimize-level=1.wast b/test/passes/duplicate-function-elimination_optimize-level=1.wast index ce33b7a91..5b42a6ba5 100644 --- a/test/passes/duplicate-function-elimination_optimize-level=1.wast +++ b/test/passes/duplicate-function-elimination_optimize-level=1.wast @@ -1158,12 +1158,12 @@ (type $0 (func)) (func $erase (type $0) (drop - (current_memory) + (memory.size) ) ) (func $other (type $0) (drop - (current_memory) + (memory.size) ) ) ) @@ -1172,14 +1172,14 @@ (type $0 (func)) (func $erase (type $0) (drop - (grow_memory + (memory.grow (i32.const 10) ) ) ) (func $other (type $0) (drop - (grow_memory + (memory.grow (i32.const 10) ) ) @@ -1190,14 +1190,14 @@ (type $0 (func)) (func $keep (type $0) (drop - (grow_memory + (memory.grow (i32.const 10) ) ) ) (func $other (type $0) (drop - (grow_memory + (memory.grow (i32.const 11) ) ) @@ -1208,12 +1208,12 @@ (type $0 (func)) (func $keep (type $0) (drop - (current_memory) + (memory.size) ) ) (func $other (type $0) (drop - (grow_memory + (memory.grow (i32.const 10) ) ) diff --git a/test/passes/duplicate-function-elimination_optimize-level=2.txt b/test/passes/duplicate-function-elimination_optimize-level=2.txt index 3232613b0..0eb2d00cc 100644 --- a/test/passes/duplicate-function-elimination_optimize-level=2.txt +++ b/test/passes/duplicate-function-elimination_optimize-level=2.txt @@ -1014,7 +1014,7 @@ (memory $0 0) (func $erase (; 0 ;) (type $0) (drop - (current_memory) + (memory.size) ) ) ) @@ -1023,7 +1023,7 @@ (memory $0 0) (func $erase (; 0 ;) (type $0) (drop - (grow_memory + (memory.grow (i32.const 10) ) ) @@ -1034,14 +1034,14 @@ (memory $0 0) (func $keep (; 0 ;) (type $0) (drop - (grow_memory + (memory.grow (i32.const 10) ) ) ) (func $other (; 1 ;) (type $0) (drop - (grow_memory + (memory.grow (i32.const 11) ) ) @@ -1052,12 +1052,12 @@ (memory $0 0) (func $keep (; 0 ;) (type $0) (drop - (current_memory) + (memory.size) ) ) (func $other (; 1 ;) (type $0) (drop - (grow_memory + (memory.grow (i32.const 10) ) ) diff --git a/test/passes/duplicate-function-elimination_optimize-level=2.wast b/test/passes/duplicate-function-elimination_optimize-level=2.wast index ce33b7a91..5b42a6ba5 100644 --- a/test/passes/duplicate-function-elimination_optimize-level=2.wast +++ b/test/passes/duplicate-function-elimination_optimize-level=2.wast @@ -1158,12 +1158,12 @@ (type $0 (func)) (func $erase (type $0) (drop - (current_memory) + (memory.size) ) ) (func $other (type $0) (drop - (current_memory) + (memory.size) ) ) ) @@ -1172,14 +1172,14 @@ (type $0 (func)) (func $erase (type $0) (drop - (grow_memory + (memory.grow (i32.const 10) ) ) ) (func $other (type $0) (drop - (grow_memory + (memory.grow (i32.const 10) ) ) @@ -1190,14 +1190,14 @@ (type $0 (func)) (func $keep (type $0) (drop - (grow_memory + (memory.grow (i32.const 10) ) ) ) (func $other (type $0) (drop - (grow_memory + (memory.grow (i32.const 11) ) ) @@ -1208,12 +1208,12 @@ (type $0 (func)) (func $keep (type $0) (drop - (current_memory) + (memory.size) ) ) (func $other (type $0) (drop - (grow_memory + (memory.grow (i32.const 10) ) ) diff --git a/test/passes/flatten.txt b/test/passes/flatten.txt index 7b7214374..560e5762b 100644 --- a/test/passes/flatten.txt +++ b/test/passes/flatten.txt @@ -1558,7 +1558,7 @@ (i32.const 18) ) (br $label$0) - (grow_memory + (memory.grow (unreachable) ) (unreachable) diff --git a/test/passes/flatten.wast b/test/passes/flatten.wast index c655ebd17..dbfc8165c 100644 --- a/test/passes/flatten.wast +++ b/test/passes/flatten.wast @@ -704,7 +704,7 @@ (func $unreachable-brs-3 (result i32) (block $label$0 (result i32) (br $label$0 - (grow_memory + (memory.grow (br $label$0 (i32.const 18) ) diff --git a/test/passes/remove-unused-module-elements_enable-threads.txt b/test/passes/remove-unused-module-elements_enable-threads.txt index c2471e743..99820cc52 100644 --- a/test/passes/remove-unused-module-elements_enable-threads.txt +++ b/test/passes/remove-unused-module-elements_enable-threads.txt @@ -181,7 +181,7 @@ (memory $0 23 256) (export "user" (func $user)) (func $user (; 0 ;) (type $0) (result i32) - (grow_memory + (memory.grow (i32.const 0) ) ) @@ -191,7 +191,7 @@ (import "env" "memory" (memory $0 256)) (export "user" (func $user)) (func $user (; 0 ;) (type $0) (result i32) - (grow_memory + (memory.grow (i32.const 0) ) ) @@ -201,7 +201,7 @@ (memory $0 23 256) (export "user" (func $user)) (func $user (; 0 ;) (type $0) (result i32) - (current_memory) + (memory.size) ) ) (module diff --git a/test/passes/remove-unused-module-elements_enable-threads.wast b/test/passes/remove-unused-module-elements_enable-threads.wast index 4bd5ccf10..7cb4423b5 100644 --- a/test/passes/remove-unused-module-elements_enable-threads.wast +++ b/test/passes/remove-unused-module-elements_enable-threads.wast @@ -147,21 +147,21 @@ (memory $0 23 256) (export "user" $user) (func $user (result i32) - (grow_memory (i32.const 0)) + (memory.grow (i32.const 0)) ) ) (module ;; more use checks (import "env" "memory" (memory $0 256)) (export "user" $user) (func $user (result i32) - (grow_memory (i32.const 0)) + (memory.grow (i32.const 0)) ) ) (module ;; more use checks (memory $0 23 256) (export "user" $user) (func $user (result i32) - (current_memory) + (memory.size) ) ) (module diff --git a/test/passes/remove-unused-nonfunction-module-elements_enable-threads.txt b/test/passes/remove-unused-nonfunction-module-elements_enable-threads.txt index 2d9609efa..1ac7e5228 100644 --- a/test/passes/remove-unused-nonfunction-module-elements_enable-threads.txt +++ b/test/passes/remove-unused-nonfunction-module-elements_enable-threads.txt @@ -196,7 +196,7 @@ (memory $0 23 256) (export "user" (func $user)) (func $user (; 0 ;) (type $0) (result i32) - (grow_memory + (memory.grow (i32.const 0) ) ) @@ -206,7 +206,7 @@ (import "env" "memory" (memory $0 256)) (export "user" (func $user)) (func $user (; 0 ;) (type $0) (result i32) - (grow_memory + (memory.grow (i32.const 0) ) ) @@ -216,7 +216,7 @@ (memory $0 23 256) (export "user" (func $user)) (func $user (; 0 ;) (type $0) (result i32) - (current_memory) + (memory.size) ) ) (module diff --git a/test/passes/remove-unused-nonfunction-module-elements_enable-threads.wast b/test/passes/remove-unused-nonfunction-module-elements_enable-threads.wast index 4370328ce..6024e1bc1 100644 --- a/test/passes/remove-unused-nonfunction-module-elements_enable-threads.wast +++ b/test/passes/remove-unused-nonfunction-module-elements_enable-threads.wast @@ -147,21 +147,21 @@ (memory $0 23 256) (export "user" $user) (func $user (result i32) - (grow_memory (i32.const 0)) + (memory.grow (i32.const 0)) ) ) (module ;; more use checks (import "env" "memory" (memory $0 256)) (export "user" $user) (func $user (result i32) - (grow_memory (i32.const 0)) + (memory.grow (i32.const 0)) ) ) (module ;; more use checks (memory $0 23 256) (export "user" $user) (func $user (result i32) - (current_memory) + (memory.size) ) ) (module diff --git a/test/passes/simplify-locals_all-features.txt b/test/passes/simplify-locals_all-features.txt index 7a6de1873..d33dd9769 100644 --- a/test/passes/simplify-locals_all-features.txt +++ b/test/passes/simplify-locals_all-features.txt @@ -1150,7 +1150,7 @@ (local $x i32) (local.set $x (i32.load - (grow_memory + (memory.grow (i32.const 1) ) ) @@ -1214,7 +1214,7 @@ (local $x i32) (local.set $x (i32.load - (grow_memory + (memory.grow (i32.const 1) ) ) diff --git a/test/passes/simplify-locals_all-features.wast b/test/passes/simplify-locals_all-features.wast index 34a93d442..ff362db64 100644 --- a/test/passes/simplify-locals_all-features.wast +++ b/test/passes/simplify-locals_all-features.wast @@ -1105,9 +1105,9 @@ (drop (i32.load (i32.const 1028))) (local.get $x) ) - (func $nonatomic-growmem (result i32) ;; grow_memory is modeled as modifying memory + (func $nonatomic-growmem (result i32) ;; memory.grow is modeled as modifying memory (local $x i32) - (local.set $x (i32.load (grow_memory (i32.const 1)))) + (local.set $x (i32.load (memory.grow (i32.const 1)))) (drop (i32.load (i32.const 1028))) (local.get $x) ) @@ -1129,9 +1129,9 @@ (drop (i32.load (i32.const 1028))) (drop (local.get $x)) ) - (func $atomic-growmem (result i32) ;; grow_memory is modeled as modifying memory + (func $atomic-growmem (result i32) ;; memory.grow is modeled as modifying memory (local $x i32) - (local.set $x (i32.load (grow_memory (i32.const 1)))) + (local.set $x (i32.load (memory.grow (i32.const 1)))) (drop (i32.atomic.load (i32.const 1028))) (local.get $x) ) diff --git a/test/spec/br.wast b/test/spec/br.wast index 99b6605c8..5937375dd 100644 --- a/test/spec/br.wast +++ b/test/spec/br.wast @@ -195,8 +195,8 @@ (block i32 (i32.wrap_i64 (br 0 (i32.const 41)))) ) - (func (export "as-grow_memory-size") (result i32) - (block i32 (grow_memory (br 0 (i32.const 40)))) + (func (export "as-memory.grow-size") (result i32) + (block i32 (memory.grow (br 0 (i32.const 40)))) ) (func (export "nested-block-value") (result i32) @@ -355,7 +355,7 @@ (assert_return (invoke "as-convert-operand") (i32.const 41)) -(assert_return (invoke "as-grow_memory-size") (i32.const 40)) +(assert_return (invoke "as-memory.grow-size") (i32.const 40)) (assert_return (invoke "nested-block-value") (i32.const 9)) (assert_return (invoke "nested-br-value") (i32.const 9)) diff --git a/test/spec/br_table.wast b/test/spec/br_table.wast index 2f3f2aa7c..663bb9ecb 100644 --- a/test/spec/br_table.wast +++ b/test/spec/br_table.wast @@ -1090,8 +1090,8 @@ (block i32 (i32.wrap_i64 (br_table 0 (i32.const 41) (i32.const 0)))) ) - (func (export "as-grow_memory-size") (result i32) - (block i32 (grow_memory (br_table 0 (i32.const 40) (i32.const 0)))) + (func (export "as-memory.grow-size") (result i32) + (block i32 (memory.grow (br_table 0 (i32.const 40) (i32.const 0)))) ) (func (export "nested-block-value") (param i32) (result i32) @@ -1331,7 +1331,7 @@ (assert_return (invoke "as-convert-operand") (i32.const 41)) -(assert_return (invoke "as-grow_memory-size") (i32.const 40)) +(assert_return (invoke "as-memory.grow-size") (i32.const 40)) (assert_return (invoke "nested-block-value" (i32.const 0)) (i32.const 19)) (assert_return (invoke "nested-block-value" (i32.const 1)) (i32.const 17)) diff --git a/test/spec/imports.wast b/test/spec/imports.wast index f0ae31340..19ea25202 100644 --- a/test/spec/imports.wast +++ b/test/spec/imports.wast @@ -215,7 +215,7 @@ (module (import "spectest" "memory" (memory 0 3)) ;; actual has max size 2 - (func (export "grow") (param i32) (result i32) (grow_memory (local.get 0))) + (func (export "grow") (param i32) (result i32) (memory.grow (local.get 0))) ) (assert_return (invoke "grow" (i32.const 0)) (i32.const 1)) (assert_return (invoke "grow" (i32.const 1)) (i32.const 1)) diff --git a/test/spec/linking.wast b/test/spec/linking.wast index fafaf2746..653433ac6 100644 --- a/test/spec/linking.wast +++ b/test/spec/linking.wast @@ -201,7 +201,7 @@ (memory (import "Mm" "mem") 1 8) (func (export "grow") (param $a i32) (result i32) - (grow_memory (local.get 0)) + (memory.grow (local.get 0)) ) ) diff --git a/test/spec/memory_trap.wast b/test/spec/memory_trap.wast index 2a4649126..fe2dee7fa 100644 --- a/test/spec/memory_trap.wast +++ b/test/spec/memory_trap.wast @@ -2,7 +2,7 @@ (memory 1) (func $addr_limit (result i32) - (i32.mul (current_memory) (i32.const 0x10000)) + (i32.mul (memory.size) (i32.const 0x10000)) ) (func (export "store") (param $i i32) (param $v i32) @@ -13,8 +13,8 @@ (i32.load (i32.add (call $addr_limit) (local.get $i))) ) - (func (export "grow_memory") (param i32) (result i32) - (grow_memory (local.get 0)) + (func (export "memory.grow") (param i32) (result i32) + (memory.grow (local.get 0)) ) ) @@ -30,4 +30,4 @@ (assert_trap (invoke "load" (i32.const 0)) "out of bounds memory access") (assert_trap (invoke "store" (i32.const 0x80000000) (i32.const 13)) "out of bounds memory access") (assert_trap (invoke "load" (i32.const 0x80000000)) "out of bounds memory access") -(assert_return (invoke "grow_memory" (i32.const 0x10001)) (i32.const -1)) +(assert_return (invoke "memory.grow" (i32.const 0x10001)) (i32.const -1)) diff --git a/test/spec/nop.wast b/test/spec/nop.wast index aebe43819..2348fdc1e 100644 --- a/test/spec/nop.wast +++ b/test/spec/nop.wast @@ -168,11 +168,11 @@ (nop) (local.get 0) (nop) (nop) (local.get 0) (nop) (nop) (i32.le_s) ) - (func (export "as-grow_memory-last") (param i32) (result i32) - (local.get 0) (nop) (grow_memory) + (func (export "as-memory.grow-last") (param i32) (result i32) + (local.get 0) (nop) (memory.grow) ) - (func (export "as-grow_memory-everywhere") (param i32) (result i32) - (nop) (nop) (local.get 0) (nop) (nop) (grow_memory) + (func (export "as-memory.grow-everywhere") (param i32) (result i32) + (nop) (nop) (local.get 0) (nop) (nop) (memory.grow) ) ) @@ -239,8 +239,8 @@ (assert_return (invoke "as-compare-last" (i32.const 3)) (i32.const 0)) (assert_return (invoke "as-compare-everywhere" (i32.const 3)) (i32.const 1)) -(assert_return (invoke "as-grow_memory-last" (i32.const 2)) (i32.const 1)) -(assert_return (invoke "as-grow_memory-everywhere" (i32.const 12)) (i32.const 3)) +(assert_return (invoke "as-memory.grow-last" (i32.const 2)) (i32.const 1)) +(assert_return (invoke "as-memory.grow-everywhere" (i32.const 12)) (i32.const 3)) (assert_invalid (module (func $type-i32 (result i32) (nop))) diff --git a/test/spec/resizing.wast b/test/spec/resizing.wast index b340bb4ea..7a677c9fa 100644 --- a/test/spec/resizing.wast +++ b/test/spec/resizing.wast @@ -7,8 +7,8 @@ (func (export "load_at_page_size") (result i32) (i32.load (i32.const 0x10000))) (func (export "store_at_page_size") (i32.store (i32.const 0x10000) (i32.const 3))) - (func (export "grow") (param $sz i32) (result i32) (grow_memory (local.get $sz))) - (func (export "size") (result i32) (current_memory)) + (func (export "grow") (param $sz i32) (result i32) (memory.grow (local.get $sz))) + (func (export "size") (result i32) (memory.size)) ) (assert_return (invoke "size") (i32.const 0)) @@ -35,7 +35,7 @@ (module (memory 0) - (func (export "grow") (param i32) (result i32) (grow_memory (local.get 0))) + (func (export "grow") (param i32) (result i32) (memory.grow (local.get 0))) ) (assert_return (invoke "grow" (i32.const 0)) (i32.const 0)) @@ -46,7 +46,7 @@ (module (memory 0 10) - (func (export "grow") (param i32) (result i32) (grow_memory (local.get 0))) + (func (export "grow") (param i32) (result i32) (memory.grow (local.get 0))) ) (assert_return (invoke "grow" (i32.const 0)) (i32.const 0)) diff --git a/test/spec/return.wast b/test/spec/return.wast index f6fd6de33..9dca8dda9 100644 --- a/test/spec/return.wast +++ b/test/spec/return.wast @@ -178,8 +178,8 @@ (i32.wrap_i64 (return (i32.const 41))) ) - (func (export "as-grow_memory-size") (result i32) - (grow_memory (return (i32.const 40))) + (func (export "as-memory.grow-size") (result i32) + (memory.grow (return (i32.const 40))) ) ) @@ -260,7 +260,7 @@ (assert_return (invoke "as-convert-operand") (i32.const 41)) -(assert_return (invoke "as-grow_memory-size") (i32.const 40)) +(assert_return (invoke "as-memory.grow-size") (i32.const 40)) (assert_invalid (module (func $type-value-empty-vs-num (result f64) (return))) diff --git a/test/spec/typecheck.wast b/test/spec/typecheck.wast index 773d00ffd..fbaf426a5 100644 --- a/test/spec/typecheck.wast +++ b/test/spec/typecheck.wast @@ -429,5 +429,5 @@ (assert_invalid (module (func (f64.promote_f32 (i32.const 0)))) "type mismatch") (assert_invalid (module (func (f64.reinterpret_i64 (i32.const 0)))) "type mismatch") -;; grow_memory -(assert_invalid (module (memory 1) (func (grow_memory (f32.const 0)))) "type mismatch") +;; memory.grow +(assert_invalid (module (memory 1) (func (memory.grow (f32.const 0)))) "type mismatch") diff --git a/test/spec/unreachable.wast b/test/spec/unreachable.wast index ce1d81ba1..ee61f794f 100644 --- a/test/spec/unreachable.wast +++ b/test/spec/unreachable.wast @@ -177,8 +177,8 @@ (i32.wrap_i64 (unreachable)) ) - (func (export "as-grow_memory-size") (result i32) - (grow_memory (unreachable)) + (func (export "as-memory.grow-size") (result i32) + (memory.grow (unreachable)) ) ) @@ -258,5 +258,5 @@ (assert_trap (invoke "as-convert-operand") "unreachable") -(assert_trap (invoke "as-grow_memory-size") "unreachable") +(assert_trap (invoke "as-memory.grow-size") "unreachable") diff --git a/test/unit.asm.js b/test/unit.asm.js index b62c7aefb..405701ee6 100644 --- a/test/unit.asm.js +++ b/test/unit.asm.js @@ -309,14 +309,14 @@ function asm(global, env, buffer) { return phi() | 0; } - function useSetGlobal() { + function useGlobalSet() { var x = 0; x = (Int = 10); Int = 20; return (Int = 30) | 0; } - function usesSetGlobal2() { + function usesGlobalSet2() { return (Int = 40, 50) | 0; } @@ -806,6 +806,6 @@ function asm(global, env, buffer) { var FUNCTION_TABLE_vi = [ vi, vi, vi, vi, vi, vi, vi, vi ]; var FUNCTION_TABLE_ii = [ ii ]; - return { big_negative: big_negative, pick: forgetMe, pick: exportMe, doubleCompares: doubleCompares, intOps: intOps, conversions: conversions, switcher: switcher, frem: frem, frem_float: frem_float, big_uint_div_u: big_uint_div_u, trapping_sint_div_s: trapping_sint_div_s, fr: fr, negZero: negZero, neg: neg, smallCompare: smallCompare, cneg_nosemicolon: cneg_nosemicolon, forLoop: forLoop, ceiling_32_64: ceiling_32_64, aborts: aborts, continues: continues, bitcasts: bitcasts, recursiveBlockMerging: recursiveBlockMerging, lb: lb, zeroInit: zeroInit, phi: phi, smallIf: smallIf, dropCall: dropCall, useSetGlobal: useSetGlobal, usesSetGlobal2: usesSetGlobal2, breakThroughMany: breakThroughMany, ifChainEmpty: ifChainEmpty, heap8NoShift: heap8NoShift, conditionalTypeFun: conditionalTypeFun, loadSigned: loadSigned, globalOpts: globalOpts, dropCallImport: dropCallImport, loophi: loophi, loophi2: loophi2, loophi2b: loophi2b, relooperJumpThreading: relooperJumpThreading, relooperJumpThreading__ZN4game14preloadweaponsEv: relooperJumpThreading__ZN4game14preloadweaponsEv, __Z12multi_varargiz: __Z12multi_varargiz, jumpThreadDrop: jumpThreadDrop, dropIgnoredImportInIf: dropIgnoredImportInIf, dropIgnoredImportsInIf: dropIgnoredImportsInIf, relooperJumpThreading_irreducible: relooperJumpThreading_irreducible, store_fround: store_fround, exportedNumber: 42, relocatableAndModules: relocatableAndModules, exported_f32_user: exported_f32_user, keepAlive: keepAlive }; + return { big_negative: big_negative, pick: forgetMe, pick: exportMe, doubleCompares: doubleCompares, intOps: intOps, conversions: conversions, switcher: switcher, frem: frem, frem_float: frem_float, big_uint_div_u: big_uint_div_u, trapping_sint_div_s: trapping_sint_div_s, fr: fr, negZero: negZero, neg: neg, smallCompare: smallCompare, cneg_nosemicolon: cneg_nosemicolon, forLoop: forLoop, ceiling_32_64: ceiling_32_64, aborts: aborts, continues: continues, bitcasts: bitcasts, recursiveBlockMerging: recursiveBlockMerging, lb: lb, zeroInit: zeroInit, phi: phi, smallIf: smallIf, dropCall: dropCall, useGlobalSet: useGlobalSet, usesGlobalSet2: usesGlobalSet2, breakThroughMany: breakThroughMany, ifChainEmpty: ifChainEmpty, heap8NoShift: heap8NoShift, conditionalTypeFun: conditionalTypeFun, loadSigned: loadSigned, globalOpts: globalOpts, dropCallImport: dropCallImport, loophi: loophi, loophi2: loophi2, loophi2b: loophi2b, relooperJumpThreading: relooperJumpThreading, relooperJumpThreading__ZN4game14preloadweaponsEv: relooperJumpThreading__ZN4game14preloadweaponsEv, __Z12multi_varargiz: __Z12multi_varargiz, jumpThreadDrop: jumpThreadDrop, dropIgnoredImportInIf: dropIgnoredImportInIf, dropIgnoredImportsInIf: dropIgnoredImportsInIf, relooperJumpThreading_irreducible: relooperJumpThreading_irreducible, store_fround: store_fround, exportedNumber: 42, relocatableAndModules: relocatableAndModules, exported_f32_user: exported_f32_user, keepAlive: keepAlive }; } diff --git a/test/unit.fromasm b/test/unit.fromasm index 1bc96b1cf..b6065c905 100644 --- a/test/unit.fromasm +++ b/test/unit.fromasm @@ -53,8 +53,8 @@ (export "phi" (func $phi)) (export "smallIf" (func $smallIf)) (export "dropCall" (func $dropCall)) - (export "useSetGlobal" (func $useSetGlobal)) - (export "usesSetGlobal2" (func $usesSetGlobal2)) + (export "useGlobalSet" (func $useGlobalSet)) + (export "usesGlobalSet2" (func $usesGlobalSet2)) (export "breakThroughMany" (func $breakThroughMany)) (export "ifChainEmpty" (func $ifChainEmpty)) (export "heap8NoShift" (func $heap8NoShift)) @@ -520,7 +520,7 @@ ) (call $phi) ) - (func $useSetGlobal (; 35 ;) (; has Stack IR ;) (result i32) + (func $useGlobalSet (; 35 ;) (; has Stack IR ;) (result i32) (global.set $Int (i32.const 10) ) @@ -532,7 +532,7 @@ ) (global.get $Int) ) - (func $usesSetGlobal2 (; 36 ;) (; has Stack IR ;) (result i32) + (func $usesGlobalSet2 (; 36 ;) (; has Stack IR ;) (result i32) (global.set $Int (i32.const 40) ) diff --git a/test/unit.fromasm.clamp b/test/unit.fromasm.clamp index 147913b80..1a905fee5 100644 --- a/test/unit.fromasm.clamp +++ b/test/unit.fromasm.clamp @@ -51,8 +51,8 @@ (export "phi" (func $phi)) (export "smallIf" (func $smallIf)) (export "dropCall" (func $dropCall)) - (export "useSetGlobal" (func $useSetGlobal)) - (export "usesSetGlobal2" (func $usesSetGlobal2)) + (export "useGlobalSet" (func $useGlobalSet)) + (export "usesGlobalSet2" (func $usesGlobalSet2)) (export "breakThroughMany" (func $breakThroughMany)) (export "ifChainEmpty" (func $ifChainEmpty)) (export "heap8NoShift" (func $heap8NoShift)) @@ -568,7 +568,7 @@ ) (call $phi) ) - (func $useSetGlobal (; 36 ;) (; has Stack IR ;) (result i32) + (func $useGlobalSet (; 36 ;) (; has Stack IR ;) (result i32) (global.set $Int (i32.const 10) ) @@ -580,7 +580,7 @@ ) (global.get $Int) ) - (func $usesSetGlobal2 (; 37 ;) (; has Stack IR ;) (result i32) + (func $usesGlobalSet2 (; 37 ;) (; has Stack IR ;) (result i32) (global.set $Int (i32.const 40) ) diff --git a/test/unit.fromasm.clamp.no-opts b/test/unit.fromasm.clamp.no-opts index 2c45360f2..672d73320 100644 --- a/test/unit.fromasm.clamp.no-opts +++ b/test/unit.fromasm.clamp.no-opts @@ -59,8 +59,8 @@ (export "phi" (func $phi)) (export "smallIf" (func $smallIf)) (export "dropCall" (func $dropCall)) - (export "useSetGlobal" (func $useSetGlobal)) - (export "usesSetGlobal2" (func $usesSetGlobal2)) + (export "useGlobalSet" (func $useGlobalSet)) + (export "usesGlobalSet2" (func $usesGlobalSet2)) (export "breakThroughMany" (func $breakThroughMany)) (export "ifChainEmpty" (func $ifChainEmpty)) (export "heap8NoShift" (func $heap8NoShift)) @@ -1081,7 +1081,7 @@ (call $phi) ) ) - (func $useSetGlobal (; 46 ;) (result i32) + (func $useGlobalSet (; 46 ;) (result i32) (local $x i32) (local.set $x (block (result i32) @@ -1103,7 +1103,7 @@ ) ) ) - (func $usesSetGlobal2 (; 47 ;) (result i32) + (func $usesGlobalSet2 (; 47 ;) (result i32) (return (block (result i32) (block diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise index 62b517f87..bc2546b6e 100644 --- a/test/unit.fromasm.imprecise +++ b/test/unit.fromasm.imprecise @@ -49,8 +49,8 @@ (export "phi" (func $phi)) (export "smallIf" (func $smallIf)) (export "dropCall" (func $dropCall)) - (export "useSetGlobal" (func $useSetGlobal)) - (export "usesSetGlobal2" (func $usesSetGlobal2)) + (export "useGlobalSet" (func $useGlobalSet)) + (export "usesGlobalSet2" (func $usesGlobalSet2)) (export "breakThroughMany" (func $breakThroughMany)) (export "ifChainEmpty" (func $ifChainEmpty)) (export "heap8NoShift" (func $heap8NoShift)) @@ -508,7 +508,7 @@ ) (call $phi) ) - (func $useSetGlobal (; 34 ;) (; has Stack IR ;) (result i32) + (func $useGlobalSet (; 34 ;) (; has Stack IR ;) (result i32) (global.set $Int (i32.const 10) ) @@ -520,7 +520,7 @@ ) (global.get $Int) ) - (func $usesSetGlobal2 (; 35 ;) (; has Stack IR ;) (result i32) + (func $usesGlobalSet2 (; 35 ;) (; has Stack IR ;) (result i32) (global.set $Int (i32.const 40) ) diff --git a/test/unit.fromasm.imprecise.no-opts b/test/unit.fromasm.imprecise.no-opts index 776aa2ba5..b2b0a5f40 100644 --- a/test/unit.fromasm.imprecise.no-opts +++ b/test/unit.fromasm.imprecise.no-opts @@ -59,8 +59,8 @@ (export "phi" (func $phi)) (export "smallIf" (func $smallIf)) (export "dropCall" (func $dropCall)) - (export "useSetGlobal" (func $useSetGlobal)) - (export "usesSetGlobal2" (func $usesSetGlobal2)) + (export "useGlobalSet" (func $useGlobalSet)) + (export "usesGlobalSet2" (func $usesGlobalSet2)) (export "breakThroughMany" (func $breakThroughMany)) (export "ifChainEmpty" (func $ifChainEmpty)) (export "heap8NoShift" (func $heap8NoShift)) @@ -992,7 +992,7 @@ (call $phi) ) ) - (func $useSetGlobal (; 42 ;) (result i32) + (func $useGlobalSet (; 42 ;) (result i32) (local $x i32) (local.set $x (block (result i32) @@ -1014,7 +1014,7 @@ ) ) ) - (func $usesSetGlobal2 (; 43 ;) (result i32) + (func $usesGlobalSet2 (; 43 ;) (result i32) (return (block (result i32) (block diff --git a/test/unit.fromasm.no-opts b/test/unit.fromasm.no-opts index 216d30d34..84dcdf881 100644 --- a/test/unit.fromasm.no-opts +++ b/test/unit.fromasm.no-opts @@ -61,8 +61,8 @@ (export "phi" (func $phi)) (export "smallIf" (func $smallIf)) (export "dropCall" (func $dropCall)) - (export "useSetGlobal" (func $useSetGlobal)) - (export "usesSetGlobal2" (func $usesSetGlobal2)) + (export "useGlobalSet" (func $useGlobalSet)) + (export "usesGlobalSet2" (func $usesGlobalSet2)) (export "breakThroughMany" (func $breakThroughMany)) (export "ifChainEmpty" (func $ifChainEmpty)) (export "heap8NoShift" (func $heap8NoShift)) @@ -1033,7 +1033,7 @@ (call $phi) ) ) - (func $useSetGlobal (; 45 ;) (result i32) + (func $useGlobalSet (; 45 ;) (result i32) (local $x i32) (local.set $x (block (result i32) @@ -1055,7 +1055,7 @@ ) ) ) - (func $usesSetGlobal2 (; 46 ;) (result i32) + (func $usesGlobalSet2 (; 46 ;) (result i32) (return (block (result i32) (block diff --git a/test/wasm2js/address.2asm.js b/test/wasm2js/address.2asm.js index 366bcec11..4038425ba 100644 --- a/test/wasm2js/address.2asm.js +++ b/test/wasm2js/address.2asm.js @@ -46,9 +46,9 @@ function asmFunc(global, env, buffer) { } var FUNCTION_TABLE = []; - function __wasm_grow_memory(pagesToAdd) { + function __wasm_memory_grow(pagesToAdd) { pagesToAdd = pagesToAdd | 0; - var oldPages = __wasm_current_memory() | 0; + var oldPages = __wasm_memory_size() | 0; var newPages = oldPages + pagesToAdd | 0; if ((oldPages < newPages) && (newPages < 65536)) { var newBuffer = new ArrayBuffer(Math_imul(newPages, 65536)); @@ -68,7 +68,7 @@ function asmFunc(global, env, buffer) { return oldPages; } - function __wasm_current_memory() { + function __wasm_memory_size() { return buffer.byteLength / 65536 | 0; } diff --git a/test/wasm2js/br.2asm.js b/test/wasm2js/br.2asm.js index f02b0a154..2dfb17d2e 100644 --- a/test/wasm2js/br.2asm.js +++ b/test/wasm2js/br.2asm.js @@ -695,7 +695,7 @@ function asmFunc(global, env, buffer) { "as_compare_left": $49, "as_compare_right": $50, "as_convert_operand": $51, - "as_grow_memory_size": $52, + "as_memory_grow_size": $52, "nested_block_value": $53, "nested_br_value": $54, "nested_br_if_value": $55, @@ -757,7 +757,7 @@ export var as_test_operand = retasmFunc.as_test_operand; export var as_compare_left = retasmFunc.as_compare_left; export var as_compare_right = retasmFunc.as_compare_right; export var as_convert_operand = retasmFunc.as_convert_operand; -export var as_grow_memory_size = retasmFunc.as_grow_memory_size; +export var as_memory_grow_size = retasmFunc.as_memory_grow_size; export var nested_block_value = retasmFunc.nested_block_value; export var nested_br_value = retasmFunc.nested_br_value; export var nested_br_if_value = retasmFunc.nested_br_if_value; diff --git a/test/wasm2js/br_table.2asm.js b/test/wasm2js/br_table.2asm.js index 952e99b1b..b462871e5 100644 --- a/test/wasm2js/br_table.2asm.js +++ b/test/wasm2js/br_table.2asm.js @@ -13377,7 +13377,7 @@ function asmFunc(global, env, buffer) { "as_compare_left": $56, "as_compare_right": $57, "as_convert_operand": $58, - "as_grow_memory_size": $59, + "as_memory_grow_size": $59, "nested_block_value": $60, "nested_br_value": $61, "nested_br_if_value": $62, @@ -13446,7 +13446,7 @@ export var as_test_operand = retasmFunc.as_test_operand; export var as_compare_left = retasmFunc.as_compare_left; export var as_compare_right = retasmFunc.as_compare_right; export var as_convert_operand = retasmFunc.as_convert_operand; -export var as_grow_memory_size = retasmFunc.as_grow_memory_size; +export var as_memory_grow_size = retasmFunc.as_memory_grow_size; export var nested_block_value = retasmFunc.nested_block_value; export var nested_br_value = retasmFunc.nested_br_value; export var nested_br_if_value = retasmFunc.nested_br_if_value; diff --git a/test/wasm2js/br_table_temp.2asm.js b/test/wasm2js/br_table_temp.2asm.js index b55d6ab24..34dffb54e 100644 --- a/test/wasm2js/br_table_temp.2asm.js +++ b/test/wasm2js/br_table_temp.2asm.js @@ -13281,7 +13281,7 @@ function asmFunc(global, env, buffer) { "as_compare_left": $56, "as_compare_right": $57, "as_convert_operand": $58, - "as_grow_memory_size": $59, + "as_memory_grow_size": $59, "nested_block_value": $60, "nested_br_value": $61, "nested_br_if_value": $62, @@ -13350,7 +13350,7 @@ export var as_test_operand = retasmFunc.as_test_operand; export var as_compare_left = retasmFunc.as_compare_left; export var as_compare_right = retasmFunc.as_compare_right; export var as_convert_operand = retasmFunc.as_convert_operand; -export var as_grow_memory_size = retasmFunc.as_grow_memory_size; +export var as_memory_grow_size = retasmFunc.as_memory_grow_size; export var nested_block_value = retasmFunc.nested_block_value; export var nested_br_value = retasmFunc.nested_br_value; export var nested_br_if_value = retasmFunc.nested_br_if_value; diff --git a/test/wasm2js/br_table_temp.2asm.js.opt b/test/wasm2js/br_table_temp.2asm.js.opt index 4633a99e3..eae9b99ab 100644 --- a/test/wasm2js/br_table_temp.2asm.js.opt +++ b/test/wasm2js/br_table_temp.2asm.js.opt @@ -12729,7 +12729,7 @@ function asmFunc(global, env, buffer) { "as_compare_left": $56, "as_compare_right": $57, "as_convert_operand": $58, - "as_grow_memory_size": $59, + "as_memory_grow_size": $59, "nested_block_value": $60, "nested_br_value": $61, "nested_br_if_value": $62, @@ -12798,7 +12798,7 @@ export var as_test_operand = retasmFunc.as_test_operand; export var as_compare_left = retasmFunc.as_compare_left; export var as_compare_right = retasmFunc.as_compare_right; export var as_convert_operand = retasmFunc.as_convert_operand; -export var as_grow_memory_size = retasmFunc.as_grow_memory_size; +export var as_memory_grow_size = retasmFunc.as_memory_grow_size; export var nested_block_value = retasmFunc.nested_block_value; export var nested_br_value = retasmFunc.nested_br_value; export var nested_br_if_value = retasmFunc.nested_br_if_value; diff --git a/test/wasm2js/br_table_temp.wast b/test/wasm2js/br_table_temp.wast index 865072b28..1ddff07ca 100644 --- a/test/wasm2js/br_table_temp.wast +++ b/test/wasm2js/br_table_temp.wast @@ -1090,8 +1090,8 @@ (block i32 (i32.wrap_i64 (br_table 0 (i32.const 41) (i32.const 0)))) ) - (func (export "as-grow_memory-size") (result i32) - (block i32 (grow_memory (br_table 0 (i32.const 40) (i32.const 0)))) + (func (export "as-memory.grow-size") (result i32) + (block i32 (memory.grow (br_table 0 (i32.const 40) (i32.const 0)))) ) (func (export "nested-block-value") (param i32) (result i32) @@ -1331,7 +1331,7 @@ (assert_return (invoke "as-convert-operand") (i32.const 41)) -(assert_return (invoke "as-grow_memory-size") (i32.const 40)) +(assert_return (invoke "as-memory.grow-size") (i32.const 40)) (assert_return (invoke "nested-block-value" (i32.const 0)) (i32.const 19)) (assert_return (invoke "nested-block-value" (i32.const 1)) (i32.const 17)) diff --git a/test/wasm2js/emscripten.wast b/test/wasm2js/emscripten.wast index 5b1b81507..2f9e560ca 100644 --- a/test/wasm2js/emscripten.wast +++ b/test/wasm2js/emscripten.wast @@ -197,7 +197,7 @@ (call $getf64) ) (func $__growWasmMemory (param $0 i32) (result i32) - (grow_memory + (memory.grow (local.get $0) ) ) diff --git a/test/wasm2js/endianness.2asm.js b/test/wasm2js/endianness.2asm.js index 364486744..ef27e82d9 100644 --- a/test/wasm2js/endianness.2asm.js +++ b/test/wasm2js/endianness.2asm.js @@ -651,9 +651,9 @@ function asmFunc(global, env, buffer) { } var FUNCTION_TABLE = []; - function __wasm_grow_memory(pagesToAdd) { + function __wasm_memory_grow(pagesToAdd) { pagesToAdd = pagesToAdd | 0; - var oldPages = __wasm_current_memory() | 0; + var oldPages = __wasm_memory_size() | 0; var newPages = oldPages + pagesToAdd | 0; if ((oldPages < newPages) && (newPages < 65536)) { var newBuffer = new ArrayBuffer(Math_imul(newPages, 65536)); @@ -673,7 +673,7 @@ function asmFunc(global, env, buffer) { return oldPages; } - function __wasm_current_memory() { + function __wasm_memory_size() { return buffer.byteLength / 65536 | 0; } diff --git a/test/wasm2js/grow-memory-tricky.2asm.js b/test/wasm2js/grow-memory-tricky.2asm.js index ed69a4a43..0e92bc100 100644 --- a/test/wasm2js/grow-memory-tricky.2asm.js +++ b/test/wasm2js/grow-memory-tricky.2asm.js @@ -23,7 +23,7 @@ function asmFunc(global, env, buffer) { var infinity = global.Infinity; function $0() { var wasm2js_i32$0 = 0, wasm2js_i32$1 = 0; - (wasm2js_i32$0 = 0, wasm2js_i32$1 = __wasm_grow_memory(1 | 0)), HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + (wasm2js_i32$0 = 0, wasm2js_i32$1 = __wasm_memory_grow(1 | 0)), HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; return HEAP32[0 >> 2] | 0 | 0; } @@ -34,13 +34,13 @@ function asmFunc(global, env, buffer) { } function grow() { - return __wasm_grow_memory(1 | 0) | 0; + return __wasm_memory_grow(1 | 0) | 0; } var FUNCTION_TABLE = []; - function __wasm_grow_memory(pagesToAdd) { + function __wasm_memory_grow(pagesToAdd) { pagesToAdd = pagesToAdd | 0; - var oldPages = __wasm_current_memory() | 0; + var oldPages = __wasm_memory_size() | 0; var newPages = oldPages + pagesToAdd | 0; if ((oldPages < newPages) && (newPages < 65536)) { var newBuffer = new ArrayBuffer(Math_imul(newPages, 65536)); @@ -60,14 +60,14 @@ function asmFunc(global, env, buffer) { return oldPages; } - function __wasm_current_memory() { + function __wasm_memory_size() { return buffer.byteLength / 65536 | 0; } return { "memory": Object.create(Object.prototype, { "grow": { - "value": __wasm_grow_memory + "value": __wasm_memory_grow }, "buffer": { "get": function () { diff --git a/test/wasm2js/grow-memory-tricky.2asm.js.opt b/test/wasm2js/grow-memory-tricky.2asm.js.opt index 42255e0f8..078fad5ec 100644 --- a/test/wasm2js/grow-memory-tricky.2asm.js.opt +++ b/test/wasm2js/grow-memory-tricky.2asm.js.opt @@ -23,14 +23,14 @@ function asmFunc(global, env, buffer) { var infinity = global.Infinity; function $0() { var wasm2js_i32$0 = 0, wasm2js_i32$1 = 0; - (wasm2js_i32$0 = 0, wasm2js_i32$1 = __wasm_grow_memory(1)), HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + (wasm2js_i32$0 = 0, wasm2js_i32$1 = __wasm_memory_grow(1)), HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; return HEAP32[0]; } var FUNCTION_TABLE = []; - function __wasm_grow_memory(pagesToAdd) { + function __wasm_memory_grow(pagesToAdd) { pagesToAdd = pagesToAdd | 0; - var oldPages = __wasm_current_memory() | 0; + var oldPages = __wasm_memory_size() | 0; var newPages = oldPages + pagesToAdd | 0; if ((oldPages < newPages) && (newPages < 65536)) { var newBuffer = new ArrayBuffer(Math_imul(newPages, 65536)); @@ -50,14 +50,14 @@ function asmFunc(global, env, buffer) { return oldPages; } - function __wasm_current_memory() { + function __wasm_memory_size() { return buffer.byteLength / 65536 | 0; } return { "memory": Object.create(Object.prototype, { "grow": { - "value": __wasm_grow_memory + "value": __wasm_memory_grow }, "buffer": { "get": function () { diff --git a/test/wasm2js/grow-memory-tricky.wast b/test/wasm2js/grow-memory-tricky.wast index 8513eb2af..163892d58 100644 --- a/test/wasm2js/grow-memory-tricky.wast +++ b/test/wasm2js/grow-memory-tricky.wast @@ -8,7 +8,7 @@ (func $0 (result i32) (block (result i32) - (i32.store (i32.const 0) (grow_memory (i32.const 1))) + (i32.store (i32.const 0) (memory.grow (i32.const 1))) (i32.load (i32.const 0)) ) ) @@ -21,7 +21,7 @@ ) (func $grow (result i32) - (grow_memory (i32.const 1)) + (memory.grow (i32.const 1)) ) ) diff --git a/test/wasm2js/grow_memory.2asm.js b/test/wasm2js/grow_memory.2asm.js index 372442436..0e9864bc3 100644 --- a/test/wasm2js/grow_memory.2asm.js +++ b/test/wasm2js/grow_memory.2asm.js @@ -23,17 +23,17 @@ function asmFunc(global, env, buffer) { var infinity = global.Infinity; function $0(var$0) { var$0 = var$0 | 0; - return __wasm_grow_memory(var$0 | 0) | 0; + return __wasm_memory_grow(var$0 | 0) | 0; } function $1() { - return __wasm_current_memory() | 0; + return __wasm_memory_size() | 0; } var FUNCTION_TABLE = []; - function __wasm_grow_memory(pagesToAdd) { + function __wasm_memory_grow(pagesToAdd) { pagesToAdd = pagesToAdd | 0; - var oldPages = __wasm_current_memory() | 0; + var oldPages = __wasm_memory_size() | 0; var newPages = oldPages + pagesToAdd | 0; if ((oldPages < newPages) && (newPages < 65536)) { var newBuffer = new ArrayBuffer(Math_imul(newPages, 65536)); @@ -53,14 +53,14 @@ function asmFunc(global, env, buffer) { return oldPages; } - function __wasm_current_memory() { + function __wasm_memory_size() { return buffer.byteLength / 65536 | 0; } return { "memory": Object.create(Object.prototype, { "grow": { - "value": __wasm_grow_memory + "value": __wasm_memory_grow }, "buffer": { "get": function () { diff --git a/test/wasm2js/left-to-right.2asm.js b/test/wasm2js/left-to-right.2asm.js index 74fe50cd6..8f8f6db3f 100644 --- a/test/wasm2js/left-to-right.2asm.js +++ b/test/wasm2js/left-to-right.2asm.js @@ -2091,9 +2091,9 @@ function asmFunc(global, env, buffer) { } var FUNCTION_TABLE = [i32_t0, i32_t1, i64_t0, i64_t1, f32_t0, f32_t1, f64_t0, f64_t1]; - function __wasm_grow_memory(pagesToAdd) { + function __wasm_memory_grow(pagesToAdd) { pagesToAdd = pagesToAdd | 0; - var oldPages = __wasm_current_memory() | 0; + var oldPages = __wasm_memory_size() | 0; var newPages = oldPages + pagesToAdd | 0; if ((oldPages < newPages) && (newPages < 65536)) { var newBuffer = new ArrayBuffer(Math_imul(newPages, 65536)); @@ -2113,7 +2113,7 @@ function asmFunc(global, env, buffer) { return oldPages; } - function __wasm_current_memory() { + function __wasm_memory_size() { return buffer.byteLength / 65536 | 0; } diff --git a/test/wasm2js/traps.2asm.js b/test/wasm2js/traps.2asm.js index e702a65a0..bba034c13 100644 --- a/test/wasm2js/traps.2asm.js +++ b/test/wasm2js/traps.2asm.js @@ -1973,9 +1973,9 @@ function asmFunc(global, env, buffer) { } var FUNCTION_TABLE = []; - function __wasm_grow_memory(pagesToAdd) { + function __wasm_memory_grow(pagesToAdd) { pagesToAdd = pagesToAdd | 0; - var oldPages = __wasm_current_memory() | 0; + var oldPages = __wasm_memory_size() | 0; var newPages = oldPages + pagesToAdd | 0; if ((oldPages < newPages) && (newPages < 65536)) { var newBuffer = new ArrayBuffer(Math_imul(newPages, 65536)); @@ -1995,7 +1995,7 @@ function asmFunc(global, env, buffer) { return oldPages; } - function __wasm_current_memory() { + function __wasm_memory_size() { return buffer.byteLength / 65536 | 0; } diff --git a/test/wasm2js/unreachable.2asm.js b/test/wasm2js/unreachable.2asm.js index 47a5ff4da..b2eeb0bec 100644 --- a/test/wasm2js/unreachable.2asm.js +++ b/test/wasm2js/unreachable.2asm.js @@ -432,7 +432,7 @@ function asmFunc(global, env, buffer) { "as_compare_left": $51, "as_compare_right": $52, "as_convert_operand": $53, - "as_grow_memory_size": $54 + "as_memory_grow_size": $54 }; } @@ -490,4 +490,4 @@ export var as_test_operand = retasmFunc.as_test_operand; export var as_compare_left = retasmFunc.as_compare_left; export var as_compare_right = retasmFunc.as_compare_right; export var as_convert_operand = retasmFunc.as_convert_operand; -export var as_grow_memory_size = retasmFunc.as_grow_memory_size; +export var as_memory_grow_size = retasmFunc.as_memory_grow_size; |