summaryrefslogtreecommitdiff
path: root/src/passes
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes')
-rw-r--r--src/passes/Asyncify.cpp15
-rw-r--r--src/passes/DeadArgumentElimination.cpp2
-rw-r--r--src/passes/FuncCastEmulation.cpp6
-rw-r--r--src/passes/I64ToI32Lowering.cpp2
-rw-r--r--src/passes/LegalizeJSInterface.cpp16
-rw-r--r--src/passes/Print.cpp32
6 files changed, 36 insertions, 37 deletions
diff --git a/src/passes/Asyncify.cpp b/src/passes/Asyncify.cpp
index 2aca16942..1bbc89435 100644
--- a/src/passes/Asyncify.cpp
+++ b/src/passes/Asyncify.cpp
@@ -1304,10 +1304,9 @@ private:
if (!relevantLiveLocals.count(i)) {
continue;
}
- const auto& types = func->getLocalType(i).expand();
+ auto localType = func->getLocalType(i);
SmallVector<Expression*, 1> loads;
- for (Index j = 0; j < types.size(); j++) {
- auto type = types[j];
+ for (auto& type : localType) {
auto size = type.getByteSize();
assert(size % STACK_ALIGN == 0);
// TODO: higher alignment?
@@ -1323,7 +1322,7 @@ private:
Expression* load;
if (loads.size() == 1) {
load = loads[0];
- } else if (types.size() > 1) {
+ } else if (localType.size() > 1) {
load = builder->makeTupleMake(std::move(loads));
} else {
WASM_UNREACHABLE("Unexpected empty type");
@@ -1350,12 +1349,11 @@ private:
continue;
}
auto localType = func->getLocalType(i);
- const auto& types = localType.expand();
- for (Index j = 0; j < types.size(); j++) {
- auto type = types[j];
+ size_t j = 0;
+ for (auto& type : localType) {
auto size = type.getByteSize();
Expression* localGet = builder->makeLocalGet(i, localType);
- if (types.size() > 1) {
+ if (localType.size() > 1) {
localGet = builder->makeTupleExtract(localGet, j);
}
assert(size % STACK_ALIGN == 0);
@@ -1368,6 +1366,7 @@ private:
localGet,
type));
offset += size;
+ ++j;
}
}
block->list.push_back(builder->makeIncStackPos(offset));
diff --git a/src/passes/DeadArgumentElimination.cpp b/src/passes/DeadArgumentElimination.cpp
index a20ff1fb8..9fed4f1dc 100644
--- a/src/passes/DeadArgumentElimination.cpp
+++ b/src/passes/DeadArgumentElimination.cpp
@@ -409,7 +409,7 @@ private:
// Remove the parameter from the function. We must add a new local
// for uses of the parameter, but cannot make it use the same index
// (in general).
- std::vector<Type> params = func->sig.params.expand();
+ std::vector<Type> params(func->sig.params.begin(), func->sig.params.end());
auto type = params[i];
params.erase(params.begin() + i);
func->sig.params = Type(params);
diff --git a/src/passes/FuncCastEmulation.cpp b/src/passes/FuncCastEmulation.cpp
index 9e455b0c8..a2f47ca90 100644
--- a/src/passes/FuncCastEmulation.cpp
+++ b/src/passes/FuncCastEmulation.cpp
@@ -193,13 +193,13 @@ private:
}
// The item in the table may be a function or a function import.
auto* func = module->getFunction(name);
- const std::vector<Type>& params = func->sig.params.expand();
Type type = func->sig.results;
Builder builder(*module);
std::vector<Expression*> callOperands;
- for (Index i = 0; i < params.size(); i++) {
+ Index i = 0;
+ for (auto& param : func->sig.params) {
callOperands.push_back(
- fromABI(builder.makeLocalGet(i, Type::i64), params[i], module));
+ fromABI(builder.makeLocalGet(i++, Type::i64), param, 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 f66af87cc..41d0e799a 100644
--- a/src/passes/I64ToI32Lowering.cpp
+++ b/src/passes/I64ToI32Lowering.cpp
@@ -272,7 +272,7 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> {
visitGenericCall<CallIndirect>(
curr, [&](std::vector<Expression*>& args, Type results) {
std::vector<Type> params;
- for (auto param : curr->sig.params.expand()) {
+ for (auto& param : curr->sig.params) {
if (param == Type::i64) {
params.push_back(Type::i32);
params.push_back(Type::i32);
diff --git a/src/passes/LegalizeJSInterface.cpp b/src/passes/LegalizeJSInterface.cpp
index 659165306..9a4dc6b63 100644
--- a/src/passes/LegalizeJSInterface.cpp
+++ b/src/passes/LegalizeJSInterface.cpp
@@ -183,7 +183,7 @@ private:
std::map<Name, Name> illegalImportsToLegal;
template<typename T> bool isIllegal(T* t) {
- for (auto param : t->sig.params.expand()) {
+ for (auto& param : t->sig.params) {
if (param == Type::i64) {
return true;
}
@@ -222,9 +222,8 @@ private:
call->target = func->name;
call->type = func->sig.results;
- const std::vector<Type>& params = func->sig.params.expand();
std::vector<Type> legalParams;
- for (auto param : params) {
+ for (auto& param : func->sig.params) {
if (param == Type::i64) {
call->operands.push_back(I64Utilities::recreateI64(
builder, legalParams.size(), legalParams.size() + 1));
@@ -277,18 +276,19 @@ private:
auto* call = module->allocator.alloc<Call>();
call->target = legalIm->name;
- const std::vector<Type>& imParams = im->sig.params.expand();
std::vector<Type> params;
- for (size_t i = 0; i < imParams.size(); ++i) {
- if (imParams[i] == Type::i64) {
+ Index i = 0;
+ for (auto& param : im->sig.params) {
+ if (param == Type::i64) {
call->operands.push_back(I64Utilities::getI64Low(builder, i));
call->operands.push_back(I64Utilities::getI64High(builder, i));
params.push_back(Type::i32);
params.push_back(Type::i32);
} else {
- call->operands.push_back(builder.makeLocalGet(i, imParams[i]));
- params.push_back(imParams[i]);
+ call->operands.push_back(builder.makeLocalGet(i, param));
+ params.push_back(param);
}
+ ++i;
}
if (im->sig.results == Type::i64) {
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index d90e7f958..ba4e022e0 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -67,15 +67,16 @@ struct SExprType {
static std::ostream& operator<<(std::ostream& o, const SExprType& localType) {
Type type = localType.type;
if (type.isMulti()) {
- const std::vector<Type>& types = type.expand();
- o << '(' << types[0];
- for (size_t i = 1; i < types.size(); ++i) {
- o << ' ' << types[i];
+ o << '(';
+ auto sep = "";
+ for (auto& t : type) {
+ o << sep << t;
+ sep = " ";
}
o << ')';
- return o;
+ } else {
+ o << type;
}
- o << type;
return o;
}
@@ -90,12 +91,10 @@ std::ostream& operator<<(std::ostream& os, SigName sigName) {
if (type == Type::none) {
os << "none";
} else {
- const std::vector<Type>& types = type.expand();
- for (size_t i = 0; i < types.size(); ++i) {
- if (i != 0) {
- os << '_';
- }
- os << types[i];
+ auto sep = "";
+ for (auto& t : type) {
+ os << sep << t;
+ sep = "_";
}
}
};
@@ -2169,14 +2168,15 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
if (!printStackIR && curr->stackIR && !minify) {
o << " (; has Stack IR ;)";
}
- const std::vector<Type>& params = curr->sig.params.expand();
- if (params.size() > 0) {
- for (size_t i = 0; i < params.size(); i++) {
+ if (curr->sig.params.size() > 0) {
+ Index i = 0;
+ for (auto& param : curr->sig.params) {
o << maybeSpace;
o << '(';
printMinor(o, "param ");
printLocal(i, currFunction, o);
- o << ' ' << params[i] << ')';
+ o << ' ' << param << ')';
+ ++i;
}
}
if (curr->sig.results != Type::none) {