summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/abi/stack.h20
-rw-r--r--src/asm2wasm.h56
-rw-r--r--src/asmjs/shared-constants.cpp4
-rw-r--r--src/asmjs/shared-constants.h4
-rw-r--r--src/binaryen-c.cpp124
-rw-r--r--src/binaryen-c.h47
-rw-r--r--src/cfg/Relooper.h8
-rw-r--r--src/cfg/liveness-traversal.h36
-rw-r--r--src/dataflow/graph.h28
-rw-r--r--src/gen-s-parser.inc52
-rw-r--r--src/ir/ExpressionAnalyzer.cpp8
-rw-r--r--src/ir/ExpressionManipulator.cpp18
-rw-r--r--src/ir/LocalGraph.cpp30
-rw-r--r--src/ir/ReFinalize.cpp8
-rw-r--r--src/ir/cost.h8
-rw-r--r--src/ir/effects.h14
-rw-r--r--src/ir/flat.h4
-rw-r--r--src/ir/global-utils.h2
-rw-r--r--src/ir/local-graph.h8
-rw-r--r--src/ir/local-utils.h30
-rw-r--r--src/ir/localize.h6
-rw-r--r--src/ir/properties.h2
-rw-r--r--src/ir/utils.h22
-rw-r--r--src/js/binaryen.js-post.js68
-rw-r--r--src/passes/AlignmentLowering.cpp54
-rw-r--r--src/passes/AvoidReinterprets.cpp20
-rw-r--r--src/passes/CoalesceLocals.cpp18
-rw-r--r--src/passes/CodePushing.cpp14
-rw-r--r--src/passes/ConstHoisting.cpp4
-rw-r--r--src/passes/DeadArgumentElimination.cpp10
-rw-r--r--src/passes/DeadCodeElimination.cpp20
-rw-r--r--src/passes/Flatten.cpp32
-rw-r--r--src/passes/FuncCastEmulation.cpp2
-rw-r--r--src/passes/I64ToI32Lowering.cpp334
-rw-r--r--src/passes/Inlining.cpp8
-rw-r--r--src/passes/InstrumentLocals.cpp4
-rw-r--r--src/passes/LegalizeJSInterface.cpp6
-rw-r--r--src/passes/LocalCSE.cpp12
-rw-r--r--src/passes/LoopInvariantCodeMotion.cpp14
-rw-r--r--src/passes/MergeBlocks.cpp2
-rw-r--r--src/passes/MergeLocals.cpp14
-rw-r--r--src/passes/OptimizeAddedConstants.cpp30
-rw-r--r--src/passes/OptimizeInstructions.cpp22
-rw-r--r--src/passes/PickLoadSigns.cpp4
-rw-r--r--src/passes/PostEmscripten.cpp2
-rw-r--r--src/passes/Precompute.cpp16
-rw-r--r--src/passes/Print.cpp28
-rw-r--r--src/passes/RedundantSetElimination.cpp12
-rw-r--r--src/passes/RelooperJumpThreading.cpp14
-rw-r--r--src/passes/RemoveNonJSOps.cpp2
-rw-r--r--src/passes/RemoveUnusedBrs.cpp16
-rw-r--r--src/passes/RemoveUnusedModuleElements.cpp6
-rw-r--r--src/passes/ReorderLocals.cpp8
-rw-r--r--src/passes/SSAify.cpp14
-rw-r--r--src/passes/SafeHeap.cpp22
-rw-r--r--src/passes/SimplifyGlobals.cpp6
-rw-r--r--src/passes/SimplifyLocals.cpp98
-rw-r--r--src/passes/Souperify.cpp6
-rw-r--r--src/passes/SpillPointers.cpp10
-rw-r--r--src/passes/StackIR.cpp8
-rw-r--r--src/passes/TrapMode.cpp16
-rw-r--r--src/passes/Untee.cpp4
-rw-r--r--src/passes/Vacuum.cpp10
-rw-r--r--src/tools/asm2wasm.cpp2
-rw-r--r--src/tools/fuzzing.h64
-rw-r--r--src/tools/wasm-ctor-eval.cpp4
-rw-r--r--src/tools/wasm-metadce.cpp8
-rw-r--r--src/wasm-binary.h34
-rw-r--r--src/wasm-builder.h20
-rw-r--r--src/wasm-interpreter.h28
-rw-r--r--src/wasm-s-parser.h10
-rw-r--r--src/wasm-stack.h48
-rw-r--r--src/wasm-traversal.h92
-rw-r--r--src/wasm.h34
-rw-r--r--src/wasm/wasm-binary.cpp66
-rw-r--r--src/wasm/wasm-emscripten.cpp42
-rw-r--r--src/wasm/wasm-s-parser.cpp24
-rw-r--r--src/wasm/wasm-validator.cpp31
-rw-r--r--src/wasm/wasm.cpp20
-rw-r--r--src/wasm2js.h54
80 files changed, 1049 insertions, 1061 deletions
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));